#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*/ swap_my(int *, int *);
void main() {
  int a = 5;
  int b = 6;
  int z = 2;
  int *c;
  int *d;
  c = &a;
  d = &b;
  printf("before swap c = %d, and d = %d;\n", *c, *d);
  printf("before swap a = %d, and b = %d;\n\n", a, b);
  swap_my(c, d);
  printf("after swap c = %d, and d = %d;\n", *c, *d);
  printf("after swap a = %d, and b = %d;\n\n", a, b);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x5,-0x4(%rbp)
movl   $0x6,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <swap_my@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x5,0x4(%rsp)
movl   $0x6,(%rsp)
lea    0xec9(%rip),%rdi
mov    $0x5,%esi
mov    $0x6,%edx
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x5,%esi
mov    $0x6,%edx
call   1030 <printf@plt>
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <swap_my@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xed9(%rip),%rdi
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [33 x i8] c"before swap c = %d, and d = %d;\0A\00"
@.str.1 = [34 x i8] c"before swap a = %d, and b = %d;\0A\0A\00"
@.str.2 = [32 x i8] c"after swap c = %d, and d = %d;\0A\00"
@.str.3 = [33 x i8] c"after swap a = %d, and b = %d;\0A\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
store i32 5, i32* %1
store i32 6, i32* %2
store i32 2, i32* %3
store i32* %1, i32** %4
store i32* %2, i32** %5
%6 = load i32*, i32** %4
%7 = load i32, i32* %6
%8 = load i32*, i32** %5
%9 = load i32, i32* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i32*, i32** %4
%15 = load i32*, i32** %5
%16 = call i32 @swap_my(i32* %14, i32* %15)
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = load i32*, i32** %5
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %20)
%22 = load i32, i32* %1
%23 = load i32, i32* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %23)
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"before swap c = %d, and d = %d;\0A\00"
@.str.1 = [34 x i8] c"before swap a = %d, and b = %d;\0A\0A\00"
@.str.2 = [32 x i8] c"after swap c = %d, and d = %d;\0A\00"
@.str.3 = [33 x i8] c"after swap a = %d, and b = %d;\0A\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 5, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 6, i32* %2
%5 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 5, i32 6)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 6)
%7 = call i32 @swap_my(i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32 %12)
ret void
}