#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*/ db_close();
int /*<<< orphan*/ db_open();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ init();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ randomize_side();
int /*<<< orphan*/ stdout;
int main() {
  db_open();
  printf("Step 0. Initialize enviroment\n");
  fflush(stdout);
  if (init()) {
    db_close();
    printf(
        "Help message: double check file \"run.prm\" in current directory.\n");
    return -1;
  } else
    printf("Step 0 Done.\n\n");
  randomize_side();
  db_close();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <db_open@plt>
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x0,%al
call   1050 <init@plt>
cmp    $0x0,%rax
je     11c0 <main+0x60>
mov    $0x0,%al
call   1040 <db_close@plt>
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e1 <main+0x81>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <randomize_side@plt>
mov    $0x0,%al
call   1040 <db_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <db_open@plt>
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
xor    %eax,%eax
call   1050 <init@plt>
test   %rax,%rax
je     11aa <main+0x4a>
xor    %eax,%eax
call   1040 <db_close@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
jmp    11c4 <main+0x64>
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <randomize_side@plt>
xor    %eax,%eax
call   1040 <db_close@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Step 0. Initialize enviroment\0A\00"
@stdout = global i32 0
@.str.1 = [65 x i8] c"Help message: double check file \22run.prm\22 in current directory.\0A\00"
@.str.2 = [15 x i8] c"Step 0 Done.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @db_open()
%3 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdout
%5 = call i32 @fflush(i32 %4)
%6 = call i64 (...) @init()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 (...) @db_close()
%10 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %16
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11
%14 = call i32 (...) @randomize_side()
%15 = call i32 (...) @db_close()
store i32 0, i32* %1
br label %16
16: ; preds = %13, %8
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@stdout = global i32 0
@str = [30 x i8] c"Step 0. Initialize enviroment\00"
@str.3 = [14 x i8] c"Step 0 Done.\0A\00"
@str.4 = [64 x i8] c"Help message: double check file \22run.prm\22 in current directory.\00"
define i32 @main() {
%1 = tail call i32 (...) @db_open()
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%3 = load i32, i32* @stdout
%4 = tail call i32 @fflush(i32 %3)
%5 = tail call i64 (...) @init()
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = tail call i32 (...) @db_close()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.4, i64 0, i64 0))
br label %14
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0))
%12 = tail call i32 (...) @randomize_side()
%13 = tail call i32 (...) @db_close()
br label %14
14: ; preds = %10, %7
%15 = phi i32 [ -1, %7 ], [ 0, %10 ]
ret i32 %15
}