#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*/ exch(int *, int *);
int /*<<< orphan*/ exch2(int *, int *);
int /*<<< orphan*/ exch3(int *, int *);
int /*<<< orphan*/ exch4(int *, int *);
int /*<<< orphan*/ exch5(int *, int *);
int /*<<< orphan*/ printf(char *, ...);
void main(void) {
  int x = 10, y = 20;
  printf("x=%d,y=%d.\n", x, y);
  exch(&x, &y);
  printf("After swap...\n");
  printf("x=%d,y=%d.\n", x, y);
  exch2(&x, &y);
  printf("x=%d,y=%d.\n", x, y);
  exch3(&x, &y);
  printf("x=%d,y=%d.\n", x, y);
  exch4(&x, &y);
  printf("x=%d,y=%d.\n", x, y);
  exch5(&x, &y);
  printf("x=%d,y=%d.\n", x, y);
  {
    int temp = x;
    x = y;
    y = temp;
  };
  printf("x=%d,y=%d.\n", x, y);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xa,-0x4(%rbp)
movl   $0x14,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <exch@plt>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <exch2@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <exch3@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <exch4@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1030 <exch5@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0xa,0xc(%rsp)
movl   $0x14,0x8(%rsp)
lea    0xe70(%rip),%r14
mov    %r14,%rdi
mov    $0xa,%esi
mov    $0x14,%edx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc(%rsp),%rbx
lea    0x8(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <exch@plt>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <exch2@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <exch3@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <exch4@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <exch5@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%esi
mov    %esi,0xc(%rsp)
mov    %edx,0x8(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"x=%d,y=%d.\0A\00"
@.str.1 = [15 x i8] c"After swap...\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 10, i32* %1
store i32 20, i32* %2
%4 = load i32, i32* %1
%5 = load i32, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
%7 = call i32 @exch(i32* %1, i32* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = call i32 @exch2(i32* %1, i32* %2)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
%16 = call i32 @exch3(i32* %1, i32* %2)
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
%20 = call i32 @exch4(i32* %1, i32* %2)
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22)
%24 = call i32 @exch5(i32* %1, i32* %2)
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %26)
%28 = load i32, i32* %1
store i32 %28, i32* %3
%29 = load i32, i32* %2
store i32 %29, i32* %1
%30 = load i32, i32* %3
store i32 %30, i32* %2
%31 = load i32, i32* %1
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %31, i32 %32)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"x=%d,y=%d.\0A\00"
@str = [14 x i8] c"After swap...\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 10, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 20, i32* %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 10, i32 20)
%6 = call i32 @exch(i32* %1, i32* %2)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = call i32 @exch2(i32* %1, i32* %2)
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
%15 = call i32 @exch3(i32* %1, i32* %2)
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17)
%19 = call i32 @exch4(i32* %1, i32* %2)
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21)
%23 = call i32 @exch5(i32* %1, i32* %2)
%24 = load i32, i32* %1
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25)
%27 = load i32, i32* %1
%28 = load i32, i32* %2
store i32 %28, i32* %1
store i32 %27, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %28, i32 %27)
ret void
}