void swap(unsigned int *a, unsigned int *b) {
  printf("enter: a=(%0x,%d), b=(%0x,%d)\n", a, *a, b, *b);
  int *temp;
  int aa, bb;
  printf("step 1. backup a,b\n");
  aa = *a;
  bb = *b;
  temp = a;
  a = b;
  b = temp;
  *a = aa;
  *b = bb;
  printf("leave: a=(%0x,%d), b=(%0x,%d)\n", a, *a, b, *b);
}


x86 assembly (clang, -O0):
<swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8d
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8d
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rdi),%edx
mov    (%rsi),%r8d
lea    0xeca(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%eax
mov    (%rbx),%r8d
mov    %eax,(%rbx)
mov    %r8d,(%r14)
mov    (%rbx),%edx
lea    0xebc(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rcx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"enter: a=(%0x,%d), b=(%0x,%d)\0A\00"
@.str.1 = [20 x i8] c"step 1. backup a,b\0A\00"
@.str.2 = [31 x i8] c"leave: a=(%0x,%d), b=(%0x,%d)\0A\00"
define void @swap(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%8 = load i32*, i32** %3
%9 = load i32*, i32** %3
%10 = load i32, i32* %9
%11 = load i32*, i32** %4
%12 = load i32*, i32** %4
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32* %8, i32 %10, i32* %11, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32*, i32** %3
%17 = load i32, i32* %16
store i32 %17, i32* %6
%18 = load i32*, i32** %4
%19 = load i32, i32* %18
store i32 %19, i32* %7
%20 = load i32*, i32** %3
store i32* %20, i32** %5
%21 = load i32*, i32** %4
store i32* %21, i32** %3
%22 = load i32*, i32** %5
store i32* %22, i32** %4
%23 = load i32, i32* %6
%24 = load i32*, i32** %3
store i32 %23, i32* %24
%25 = load i32, i32* %7
%26 = load i32*, i32** %4
store i32 %25, i32* %26
%27 = load i32*, i32** %3
%28 = load i32*, i32** %3
%29 = load i32, i32* %28
%30 = load i32*, i32** %4
%31 = load i32*, i32** %4
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32* %27, i32 %29, i32* %30, i32 %32)
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"enter: a=(%0x,%d), b=(%0x,%d)\0A\00"
@.str.2 = [31 x i8] c"leave: a=(%0x,%d), b=(%0x,%d)\0A\00"
@str = [19 x i8] c"step 1. backup a,b\00"
define void @swap(i32* %0, i32* %1) {
%3 = load i32, i32* %0
%4 = load i32, i32* %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32* %0, i32 %3, i32* %1, i32 %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%7 = load i32, i32* %0
%8 = load i32, i32* %1
store i32 %7, i32* %1
store i32 %8, i32* %0
%9 = load i32, i32* %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32 %9, i32* %0, i32 %8)
ret void
}