#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);
void swap_p(int *a, int *b) {
  int temp = 0;
  printf("in func before swap *a = %d; *b = %d;\n", *a, *b);
  temp = *a;
  *a = *b;
  *b = temp;
  printf("in func after swap *a = %d; *b = %d;\n", *a, *b);
}


x86 assembly (clang, -O0):
<swap_p>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xec6(%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    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
@.str = [39 x i8] c"in func before swap *a = %d; *b = %d;\0A\00"
@.str.1 = [38 x i8] c"in func after swap *a = %d; *b = %d;\0A\00"
define void @swap_p(i32* nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* %0
%4 = load i32, i32* %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
%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 ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %6)
ret void
}