#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ swap1(int, int);
int /*<<< orphan*/ swap2(int *, int *);
int /*<<< orphan*/ swap3(int, int);
int main() {
  int a = 1, b = 2;
  swap1(a, b);
  printf("swap1(a,b) %d, %d\n", a, b);
  a = 1, b = 2;
  swap2(&a, &b);
  printf("swap2(&a,&b) %d, %d\n", a, b);
  a = 1, b = 2;
  swap3(a, b);
  printf("swap3(a,b) %d, %d\n", a, b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <swap1@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <swap2@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <swap3@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1,%edi
mov    $0x2,%esi
call   1050 <swap1@plt>
lea    0xea9(%rip),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <printf@plt>
movl   $0x1,0x4(%rsp)
movl   $0x2,(%rsp)
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1060 <swap2@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,0x4(%rsp)
movl   $0x2,(%rsp)
mov    $0x1,%edi
mov    $0x2,%esi
call   1040 <swap3@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"swap1(a,b) %d, %d\0A\00"
@.str.1 = [21 x i8] c"swap2(&a,&b) %d, %d\0A\00"
@.str.2 = [19 x i8] c"swap3(a,b) %d, %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 2, i32* %3
%4 = load i32, i32* %2
%5 = load i32, i32* %3
%6 = call i32 @swap1(i32 %4, i32 %5)
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
store i32 1, i32* %2
store i32 2, i32* %3
%10 = call i32 @swap2(i32* %2, i32* %3)
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
store i32 1, i32* %2
store i32 2, i32* %3
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call i32 @swap3(i32 %14, i32 %15)
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"swap1(a,b) %d, %d\0A\00"
@.str.1 = [21 x i8] c"swap2(&a,&b) %d, %d\0A\00"
@.str.2 = [19 x i8] c"swap3(a,b) %d, %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @swap1(i32 1, i32 2)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 1, i32 2)
store i32 1, i32* %1
store i32 2, i32* %2
%7 = call i32 @swap2(i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %9)
store i32 1, i32* %1
store i32 2, i32* %2
%11 = call i32 @swap3(i32 1, i32 2)
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %13)
ret i32 0
}