#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*/ foo(int, int, char, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int *, char ***, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int x = 0xfeedf00d;
  fprintf(stderr, "argc=%p argv=%p x=%p\n", &argc, &argv, &x);
  foo(0xaaaa, 0xbbbb, 'Z', 0xabcdabcdabcdabc);
  while (scanf("%d", &x)) {
    int *vx = (int *)malloc(sizeof(int));
    *vx = x;
  }
  printf("%d\n", x);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xfeedf00d,-0x14(%rbp)
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
lea    -0x8(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <fprintf@plt>
mov    $0xaaaa,%edi
mov    $0xbbbb,%esi
mov    $0x5a,%edx
mov    $0xdabcdabc,%ecx
call   1060 <foo@plt>
lea    0xe68(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
cmp    $0x0,%rax
je     11dd <main+0x8d>
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    11a7 <main+0x57>
mov    -0x14(%rbp),%esi
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,0xc(%rsp)
mov    %rsi,0x10(%rsp)
movl   $0xfeedf00d,0x8(%rsp)
fe
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%rbx
mov    %rbx,%r8
call   1040 <fprintf@plt>
mov    $0xaaaa,%edi
mov    $0xbbbb,%esi
mov    $0x5a,%edx
mov    $0xdabcdabc,%ecx
call   1060 <foo@plt>
lea    0xe67(%rip),%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
test   %rax,%rax
je     11f0 <main+0xa0>
lea    0xe53(%rip),%r14
lea    0x8(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    0x8(%rsp),%ecx
mov    %ecx,(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
test   %rax,%rax
jne    11d0 <main+0x80>
mov    0x8(%rsp),%esi
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"argc=%p argv=%p x=%p\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -17960947, i32* %6
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32* %4, i8*** %5, i32* %6)
%10 = call i32 @foo(i32 43690, i32 48059, i8 signext 90, i32 -625157444)
br label %11
11: ; preds = %14, %2
%12 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = call i64 @malloc(i32 4)
%16 = inttoptr i64 %15 to i32*
store i32* %16, i32** %7
%17 = load i32, i32* %6
%18 = load i32*, i32** %7
store i32 %17, i32* %18
br label %11
19: ; preds = %11
%20 = load i32, i32* %6
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"argc=%p argv=%p x=%p\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = bitcast i32* %5 to i8*
store i32 -17960947, i32* %5
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32* %3, i8*** %4, i32* %5)
%9 = call i32 @foo(i32 43690, i32 48059, i8 signext 90, i32 -625157444)
%10 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %2, %12
%13 = call i64 @malloc(i32 4)
%14 = inttoptr i64 %13 to i32*
%15 = load i32, i32* %5
store i32 %15, i32* %14
%16 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %12
18: ; preds = %12, %2
%19 = load i32, i32* %5
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %19)
ret i32 0
}