Simple Assembly Output

C code (full program)

int main(void)
{
  int a = 1;
  int b = 2;
  int c = 3;
  int d = 4;
  int e = a * b * (c + d);
  return 0;
}

Compiler-generated assembly code (32-bit)

GNU (simple.s)
gcc -S simple.c
Microsoft 7.1 (simple.asm)
cl -c -FA simple.c
  .file "simple.c"
  .def  ___main;  .scl  2;  .type 32; .endef
  .text
  .globl _main
  .def  _main;  .scl  2;  .type 32; .endef
_main:
  pushl %ebp
  movl  %esp, %ebp
  subl  $24, %esp
  andl  $-16, %esp
  movl  $0, %eax
  addl  $15, %eax
  addl  $15, %eax
  shrl  $4, %eax
  sall  $4, %eax
  movl  %eax, -24(%ebp)
  movl  -24(%ebp), %eax
  call  __alloca
  call  ___main
  movl  $1, -4(%ebp)
  movl  $2, -8(%ebp)
  movl  $3, -12(%ebp)
  movl  $4, -16(%ebp)
  movl  -4(%ebp), %eax
  movl  %eax, %edx
  imull -8(%ebp), %edx
  movl  -16(%ebp), %eax
  addl  -12(%ebp), %eax
  imull %edx, %eax
  movl  %eax, -20(%ebp)
  movl  $0, %eax
  leave
  ret
  TITLE simple.c
  .386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA ENDS
CONST SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST ENDS
_BSS  SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS  ENDS
_TLS  SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS  ENDS
FLAT  GROUP _DATA, CONST, _BSS
  ASSUME  CS: FLAT, DS: FLAT, SS: FLAT
endif
PUBLIC  _main
_TEXT SEGMENT
_a$ = -4
_b$ = -8
_c$ = -12
_d$ = -16
_e$ = -20
_main PROC NEAR
  push  ebp
  mov ebp, esp
  sub esp, 20         ; 00000014H
  mov DWORD PTR _a$[ebp], 1
  mov DWORD PTR _b$[ebp], 2
  mov DWORD PTR _c$[ebp], 3
  mov DWORD PTR _d$[ebp], 4
  mov eax, DWORD PTR _a$[ebp]
  imul  eax, DWORD PTR _b$[ebp]
  mov ecx, DWORD PTR _c$[ebp]
  add ecx, DWORD PTR _d$[ebp]
  imul  eax, ecx
  mov DWORD PTR _e$[ebp], eax
  xor eax, eax
  mov esp, ebp
  pop ebp
  ret 0
_main ENDP
_TEXT ENDS
END

Compiler-generated assembly code (64-bit)

GNU (simple.s)
gcc -S simple.c
  .file "simple.c"
  .text
  .globl  main
  .type main, @function
main:
.LFB0:
  pushq %rbp
  movq  %rsp, %rbp
  movl  $1, -20(%rbp)
  movl  $2, -16(%rbp)
  movl  $3, -12(%rbp)
  movl  $4, -8(%rbp)
  movl  -20(%rbp), %eax
  imull -16(%rbp), %eax
  movl  -12(%rbp), %ecx
  movl  -8(%rbp), %edx
  addl  %ecx, %edx
  imull %edx, %eax
  movl  %eax, -4(%rbp)
  movl  $0, %eax
  popq  %rbp
  ret