void swap1(unsigned int *a, unsigned int *b) {
  printf("enter: a=(%0x,%d), b=(%0x,%d)\n", a, *a, b, *b);
  int temp;
  temp = *a;
  printf("nuchange a=%d,b=%d\n", *a, *b);
  *a = *b;
  printf("changed a=%d\n", *a);
  *b = temp;
  printf("changed b=%d\n", *b);
  printf("leave: a=(%0x,%d), b=(%0x,%d)\n", a, *a, b, *b);
}


x86 assembly (clang, -O0):
<swap1>:
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>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8d
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap1>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rdi),%edx
mov    (%rsi),%r8d
lea    0xeda(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%r14),%ebp
mov    (%rbx),%edx
lea    0xee0(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%esi
mov    %esi,(%r14)
lea    0xedf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,(%rbx)
lea    0xedd(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%r14),%edx
mov    (%rbx),%r8d
lea    0xed5(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <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"nuchange a=%d,b=%d\0A\00"
@.str.2 = [14 x i8] c"changed a=%d\0A\00"
@.str.3 = [14 x i8] c"changed b=%d\0A\00"
@.str.4 = [31 x i8] c"leave: a=(%0x,%d), b=(%0x,%d)\0A\00"
define void @swap1(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %3
%7 = load i32*, i32** %3
%8 = load i32, i32* %7
%9 = load i32*, i32** %4
%10 = load i32*, i32** %4
%11 = load i32, i32* %10
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32* %6, i32 %8, i32* %9, i32 %11)
%13 = load i32*, i32** %3
%14 = load i32, i32* %13
store i32 %14, i32* %5
%15 = load i32*, i32** %3
%16 = load i32, i32* %15
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %18)
%20 = load i32*, i32** %4
%21 = load i32, i32* %20
%22 = load i32*, i32** %3
store i32 %21, i32* %22
%23 = load i32*, i32** %3
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %5
%27 = load i32*, i32** %4
store i32 %26, i32* %27
%28 = load i32*, i32** %4
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load i32*, i32** %3
%32 = load i32*, i32** %3
%33 = load i32, i32* %32
%34 = load i32*, i32** %4
%35 = load i32*, i32** %4
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32* %31, i32 %33, i32* %34, i32 %36)
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"enter: a=(%0x,%d), b=(%0x,%d)\0A\00"
@.str.1 = [20 x i8] c"nuchange a=%d,b=%d\0A\00"
@.str.2 = [14 x i8] c"changed a=%d\0A\00"
@.str.3 = [14 x i8] c"changed b=%d\0A\00"
@.str.4 = [31 x i8] c"leave: a=(%0x,%d), b=(%0x,%d)\0A\00"
define void @swap1(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 = load i32, i32* %0
%7 = load i32, i32* %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7)
%9 = load i32, i32* %1
store i32 %9, i32* %0
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %9)
store i32 %6, i32* %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%12 = load i32, i32* %0
%13 = load i32, i32* %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32* %0, i32 %12, i32* %1, i32 %13)
ret void
}