#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_open(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ my_getpass(char *, char **, size_t *, int /*<<< orphan*/);
scalar_t__ open_db_exist(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ steel_tracker_file_exists();
bool open_database(const char *path) {
  if (!steel_tracker_file_exists())
    return false;
  size_t pwdlen = 255;
  char passphrase[pwdlen];
  char *ptr = passphrase;
  if (open_db_exist("opening"))
    return false;
  my_getpass("Master passphrase: ", &ptr, &pwdlen, stdin);
  if (!db_open(path, passphrase)) {
    fprintf(stderr, "Database opening unsuccessful.\n");
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<open_database>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <steel_tracker_file_exists@plt>
cmp    $0x0,%eax
jne    1178 <open_database+0x28>
movl   $0x0,-0x4(%rbp)
jmp    1244 <open_database+0xf4>
movq   $0xff,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    %rsp,%rax
mov    %rax,-0x20(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x40(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
lea    0xe4e(%rip),%rdi
call   1030 <open_db_exist@plt>
cmp    $0x0,%rax
je     11d4 <open_database+0x84>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    123d <open_database+0xed>
mov    0x2e0d(%rip),%rax
mov    (%rax),%ecx
lea    0xe24(%rip),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <my_getpass@plt>
mov    -0x40(%rbp),%rsi
mov    -0x10(%rbp),%rdi
call   1070 <db_open@plt>
cmp    $0x0,%eax
jne    122f <open_database+0xdf>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0xe05(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    123d <open_database+0xed>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_database>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <steel_tracker_file_exists@plt>
test   %eax,%eax
je     11ed <open_database+0x9d>
mov    %rsp,%r12
movq   $0xff,-0x30(%rbp)
mov    %rsp,%rbx
add    $0xffffffffffffff00,%rbx
mov    %rbx,%rsp
mov    %rbx,-0x28(%rbp)
lea    0xe6d(%rip),%rdi
call   1030 <open_db_exist@plt>
xor    %r15d,%r15d
test   %rax,%rax
jne    11ea <open_database+0x9a>
mov    0x2e41(%rip),%rax
mov    (%rax),%ecx
lea    0xe58(%rip),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1060 <my_getpass@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <db_open@plt>
mov    $0x1,%r15d
test   %eax,%eax
jne    11ea <open_database+0x9a>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe3a(%rip),%rsi
call   1040 <fprintf@plt>
xor    %r15d,%r15d
mov    %r12,%rsp
mov    %r15d,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"opening\00"
@.str.1 = [20 x i8] c"Master passphrase: \00"
@stdin = global i32 0
@stderr = global i32 0
@.str.2 = [32 x i8] c"Database opening unsuccessful.\0A\00"
define i32 @open_database(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %3
%9 = call i32 (...) @steel_tracker_file_exists()
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %1
store i32 0, i32* %2
br label %31
12: ; preds = %1
store i64 255, i64* %4
%13 = load i64, i64* %4
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %5
%15 = alloca i8, i64 %13
store i64 %13, i64* %6
store i8* %15, i8** %7
%16 = call i64 @open_db_exist(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 0, i32* %2
store i32 1, i32* %8
br label %29
19: ; preds = %12
%20 = load i32, i32* @stdin
%21 = call i32 @my_getpass(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8** %7, i64* %4, i32 %20)
%22 = load i8*, i8** %3
%23 = call i32 @db_open(i8* %22, i8* %15)
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
store i32 1, i32* %8
br label %29
28: ; preds = %19
store i32 1, i32* %2
store i32 1, i32* %8
br label %29
29: ; preds = %28, %25, %18
%30 = load i8*, i8** %5
br label %31
31: ; preds = %29, %11
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@.str = [8 x i8] c"opening\00"
@.str.1 = [20 x i8] c"Master passphrase: \00"
@stdin = global i32 0
@stderr = global i32 0
@.str.2 = [32 x i8] c"Database opening unsuccessful.\0A\00"
define i32 @open_database(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = tail call i32 (...) @steel_tracker_file_exists()
%5 = icmp eq i32 %4, 0
br i1 %5, label %24, label %6
6: ; preds = %1
%7 = bitcast i64* %2 to i8*
store i64 255, i64* %2
%8 = tail call i8* @llvm.stacksave()
%9 = alloca [255 x i8]
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%11 = bitcast i8** %3 to i8*
store i8* %10, i8** %3
%12 = call i64 @open_db_exist(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %6
%15 = load i32, i32* @stdin
%16 = call i32 @my_getpass(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8** %3, i64* %2, i32 %15)
%17 = call i32 @db_open(i8* %0, i8* %10)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %14, %6, %19
%23 = phi i32 [ 0, %19 ], [ 0, %6 ], [ 1, %14 ]
br label %24
24: ; preds = %1, %22
%25 = phi i32 [ %23, %22 ], [ 0, %1 ]
ret i32 %25
}