#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(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ my_getpass(char *, char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ steel_tracker_file_exists();
scalar_t__ strcmp(char *, char *);
void close_database() {
  if (!steel_tracker_file_exists())
    return;
  size_t pwdlen = 255;
  char passphrase[pwdlen];
  char *ptr = passphrase;
  char pass2[pwdlen];
  char *ptr2 = pass2;
  my_getpass("Master passphrase: ", &ptr, &pwdlen, stdin);
  my_getpass("Retype master passphrase: ", &ptr2, &pwdlen, stdin);
  if (strcmp(passphrase, pass2) != 0) {
    fprintf(stderr, "Passphrases do not match.\n");
    return;
  }
  db_close(passphrase);
}


x86 assembly (clang, -O0):
<close_database>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    $0x0,%al
call   1060 <steel_tracker_file_exists@plt>
cmp    $0x0,%eax
jne    116d <close_database+0x1d>
jmp    124d <close_database+0xfd>
movq   $0xff,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x48(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
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)
mov    0x2e1d(%rip),%rax
mov    (%rax),%ecx
lea    0xe2c(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1070 <my_getpass@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%ecx
lea    0xe23(%rip),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1070 <my_getpass@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1236 <close_database+0xe6>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
lea    0xe0a(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x34(%rbp)
jmp    1246 <close_database+0xf6>
mov    -0x48(%rbp),%rdi
call   1030 <db_close@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_database>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1060 <steel_tracker_file_exists@plt>
test   %eax,%eax
je     1206 <close_database+0xb6>
mov    %rsp,%r12
movq   $0xff,-0x40(%rbp)
mov    %rsp,%rbx
add    $0xffffffffffffff00,%rbx
mov    %rbx,%rsp
mov    %rbx,-0x38(%rbp)
lea    -0x100(%rsp),%r14
ff
mov    %r14,%rsp
mov    %r14,-0x30(%rbp)
mov    0x2e46(%rip),%r13
mov    0x0(%r13),%ecx
lea    0xe53(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%r15
mov    %r15,%rdx
call   1070 <my_getpass@plt>
mov    0x0(%r13),%ecx
lea    0xe4c(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    %r15,%rdx
call   1070 <my_getpass@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11fb <close_database+0xab>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1203 <close_database+0xb3>
mov    %rbx,%rdi
call   1030 <db_close@plt>
mov    %r12,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [20 x i8] c"Master passphrase: \00"
@stdin = global i32 0
@.str.1 = [27 x i8] c"Retype master passphrase: \00"
@stderr = global i32 0
@.str.2 = [27 x i8] c"Passphrases do not match.\0A\00"
define void @close_database() {
%1 = alloca i64
%2 = alloca i8*
%3 = alloca i8*
%4 = tail call i32 (...) @steel_tracker_file_exists()
%5 = icmp eq i32 %4, 0
br i1 %5, label %27, label %6
6: ; preds = %0
%7 = bitcast i64* %1 to i8*
store i64 255, i64* %1
%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** %2 to i8*
store i8* %10, i8** %2
%12 = alloca [255 x i8]
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%14 = bitcast i8** %3 to i8*
store i8* %13, i8** %3
%15 = load i32, i32* @stdin
%16 = call i32 @my_getpass(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8** %2, i64* %1, i32 %15)
%17 = load i32, i32* @stdin
%18 = call i32 @my_getpass(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8** %3, i64* %1, i32 %17)
%19 = call i64 @strcmp(i8* %10, i8* %13)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %6
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %26
24: ; preds = %6
%25 = call i32 @db_close(i8* %10)
br label %26
26: ; preds = %24, %21
br label %27
27: ; preds = %0, %26
ret void
}