# code from compiler, with some comments by Lin .file "swap.c" .text .globl swap .type swap, @function swap: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 movq %rdi, -24(%rbp) #saving args on stack (x and y) %rdi = x movq %rsi, -32(%rbp) # %rsi = y movq -24(%rbp), %rax # getting them right back movl (%rax), %eax # doing the *x movl %eax, -4(%rbp) # temp = *x movq -32(%rbp), %rax movl (%rax), %edx # %edx = *y movq -24(%rbp), %rax movl %edx, (%rax) # *x = %edx movq -32(%rbp), %rax movl -4(%rbp), %edx movl %edx, (%rax) # *x = temp - Ain't that crazy? popq %rbp # clean up stack .cfi_def_cfa 7, 8 ret # what about the %rsp stack pointer?? .cfi_endproc .LFE0: .size swap, .-swap .ident "GCC: (GNU) 4.8.3 20140911 (Red Hat 4.8.3-7)" .section .note.GNU-stack,"",@progbits