For my homework assignment I am supposed to convert this C code
 #define UPPER 15
 const int lower = 12;
 int sum = 0;
 int main(void) {
   int i;
   for (i = lower; i < UPPER; i++) {
     sum += i;
   }
   return sum;
 }
into gcc assembly. I already compiled it to first study the code before doing it per hand (obviously translating by hand is going to look much differently). This is the assembler code I received:
.file   "upper.c"
.globl  lower
.section    .rodata
.align 4
.type   lower, @object
.size   lower, 4
    lower:
.long   12
.globl  sum
.bss
.align 4
.type   sum, @object
.size   sum, 4
     sum:
.zero   4
.text
.globl  main
.type   main, @function
    main:
    .LFB0:
.cfi_startproc
pushq   %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq    %rsp, %rbp
.cfi_def_cfa_register 6
movl    $12, -4(%rbp)
jmp .L2
    .L3:
movl    sum(%rip), %edx
movl    -4(%rbp), %eax
addl    %edx, %eax
movl    %eax, sum(%rip)
addl    $1, -4(%rbp)
    .L2:
cmpl    $14, -4(%rbp)
jle .L3
movl    sum(%rip), %eax
popq    %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
    .LFE0:
.size   main, .-main
.ident  "GCC: (SUSE Linux) 4.8.1 20130909 [gcc-4_8-branch revision 202388]"
.section    .note.GNU-stack,"",@progbits
Now I was wondering if someone could give me a few examples like
- where the constructors i, lower, upper and sum are located it in code
- where some of the expressions i = lower or i < UPPER are located
- where the for-loop starts
and such things so I can then get an idea of how the assembler code is constructed. Thank you!
 
    