ganbree 7 Light Poster

I'm trying to advance my understanding of how computers and compilers work.

Given the C++ program bellow with exceptions and runtime typing turned off and no optimizing that removes main or makes it into a non-standard function.

int main() {return0;}

Produced an disassembly with the following code for main:

pushl	%ebp ; pushes the stack frame
xorl	%eax, %eax  ; sets the eax register to zero
movl	%esp, %ebp  ; empties the stack frame
leave
ret ; return with 0 in eax

1. What will the assembly that calls the main function look like?
2. What will be on the start before this code is run?
3. What will EBP (the stack frame pointer) be at the start? Garbage values?
4. What is in the accumulator at the start? Garbage values again?
5. What does the leave function do? I've read around for this but I can't find anything that makes much sense.
6. To what address will ret jump the instruction pointer to?
7. What does the assembly look like for the code that is executed the main function exits?
8. Another thing that is being getting at me is: why does C++ CDECL calling convention pass argument right to left? It seems counter intuitive to me as it rewards doing right to left as the order of evaluation of the parameters which is also counter intuitive to me.

Thanks in advance, any help would be much appreciated