#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 modify_x(int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int y = 0, x = 4;
  int *p = &x;
  int modify(), modify_x();
  printf("y and x unmodified y = %d x = %d\n\n", y, x);
  y = modify(p);
  printf("on use of modify() (y = x + 4)");
  printf("  y = %d  x = %d\n", y, x);
  y = modify_x(p);
  printf("\non use of modify_x() (x is changed to 2: y = x / 2) ");
  printf("y = %d x = %d\n", y, x);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <modify@plt>
mov    %eax,-0x4(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <modify_x@plt>
mov    %eax,-0x4(%rbp)
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
movl   $0x4,0x4(%rsp)
lea    0xebe(%rip),%rdi
xor    %esi,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <modify@plt>
mov    %eax,%ebp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
lea    0xec8(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <modify_x@plt>
mov    %eax,%ebx
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
lea    0xee4(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"y and x unmodified y = %d x = %d\0A\0A\00"
@.str.1 = [31 x i8] c"on use of modify() (y = x + 4)\00"
@.str.2 = [18 x i8] c" y = %d x = %d\0A\00"
@.str.3 = [54 x i8] c"\0Aon use of modify_x() (x is changed to 2: y = x / 2) \00"
@.str.4 = [15 x i8] c"y = %d x = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
store i32 4, i32* %2
store i32* %2, i32** %3
%4 = load i32, i32* %1
%5 = load i32, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
%7 = load i32*, i32** %3
%8 = call i32 (i32*, ...) bitcast (i32 (...)* @modify to i32 (i32*, ...)*)(i32* %7)
store i32 %8, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %11)
%13 = load i32*, i32** %3
%14 = call i32 @modify_x(i32* %13)
store i32 %14, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %16, i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"y and x unmodified y = %d x = %d\0A\0A\00"
@.str.1 = [31 x i8] c"on use of modify() (y = x + 4)\00"
@.str.2 = [18 x i8] c" y = %d x = %d\0A\00"
@.str.3 = [54 x i8] c"\0Aon use of modify_x() (x is changed to 2: y = x / 2) \00"
@.str.4 = [15 x i8] c"y = %d x = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 4, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 0, i32 4)
%4 = call i32 (i32*, ...) bitcast (i32 (...)* @modify to i32 (i32*, ...)*)(i32* %1)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %6)
%8 = call i32 @modify_x(i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %8, i32 %10)
ret i32 0
}