#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 EXIT_SUCCESS;
int /*<<< orphan*/ change_params(int, int, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int x = 1;
  int y = 2;
  int *ptr;
  ptr = (int *)3;
  int *ptr_y;
  ptr_y = &y;
  printf("x=%d y=%d ptr_y=%p ptr=%p\n", x, y, ptr_y, ptr);
  change_params(x, y, ptr, ptr_y);
  printf("x=%d y=%d ptr_y=%p ptr=%p\n", x, y, ptr_y, ptr);
  printf("can't access the memory position that\n"
         "ptr points to. will try it now:\n");
  printf("%d\n", *ptr);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
mov    $0x3,%eax
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <change_params@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0x2,0x4(%rsp)
lea    0xebd(%rip),%r14
lea    0x4(%rsp),%rbx
mov    $0x3,%r8d
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    $0x3,%edx
mov    $0x1,%edi
mov    %rbx,%rcx
call   1040 <change_params@plt>
mov    0x4(%rsp),%edx
mov    $0x3,%r8d
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
mov    0x3,%esi
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [27 x i8] c"x=%d y=%d ptr_y=%p ptr=%p\0A\00"
@.str.1 = [71 x i8] c"can't access the memory position that\0Aptr points to. will try it now:\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 2, i32* %7
store i32* inttoptr (i64 3 to i32*), i32** %8
store i32* %7, i32** %9
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = load i32*, i32** %9
%13 = load i32*, i32** %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11, i32* %12, i32* %13)
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = load i32*, i32** %8
%18 = load i32*, i32** %9
%19 = call i32 @change_params(i32 %15, i32 %16, i32* %17, i32* %18)
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = load i32*, i32** %9
%23 = load i32*, i32** %8
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21, i32* %22, i32* %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32*, i32** %8
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @EXIT_SUCCESS
ret i32 %29
}

LLVM IR (-O2):
@.str = [27 x i8] c"x=%d y=%d ptr_y=%p ptr=%p\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [70 x i8] c"can't access the memory position that\0Aptr points to. will try it now:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 2, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 1, i32 2, i32* %3, i32* inttoptr (i64 3 to i32*))
%6 = load i32, i32* %3
%7 = call i32 @change_params(i32 1, i32 %6, i32* inttoptr (i64 3 to i32*), i32* %3)
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 1, i32 %8, i32* %3, i32* inttoptr (i64 3 to i32*))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str, i64 0, i64 0))
%11 = load i32, i32* inttoptr (i64 3 to i32*)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @EXIT_SUCCESS
ret i32 %13
}