#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 /*<<< orphan*/ puts(char *);
int add_passbyreference(int *x) {
  *x = *x - *x;
  int y = *x + *x + 5;
  puts("The value of x inside passbyreference\n");
  printf("value of x is %d\n\n", *x);
  printf("value of y inside passbyreference is %d\n", y);
}


x86 assembly (clang, -O0):
<add_passbyreference>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
sub    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
add    (%rcx),%eax
add    $0x5,%eax
mov    %eax,-0x14(%rbp)
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xebe(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_passbyreference>:
push   %rbx
mov    %rdi,%rbx
movl   $0x0,(%rdi)
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%esi
lea    0xee8(%rip),%rdi
call   1040 <printf@plt>
lea    0xeef(%rip),%rdi
mov    $0x5,%esi
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"The value of x inside passbyreference\0A\00"
@.str.1 = [19 x i8] c"value of x is %d\0A\0A\00"
@.str.2 = [41 x i8] c"value of y inside passbyreference is %d\0A\00"
define i32 @add_passbyreference(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
%5 = load i32*, i32** %3
%6 = load i32, i32* %5
%7 = load i32*, i32** %3
%8 = load i32, i32* %7
%9 = sub nsw i32 %6, %8
%10 = load i32*, i32** %3
store i32 %9, i32* %10
%11 = load i32*, i32** %3
%12 = load i32, i32* %11
%13 = load i32*, i32** %3
%14 = load i32, i32* %13
%15 = add nsw i32 %12, %14
%16 = add nsw i32 %15, 5
store i32 %16, i32* %4
%17 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%18 = load i32*, i32** %3
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %4
%22 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@.str = [39 x i8] c"The value of x inside passbyreference\0A\00"
@.str.1 = [19 x i8] c"value of x is %d\0A\0A\00"
@.str.2 = [41 x i8] c"value of y inside passbyreference is %d\0A\00"
define i32 @add_passbyreference(i32* nocapture %0) {
store i32 0, i32* %0
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* %0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 5)
ret i32 undef
}