int main(int argc, char *argv[]) {
  int num1 = 3;
  int num2 = 5;
  printf("[%s] : addresses : &num1 = %p, &num2 = %p\n\n", __func__, &num1,
         &num2);
  printf(
      "[%s] : before calling swap_call_by_reference() : num1 = %d, num2 = %d\n",
      __func__, num1, num2);
  swap_call_by_reference(&num1, &num2);
  printf(
      "[%s] : after calling swap_call_by_reference() : num1 = %d, num2 = %d\n",
      __func__, num1, num2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
movl   $0x5,-0x18(%rbp)
lea    0xeb5(%rip),%rdi
lea    0xeda(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xec3(%rip),%rdi
lea    0xeb7(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <swap_call_by_reference@plt>
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xee0(%rip),%rdi
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1030 <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   $0x3,0xc(%rsp)
movl   $0x5,0x8(%rsp)
lea    0xec0(%rip),%rdi
lea    0xee5(%rip),%rbx
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xec1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <swap_call_by_reference@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xee2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"[%s] : addresses : &num1 = %p, &num2 = %p\0A\0A\00"
@__func__.main = [5 x i8] c"main\00"
@.str.1 = [71 x i8] c"[%s] : before calling swap_call_by_reference() : num1 = %d, num2 = %d\0A\00"
@.str.2 = [70 x i8] c"[%s] : after calling swap_call_by_reference() : num1 = %d, num2 = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %6
store i32 5, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__func__.main, i64 0, i64 0), i32* %6, i32* %7)
%9 = load i32, i32* %6
%10 = load i32, i32* %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__func__.main, i64 0, i64 0), i32 %9, i32 %10)
%12 = call i32 (i32*, i32*, ...) bitcast (i32 (...)* @swap_call_by_reference to i32 (i32*, i32*, ...)*)(i32* %6, i32* %7)
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__func__.main, i64 0, i64 0), i32 %13, i32 %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"[%s] : addresses : &num1 = %p, &num2 = %p\0A\0A\00"
@__func__.main = [5 x i8] c"main\00"
@.str.1 = [71 x i8] c"[%s] : before calling swap_call_by_reference() : num1 = %d, num2 = %d\0A\00"
@.str.2 = [70 x i8] c"[%s] : after calling swap_call_by_reference() : num1 = %d, num2 = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
store i32 3, i32* %3
%6 = bitcast i32* %4 to i8*
store i32 5, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__func__.main, i64 0, i64 0), i32* %3, i32* %4)
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__func__.main, i64 0, i64 0), i32 %8, i32 %9)
%11 = call i32 (i32*, i32*, ...) bitcast (i32 (...)* @swap_call_by_reference to i32 (i32*, i32*, ...)*)(i32* %3, i32* %4)
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__func__.main, i64 0, i64 0), i32 %12, i32 %13)
ret i32 0
}