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_value() : num1 = %d, num2 = %d\n\n",
      __func__, num1, num2);
  swap_call_by_value(num1, num2);
  printf("[%s] : after calling swap_call_by_value() : 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>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x0,%al
call   1040 <swap_call_by_value@plt>
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xedf(%rip),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x3,0xc(%rsp)
movl   $0x5,0x8(%rsp)
lea    0xec4(%rip),%rdi
lea    0xee9(%rip),%rbx
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xecb(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1040 <swap_call_by_value@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xee7(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
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 = [68 x i8] c"[%s] : before calling swap_call_by_value() : num1 = %d, num2 = %d\0A\0A\00"
@.str.2 = [66 x i8] c"[%s] : after calling swap_call_by_value() : 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 ([68 x i8], [68 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 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = call i32 (i32, i32, ...) bitcast (i32 (...)* @swap_call_by_value to i32 (i32, i32, ...)*)(i32 %12, i32 %13)
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__func__.main, i64 0, i64 0), i32 %15, i32 %16)
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 = [68 x i8] c"[%s] : before calling swap_call_by_value() : num1 = %d, num2 = %d\0A\0A\00"
@.str.2 = [66 x i8] c"[%s] : after calling swap_call_by_value() : 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 ([68 x i8], [68 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 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = call i32 (i32, i32, ...) bitcast (i32 (...)* @swap_call_by_value to i32 (i32, i32, ...)*)(i32 %11, i32 %12)
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__func__.main, i64 0, i64 0), i32 %14, i32 %15)
ret i32 0
}