Example 1 ========= int example_1 (int x, int y) { return x+y; } 0x80483e4 : push %ebp 0x80483e5 : mov %esp,%ebp 0x80483e7 : mov 0xc(%ebp),%eax 0x80483ea : add 0x8(%ebp),%eax 0x80483ed : mov %ebp,%esp 0x80483ef : pop %ebp 0x80483f0 : ret Example 2 ========= int fib(int n) { int result; if(n <= 2) result = 1; else result = fib(n-2) + fib(n-1); return result; } 0x8048420 : push %ebp 0x8048421 : mov %esp,%ebp 0x8048423 : sub $0x10,%esp 0x8048426 : push %esi 0x8048427 : push %ebx 0x8048428 : mov 0x8(%ebp),%ebx 0x804842b : cmp $0x2,%ebx 0x804842e : jg 0x8048437 0x8048430 : mov $0x1,%eax 0x8048435 : jmp 0x8048453 0x8048437 : add $0xfffffff4,%esp 0x804843a : lea 0xfffffffe(%ebx),%eax 0x804843d : push %eax 0x804843e : call 0x8048420 0x8048443 : mov %eax,%esi 0x8048445 : add $0xfffffff4,%esp 0x8048448 : lea 0xffffffff(%ebx),%eax 0x804844b : push %eax 0x804844c : call 0x8048420 0x8048451 : add %esi,%eax 0x8048453 : lea 0xffffffe8(%ebp),%esp 0x8048456 : pop %ebx 0x8048457 : pop %esi 0x8048458 : mov %ebp,%esp 0x804845a : pop %ebp 0x804845b : ret Example 3 ========= int sum_array(int x[], int num) { int i, sum; sum = 0; for(i = 0; i < num; i++) sum += x[i]; return sum; } 0x80483f0 : push %ebp 0x80483f1 : mov %esp,%ebp 0x80483f3 : push %ebx 0x80483f4 : mov 0x8(%ebp),%ebx # x 0x80483f7 : mov 0xc(%ebp),%ecx # num 0x80483fa : xor %eax,%eax # sum 0x80483fc : xor %edx,%edx # i 0x80483fe : cmp %ecx,%eax # num <= 0 0x8048400 : jge 0x804840a 0x8048402 : add (%ebx,%edx,4),%eax # sum += x[i] 0x8048405 : inc %edx # i++ 0x8048406 : cmp %ecx,%edx # i < num 0x8048408 : jl 0x8048402 0x804840a : pop %ebx 0x804840b : mov %ebp,%esp 0x804840d : pop %ebp 0x804840e : ret Example 4 ========= typedef struct linked_list { struct linked_list *next; int data; } linked_list; linked_list a_list[5]; void init_a_list() { int i; for(i = 0; i < 4; i++) { a_list[i].next = &(a_list[i+1]); a_list[i].data = i+1; } a_list[4].next = NULL; a_list[4].data = 5; } int sum_linked_list(linked_list *head) { int sum; sum = 0; while(head != NULL) { sum += head->data; head = head->next; } return sum; } Dump of assembler code for function sum_linked_list: 0x8048434 : push %ebp 0x8048435 : mov %esp,%ebp 0x8048437 : mov 0x8(%ebp),%edx # head 0x804843a : xor %eax,%eax # sum = 0 0x804843c : test %edx,%edx # head = NULL 0x804843e : je 0x8048449 0x8048440 : add 0x4(%edx),%eax # sum += head->data 0x8048443 : mov (%edx),%edx # head = head->next 0x8048445 : test %edx,%edx # head = NULL 0x8048447 : jne 0x8048440 0x8048449 : mov %ebp,%esp 0x804844b : pop %ebp 0x804844c : ret