#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 main() {
  int x = 4;
  int y = 5;
  int *ptr = &x;
  char val[] = "abc";
  char *pptr;
  pptr = val;
  val[1] = val[0];
  printf("val = %s , str = %s\n", val, pptr);
  printf("ptr is x\n");
  printf("address ptr %p\n", ptr);
  printf("value   ptr %i\n", *ptr);
  printf("x       ptr %i\n", x);
  printf("y       ptr %i\n", y);
  *ptr = 99;
  printf("ptr set 99\n");
  printf("address ptr %p\n", ptr);
  printf("value   ptr %i\n", *ptr);
  printf("x       ptr %i\n", x);
  printf("y       ptr %i\n", y);
  ptr = &y;
  printf("ptr is y\n");
  printf("address ptr %p\n", ptr);
  printf("value   ptr %i\n", *ptr);
  printf("x       ptr %i\n", x);
  printf("y       ptr %i\n", y);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x4,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0xecc(%rip),%eax
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%al
mov    %al,-0x13(%rbp)
lea    -0x14(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movl   $0x63,(%rax)
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x4,0x4(%rsp)
movl   $0x5,0x8(%rsp)
movl   $0x636161,0xc(%rsp)
lea    0xeb4(%rip),%rdi
lea    0xc(%rsp),%rdx
mov    %rdx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0xea7(%rip),%r14
lea    0x4(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xe9a(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xe95(%rip),%r13
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe94(%rip),%r12
mov    %r12,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x63,0x4(%rsp)
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe56(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.val = [4 x i8] c"abc\00"
@.str = [21 x i8] c"val = %s , str = %s\0A\00"
@.str.1 = [10 x i8] c"ptr is x\0A\00"
@.str.2 = [16 x i8] c"address ptr %p\0A\00"
@.str.3 = [16 x i8] c"value ptr %i\0A\00"
@.str.4 = [16 x i8] c"x ptr %i\0A\00"
@.str.5 = [16 x i8] c"y ptr %i\0A\00"
@.str.6 = [12 x i8] c"ptr set 99\0A\00"
@.str.7 = [10 x i8] c"ptr is y\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [4 x i8]
%5 = alloca i8*
store i32 4, i32* %1
store i32 5, i32* %2
store i32* %1, i32** %3
%6 = bitcast [4 x i8]* %4 to i8*
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
store i8* %7, i8** %5
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%9 = load i8, i8* %8
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
store i8 %9, i8* %10
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%12 = load i8*, i8** %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32*, i32** %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32* %15)
%17 = load i32*, i32** %3
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = load i32*, i32** %3
store i32 99, i32* %24
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%26 = load i32*, i32** %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32* %26)
%28 = load i32*, i32** %3
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %1
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %2
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %33)
store i32* %2, i32** %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%36 = load i32*, i32** %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32* %36)
%38 = load i32*, i32** %3
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %1
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %2
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %43)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"val = %s , str = %s\0A\00"
@.str.2 = [16 x i8] c"address ptr %p\0A\00"
@.str.3 = [16 x i8] c"value ptr %i\0A\00"
@.str.4 = [16 x i8] c"x ptr %i\0A\00"
@.str.5 = [16 x i8] c"y ptr %i\0A\00"
@str = [9 x i8] c"ptr is x\00"
@str.8 = [11 x i8] c"ptr set 99\00"
@str.9 = [9 x i8] c"ptr is y\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
store i32 4, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 5, i32* %2
%6 = bitcast i32* %3 to i8*
store i32 6512993, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %3)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 5)
store i32 99, i32* %1
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%17 = load i32, i32* %1
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %1
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 5)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %1
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %28)
ret i32 0
}