#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*/ free(int *);
int function1(int *);
int /*<<< orphan*/ getchar();
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int x;
  int *p;
  p = &x;
  printf("Enter an integer:  ");
  scanf("%d", &x);
  printf("I point to an: %d\n", *p);
  getchar();
  int *ptr = malloc(sizeof(*ptr));
  printf("Enter another integer: ");
  scanf("%d", ptr);
  printf("Your new integer is: %d\n", *ptr);
  getchar();
  x = function1(ptr);
  printf("%d\n", *ptr);
  free(ptr);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe44(%rip),%rdi
call   1080 <scanf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    -0x18(%rbp),%rdi
call   1040 <function1@plt>
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9b(%rip),%r14
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1080 <scanf@plt>
mov    0x4(%rsp),%esi
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    (%rbx),%esi
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %rbx,%rdi
call   1040 <function1@plt>
mov    %eax,0x4(%rsp)
mov    (%rbx),%esi
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter an integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"I point to an: %d\0A\00"
@.str.3 = [24 x i8] c"Enter another integer: \00"
@.str.4 = [25 x i8] c"Your new integer is: %d\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
store i32* %1, i32** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32*, i32** %2
%7 = load i32, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = call i32 (...) @getchar()
%10 = call i32* @malloc(i32 4)
store i32* %10, i32** %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32*, i32** %3
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = load i32*, i32** %3
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = call i32 (...) @getchar()
%18 = load i32*, i32** %3
%19 = call i32 @function1(i32* %18)
store i32 %19, i32* %1
%20 = load i32*, i32** %3
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = load i32*, i32** %3
%24 = call i32 @free(i32* %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter an integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"I point to an: %d\0A\00"
@.str.3 = [24 x i8] c"Enter another integer: \00"
@.str.4 = [25 x i8] c"Your new integer is: %d\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = call i32 (...) @getchar()
%8 = call i32* @malloc(i32 4)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%11 = load i32, i32* %8
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%13 = call i32 (...) @getchar()
%14 = call i32 @function1(i32* %8)
store i32 %14, i32* %1
%15 = load i32, i32* %8
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = call i32 @free(i32* %8)
ret i32 0
}