All the UI code. It is a legacy created for text-terminal. It works in a graphic environments due to hacks, but it is sad.
If emacs was built on top of a decent ui-toolkit, with nice widgets, like checkboxes, buttons, menus, scrollbars (i do not know how to use emacs' scrollbars). With panes (windows in emacs' terms) resizeable with mouse (one more pain point: I need to resize them maybe once per month, and I never quite remember how it may be done).
UI of emacs is bad, it is terrible. It missed completely 30 last years of UI progress.