int main() {
  int x = 21050;
  int y = 12;
  printf("The value of x = %d\n", x);
  printf("Address of x is %p.\n", &x);
  int *ptr;
  printf("The value of ptr = %d\n", ptr);
  printf("Address of ptr is %p.\n", &ptr);
  ptr = &x;
  printf("The value of ptr = %p\n", ptr);
  printf("Address of ptr is %p.\n", &ptr);
  printf("x = %d.\n", *ptr);
  *ptr = 3;
  printf("x = %d.\n", x);
  printf("addNumbers(x, x) = %d\n", addNumbers(x, x));
  swapNumbers(&x, &y);
  printf("x = %d\n", x);
  printf("y = %d\n", y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x523a,-0x8(%rbp)
movl   $0xc,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8c(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x8(%rbp),%esi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x0,%al
call   1030 <addNumbers@plt>
mov    %eax,%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <swapNumbers@plt>
mov    -0x8(%rbp),%esi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x523a,(%rsp)
movl   $0xc,0x4(%rsp)
lea    0xeb1(%rip),%rdi
mov    $0x523a,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebd(%rip),%rbx
lea    0x8(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,0x8(%rsp)
lea    0xeb6(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%esi
lea    0xea8(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
movl   $0x3,(%rax)
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%edi
mov    %edi,%esi
xor    %eax,%eax
call   1030 <addNumbers@plt>
lea    0xe7c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <swapNumbers@plt>
mov    (%rsp),%esi
lea    0xdef(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"The value of x = %d\0A\00"
@.str.1 = [21 x i8] c"Address of x is %p.\0A\00"
@.str.2 = [23 x i8] c"The value of ptr = %d\0A\00"
@.str.3 = [23 x i8] c"Address of ptr is %p.\0A\00"
@.str.4 = [23 x i8] c"The value of ptr = %p\0A\00"
@.str.5 = [9 x i8] c"x = %d.\0A\00"
@.str.6 = [23 x i8] c"addNumbers(x, x) = %d\0A\00"
@.str.7 = [8 x i8] c"x = %d\0A\00"
@.str.8 = [8 x i8] c"y = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
store i32 21050, i32* %2
store i32 12, i32* %3
%5 = load i32, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32*, i32** %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32** %4)
store i32* %2, i32** %4
%11 = load i32*, i32** %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32** %4)
%14 = load i32*, i32** %4
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = load i32*, i32** %4
store i32 3, i32* %17
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %2
%21 = load i32, i32* %2
%22 = call i32 (i32, i32, ...) bitcast (i32 (...)* @addNumbers to i32 (i32, i32, ...)*)(i32 %20, i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %22)
%24 = call i32 (i32*, i32*, ...) bitcast (i32 (...)* @swapNumbers to i32 (i32*, i32*, ...)*)(i32* %2, i32* %3)
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"The value of x = %d\0A\00"
@.str.1 = [21 x i8] c"Address of x is %p.\0A\00"
@.str.2 = [23 x i8] c"The value of ptr = %d\0A\00"
@.str.3 = [23 x i8] c"Address of ptr is %p.\0A\00"
@.str.4 = [23 x i8] c"The value of ptr = %p\0A\00"
@.str.5 = [9 x i8] c"x = %d.\0A\00"
@.str.6 = [23 x i8] c"addNumbers(x, x) = %d\0A\00"
@.str.7 = [8 x i8] c"x = %d\0A\00"
@.str.8 = [8 x i8] c"y = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = bitcast i32* %1 to i8*
store i32 21050, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 12, i32* %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 21050)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = bitcast i32** %3 to i8*
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32* undef)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32** %3)
store i32* %1, i32** %3
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32** %3)
%13 = load i32*, i32** %3
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %14)
%16 = load i32*, i32** %3
store i32 3, i32* %16
%17 = load i32, i32* %1
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %1
%20 = call i32 (i32, i32, ...) bitcast (i32 (...)* @addNumbers to i32 (i32, i32, ...)*)(i32 %19, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %20)
%22 = call i32 (i32*, i32*, ...) bitcast (i32 (...)* @swapNumbers to i32 (i32*, i32*, ...)*)(i32* %1, i32* %2)
%23 = load i32, i32* %1
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 %25)
ret i32 0
}