Cleaning up is easy. We need to restore the frame pointer to its old value. This is almost trivial because the frame pointer (%ebp) points to its own old value! However, we also need to move the stack pointer accordingly. This is because a subroutine may use additional push instructions or use more of the stack for other purposes (as we will see later). In other words, the stack pointer is likely to point to somewhere lower than where the frame pointer points to.
We can kill three birds with a few pebbles (to clean up and restore both the stack pointer and the frame pointer, then return):
This sequence of instructions is so useful that Intel decided to offer a single instruction to do all three. However, for a class, it is best to spell out the instructions so that we are aware of what actually happens when a subroutine returns.