#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, char *argv[]) {
  char user_input[100];
  int *secret;
  int int_input;
  int a = 1, b = 2, c = 3, d = 4;
  printf("sizeof(int *): %d\n", sizeof(int *));
  printf("userinput 0x%lx\n", user_input);
  printf("secret 0x%lx\n", &secret);
  printf("int_input 0x%lx\n", &int_input);
  printf("a 0x%lx\n", &a);
  printf("b 0x%lx\n", &b);
  printf("c 0x%lx\n", &c);
  printf("d 0x%lx\n", &d);
  secret = (int *)malloc(2 * sizeof(int));
  secret[0] = 0x44;
  secret[1] = 0x55;
  printf("The variable secret's address is 0x%8x (on stack)\n",
         (unsigned int)&secret);
  printf("The variable secret's value is 0x%8x (on heap)\n",
         (unsigned int)secret);
  printf("secret[0]'s address is 0x%016lx (on heap)\n",
         (unsigned int)&secret[0]);
  printf("secret[1]'s address is 0x%016lx (on heap)\n",
         (unsigned int)&secret[1]);
  printf("Please enter a decimal integer\n");
  scanf("%d", &int_input);
  printf("Please enter a string\n");
  scanf("%s", user_input);
  printf(user_input);
  printf("\n");
  printf("The original secrets: 0x%x -- 0x%x\n", 0x44, 0x55);
  printf("The new secrets:      0x%x -- 0x%x\n", secret[0], secret[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x90(%rbp)
movl   $0x2,-0x94(%rbp)
movl   $0x3,-0x98(%rbp)
movl   $0x4,-0x9c(%rbp)
lea    0xe88(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
lea    -0x88(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
lea    -0x8c(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe70(%rip),%rdi
lea    -0x94(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe64(%rip),%rdi
lea    -0x98(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe58(%rip),%rdi
lea    -0x9c(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
movl   $0x44,(%rax)
mov    -0x88(%rbp),%rax
movl   $0x55,0x4(%rax)
lea    -0x88(%rbp),%rax
mov    %eax,%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x88(%rbp),%rax
mov    %eax,%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x88(%rbp),%rax
mov    %eax,%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x88(%rbp),%rax
add    $0x4,%rax
mov    %eax,%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8b(%rip),%rdi
lea    -0x8c(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x80(%rbp),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
mov    $0x44,%esi
mov    $0x55,%edx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x88(%rbp),%rax
mov    (%rax),%esi
mov    -0x88(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
movl   $0x1,0x18(%rsp)
movl   $0x2,0x14(%rsp)
movl   $0x3,0x10(%rsp)
movl   $0x4,0xc(%rsp)
lea    0xe7d(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe7d(%rip),%rdi
lea    0x20(%rsp),%r15
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe78(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe72(%rip),%rdi
lea    0x1c(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe6d(%rip),%rdi
lea    0x18(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe63(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe59(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe4f(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,(%rsp)
movabs $0x5500000044,%rcx
mov    %rcx,(%rax)
lea    0xe2a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%esi
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%esi
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%esi
add    $0x4,%esi
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeeb(%rip),%rdi
call   1040 <puts@plt>
lea    0xe91(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xeed(%rip),%rdi
call   1040 <puts@plt>
lea    0xe77(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe55(%rip),%rdi
mov    $0x44,%esi
mov    $0x55,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rax
mov    (%rax),%esi
mov    0x4(%rax),%edx
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"sizeof(int *): %d\0A\00"
@.str.1 = [17 x i8] c"userinput 0x%lx\0A\00"
@.str.2 = [14 x i8] c"secret 0x%lx\0A\00"
@.str.3 = [17 x i8] c"int_input 0x%lx\0A\00"
@.str.4 = [9 x i8] c"a 0x%lx\0A\00"
@.str.5 = [9 x i8] c"b 0x%lx\0A\00"
@.str.6 = [9 x i8] c"c 0x%lx\0A\00"
@.str.7 = [9 x i8] c"d 0x%lx\0A\00"
@.str.8 = [51 x i8] c"The variable secret's address is 0x%8x (on stack)\0A\00"
@.str.9 = [48 x i8] c"The variable secret's value is 0x%8x (on heap)\0A\00"
@.str.10 = [43 x i8] c"secret[0]'s address is 0x%016lx (on heap)\0A\00"
@.str.11 = [43 x i8] c"secret[1]'s address is 0x%016lx (on heap)\0A\00"
@.str.12 = [32 x i8] c"Please enter a decimal integer\0A\00"
@.str.13 = [3 x i8] c"%d\00"
@.str.14 = [23 x i8] c"Please enter a string\0A\00"
@.str.15 = [3 x i8] c"%s\00"
@.str.16 = [2 x i8] c"\0A\00"
@.str.17 = [36 x i8] c"The original secrets: 0x%x -- 0x%x\0A\00"
@.str.18 = [36 x i8] c"The new secrets: 0x%x -- 0x%x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %9
store i32 2, i32* %10
store i32 3, i32* %11
store i32 4, i32* %12
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 8)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32** %7)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %9)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32* %10)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32* %11)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32* %12)
%22 = call i64 @malloc(i32 8)
%23 = inttoptr i64 %22 to i32*
store i32* %23, i32** %7
%24 = load i32*, i32** %7
%25 = getelementptr inbounds i32, i32* %24, i64 0
store i32 68, i32* %25
%26 = load i32*, i32** %7
%27 = getelementptr inbounds i32, i32* %26, i64 1
store i32 85, i32* %27
%28 = ptrtoint i32** %7 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.8, i64 0, i64 0), i32 %28)
%30 = load i32*, i32** %7
%31 = ptrtoint i32* %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0), i32 %31)
%33 = load i32*, i32** %7
%34 = getelementptr inbounds i32, i32* %33, i64 0
%35 = ptrtoint i32* %34 to i32
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0), i32 %35)
%37 = load i32*, i32** %7
%38 = getelementptr inbounds i32, i32* %37, i64 1
%39 = ptrtoint i32* %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.11, i64 0, i64 0), i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0))
%42 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i32* %8)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0))
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.17, i64 0, i64 0), i32 68, i32 85)
%50 = load i32*, i32** %7
%51 = getelementptr inbounds i32, i32* %50, i64 0
%52 = load i32, i32* %51
%53 = load i32*, i32** %7
%54 = getelementptr inbounds i32, i32* %53, i64 1
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0), i32 %52, i32 %55)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"sizeof(int *): %d\0A\00"
@.str.1 = [17 x i8] c"userinput 0x%lx\0A\00"
@.str.2 = [14 x i8] c"secret 0x%lx\0A\00"
@.str.3 = [17 x i8] c"int_input 0x%lx\0A\00"
@.str.4 = [9 x i8] c"a 0x%lx\0A\00"
@.str.5 = [9 x i8] c"b 0x%lx\0A\00"
@.str.6 = [9 x i8] c"c 0x%lx\0A\00"
@.str.7 = [9 x i8] c"d 0x%lx\0A\00"
@.str.8 = [51 x i8] c"The variable secret's address is 0x%8x (on stack)\0A\00"
@.str.9 = [48 x i8] c"The variable secret's value is 0x%8x (on heap)\0A\00"
@.str.10 = [43 x i8] c"secret[0]'s address is 0x%016lx (on heap)\0A\00"
@.str.11 = [43 x i8] c"secret[1]'s address is 0x%016lx (on heap)\0A\00"
@.str.13 = [3 x i8] c"%d\00"
@.str.15 = [3 x i8] c"%s\00"
@.str.17 = [36 x i8] c"The original secrets: 0x%x -- 0x%x\0A\00"
@.str.18 = [36 x i8] c"The new secrets: 0x%x -- 0x%x\0A\00"
@str = [31 x i8] c"Please enter a decimal integer\00"
@str.19 = [22 x i8] c"Please enter a string\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%11 = bitcast i32** %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
store i32 1, i32* %6
%14 = bitcast i32* %7 to i8*
store i32 2, i32* %7
%15 = bitcast i32* %8 to i8*
store i32 3, i32* %8
%16 = bitcast i32* %9 to i8*
store i32 4, i32* %9
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 8)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32** %4)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32* %7)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32* %8)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32* %9)
%25 = call i64 @malloc(i32 8)
%26 = inttoptr i64 %25 to i32*
store i32* %26, i32** %4
store i32 68, i32* %26
%27 = getelementptr inbounds i32, i32* %26, i64 1
store i32 85, i32* %27
%28 = ptrtoint i32** %4 to i64
%29 = trunc i64 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.8, i64 0, i64 0), i32 %29)
%31 = load i32*, i32** %4
%32 = ptrtoint i32* %31 to i64
%33 = trunc i64 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0), i32 %33)
%35 = load i32*, i32** %4
%36 = ptrtoint i32* %35 to i64
%37 = trunc i64 %36 to i32
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0), i32 %37)
%39 = load i32*, i32** %4
%40 = getelementptr inbounds i32, i32* %39, i64 1
%41 = ptrtoint i32* %40 to i64
%42 = trunc i64 %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.11, i64 0, i64 0), i32 %42)
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i32* %5)
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.19, i64 0, i64 0))
%47 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8* %10)
%48 = call i32 (i8*, ...) @printf(i8* %10)
%49 = call i32 @putchar(i32 10)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.17, i64 0, i64 0), i32 68, i32 85)
%51 = load i32*, i32** %4
%52 = load i32, i32* %51
%53 = getelementptr inbounds i32, i32* %51, i64 1
%54 = load i32, i32* %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0), i32 %52, i32 %54)
ret i32 0
}