#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, int *);
void swap(int *a, int *b) {
  printf("entering this, it is %d (%p) %d (%p)\n", *a, a, *b, b);
  int temp = *a;
  *a = *b;
  *b = temp;
  printf("exiting this, it is %d (%p) %d (%p)\n", *a, a, *b, b);
}


x86 assembly (clang, -O0):
<swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%r8
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%r8
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%esi
mov    (%r14),%ecx
lea    0xeda(%rip),%rdi
mov    %rbx,%rdx
mov    %r14,%r8
call   1030 <printf@plt>
mov    (%rbx),%ecx
mov    (%r14),%eax
mov    %eax,(%rbx)
mov    %ecx,(%r14)
mov    (%rbx),%esi
lea    0xee2(%rip),%rdi
mov    %rbx,%rdx
mov    %r14,%r8
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"entering this, it is %d (%p) %d (%p)\0A\00"
@.str.1 = [37 x i8] c"exiting this, it is %d (%p) %d (%p)\0A\00"
define void @swap(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %3
%7 = load i32, i32* %6
%8 = load i32*, i32** %3
%9 = load i32*, i32** %4
%10 = load i32, i32* %9
%11 = load i32*, i32** %4
%12 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %7, i32* %8, i32 %10, i32* %11)
%13 = load i32*, i32** %3
%14 = load i32, i32* %13
store i32 %14, i32* %5
%15 = load i32*, i32** %4
%16 = load i32, i32* %15
%17 = load i32*, i32** %3
store i32 %16, i32* %17
%18 = load i32, i32* %5
%19 = load i32*, i32** %4
store i32 %18, i32* %19
%20 = load i32*, i32** %3
%21 = load i32, i32* %20
%22 = load i32*, i32** %3
%23 = load i32*, i32** %4
%24 = load i32, i32* %23
%25 = load i32*, i32** %4
%26 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32* %22, i32 %24, i32* %25)
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"entering this, it is %d (%p) %d (%p)\0A\00"
@.str.1 = [37 x i8] c"exiting this, it is %d (%p) %d (%p)\0A\00"
define void @swap(i32* %0, i32* %1) {
%3 = load i32, i32* %0
%4 = load i32, i32* %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %3, i32* %0, i32 %4, i32* %1)
%6 = load i32, i32* %0
%7 = load i32, i32* %1
store i32 %7, i32* %0
store i32 %6, i32* %1
%8 = load i32, i32* %0
%9 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32* %0, i32 %6, i32* %1)
ret void
}