For local variables, the called function allocates space for them by decreasing the value of the rsp/esp register. To allocate space for two variables of four bytes each, the code will be this:
push ebp
mov ebp,esp
sub esp, 8
Additionally, the end of the function will be this:
mov ebp,esp
pop ebp
ret
Figure 4: An example of a stack change at the beginning and at the end of the function
Additionally, if there are arguments, the ret instruction cleans the stack given the number of bytes to pull out from the top of the stack like this:
ret 8 ;2 Arguments, 4 bytes each