#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 */
typedef int int8_t;
typedef int int32_t;

/* Variables and functions */
int DidInitRun();
int DidMainRun();
int FromPkg();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, ...);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int main(void) {
  int8_t ran_init = DidInitRun();
  if (!ran_init) {
    fprintf(stderr, "ERROR: DidInitRun returned unexpected results: %d\n",
            ran_init);
    return 1;
  }
  int8_t ran_main = DidMainRun();
  if (ran_main) {
    fprintf(stderr, "ERROR: DidMainRun returned unexpected results: %d\n",
            ran_main);
    return 1;
  }
  int32_t from_pkg = FromPkg();
  if (from_pkg != 1024) {
    fprintf(stderr, "ERROR: FromPkg=%d, want %d\n", from_pkg, 1024);
    return 1;
  }
  printf("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <DidInitRun@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1199 <main+0x49>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1228 <main+0xd8>
mov    $0x0,%al
call   1070 <DidMainRun@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11d3 <main+0x83>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1228 <main+0xd8>
mov    $0x0,%al
call   1060 <FromPkg@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x400,-0x10(%rbp)
je     1215 <main+0xc5>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%edx
lea    0xe69(%rip),%rsi
mov    $0x400,%ecx
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1228 <main+0xd8>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <DidInitRun@plt>
test   %eax,%eax
je     117b <main+0x2b>
xor    %eax,%eax
call   1070 <DidMainRun@plt>
test   %eax,%eax
je     119d <main+0x4d>
mov    0x2e72(%rip),%rcx
mov    (%rcx),%edi
lea    0xebc(%rip),%rsi
mov    %eax,%edx
jmp    118d <main+0x3d>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <FromPkg@plt>
cmp    $0x400,%eax
jne    11bb <main+0x6b>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
jmp    1199 <main+0x49>
mov    0x2e1e(%rip),%rcx
mov    (%rcx),%edi
lea    0xe9b(%rip),%rsi
mov    %eax,%edx
mov    $0x400,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1194 <main+0x44>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [51 x i8] c"ERROR: DidInitRun returned unexpected results: %d\0A\00"
@.str.1 = [51 x i8] c"ERROR: DidMainRun returned unexpected results: %d\0A\00"
@.str.2 = [28 x i8] c"ERROR: FromPkg=%d, want %d\0A\00"
@.str.3 = [6 x i8] c"PASS\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @DidInitRun()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = load i32, i32* %2
%11 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 1, i32* %1
br label %30
12: ; preds = %0
%13 = call i32 (...) @DidMainRun()
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = load i32, i32* %3
%19 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %18)
store i32 1, i32* %1
br label %30
20: ; preds = %12
%21 = call i32 (...) @FromPkg()
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 1024
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = load i32, i32* %4
%27 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %26, i32 1024)
store i32 1, i32* %1
br label %30
28: ; preds = %20
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %30
30: ; preds = %28, %24, %16, %8
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [51 x i8] c"ERROR: DidInitRun returned unexpected results: %d\0A\00"
@.str.1 = [51 x i8] c"ERROR: DidMainRun returned unexpected results: %d\0A\00"
@.str.2 = [28 x i8] c"ERROR: FromPkg=%d, want %d\0A\00"
@str = [5 x i8] c"PASS\00"
define i32 @main() {
%1 = tail call i32 (...) @DidInitRun()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 0)
br label %20
6: ; preds = %0
%7 = tail call i32 (...) @DidMainRun()
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %7)
br label %20
12: ; preds = %6
%13 = tail call i32 (...) @FromPkg()
%14 = icmp eq i32 %13, 1024
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 1024)
br label %20
18: ; preds = %12
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %9, %18, %15, %3
%21 = phi i32 [ 1, %3 ], [ 1, %9 ], [ 1, %15 ], [ 0, %18 ]
ret i32 %21
}