#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, ...);
void real_swap(int *a, int *b) {
  printf("swapping %d (%p) and %d (%p)\n", *a, a, *b, b);
  int temp = *b;
  *b = *a;
  *a = temp;
  printf("swapped to %d %d\n", *a, *b);
}


x86 assembly (clang, -O0):
<real_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
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [30 x i8] c"swapping %d (%p) and %d (%p)\0A\00"
@.str.1 = [18 x i8] c"swapped to %d %d\0A\00"
define void @real_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 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %7, i32* %8, i32 %10, i32* %11)
%13 = load i32*, i32** %4
%14 = load i32, i32* %13
store i32 %14, i32* %5
%15 = load i32*, i32** %3
%16 = load i32, i32* %15
%17 = load i32*, i32** %4
store i32 %16, i32* %17
%18 = load i32, i32* %5
%19 = load i32*, i32** %3
store i32 %18, i32* %19
%20 = load i32*, i32** %3
%21 = load i32, i32* %20
%22 = load i32*, i32** %4
%23 = load i32, i32* %22
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %23)
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"swapping %d (%p) and %d (%p)\0A\00"
@.str.1 = [18 x i8] c"swapped to %d %d\0A\00"
define void @real_swap(i32* %0, i32* %1) {
%3 = load i32, i32* %0
%4 = load i32, i32* %1
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %3, i32* %0, i32 %4, i32* %1)
%6 = load i32, i32* %1
%7 = load i32, i32* %0
store i32 %7, i32* %1
store i32 %6, i32* %0
%8 = load i32, i32* %1
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %8)
ret void
}