#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_init(char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ open_db_exist(char *);
int /*<<< orphan*/ status_set_tracking(char const *);
int /*<<< orphan*/ stderr;
bool init_database(const char *path) {
  if (open_db_exist("creating"))
    return false;
  if (!db_init(path)) {
    fprintf(stderr, "Database initialization unsuccessful\n");
    return false;
  }
  status_set_tracking(path);
  return true;
}


x86 assembly (clang, -O0):
<init_database>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xead(%rip),%rdi
call   1030 <open_db_exist@plt>
cmp    $0x0,%rax
je     116e <init_database+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11b1 <init_database+0x71>
mov    -0x10(%rbp),%rdi
call   1050 <db_init@plt>
cmp    $0x0,%eax
jne    11a1 <init_database+0x61>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b1 <init_database+0x71>
mov    -0x10(%rbp),%rdi
call   1040 <status_set_tracking@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_database>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeb2(%rip),%rdi
call   1030 <open_db_exist@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    118a <init_database+0x4a>
mov    %r14,%rdi
call   1050 <db_init@plt>
test   %eax,%eax
je     1175 <init_database+0x35>
mov    %r14,%rdi
call   1040 <status_set_tracking@plt>
mov    $0x1,%ebx
jmp    118a <init_database+0x4a>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
call   1060 <fprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"creating\00"
@stderr = global i32 0
@.str.1 = [38 x i8] c"Database initialization unsuccessful\0A\00"
define i32 @init_database(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = call i64 @open_db_exist(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 0, i32* %2
br label %17
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @db_init(i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %17
14: ; preds = %7
%15 = load i8*, i8** %3
%16 = call i32 @status_set_tracking(i8* %15)
store i32 1, i32* %2
br label %17
17: ; preds = %14, %11, %6
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@.str = [9 x i8] c"creating\00"
@stderr = global i32 0
@.str.1 = [38 x i8] c"Database initialization unsuccessful\0A\00"
define i32 @init_database(i8* %0) {
%2 = tail call i64 @open_db_exist(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %12
4: ; preds = %1
%5 = tail call i32 @db_init(i8* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %12
10: ; preds = %4
%11 = tail call i32 @status_set_tracking(i8* %0)
br label %12
12: ; preds = %1, %10, %7
%13 = phi i32 [ 1, %10 ], [ 0, %7 ], [ 0, %1 ]
ret i32 %13
}