You have allocated my_array
on the stack (automatic storage), this means the compiler has to decrement the stack pointer (the stack grows towards lower addresses) by the size of your local variables plus room to save registers and such. The %ebp
base pointer is set to point to the frame pointer of the caller (after saving the caller's base pointer by pushing it on the stack). This is part of the convention necessary for proper stack unwinding. See Chapter 9 Exception handling and stack unwinding in Agner Fog's comprehensive Calling Conventions document
http://www.agner.org/optimize/calling_conventions.pdf.
Since %ebp
is pointing to the caller's frame, the compiler uses a negative offset from it to point to the beginning of my_array
, a local variable in the called function.
I don't have an answer as to why the compiler stored the address in %rax
and immediately copied it to %rdi
, it seems it could have done that in one step
leaq -24016(%rbp), %rdi