#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_file_exists(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
scalar_t__ is_file_encrypted(char *);
int /*<<< orphan*/ stderr;
bool db_make_sanity_check(char *path) {
  if (path == NULL) {
    fprintf(stderr,
            "Database is encrypted or does not exists."
            " It's also possible that\n~/.steel_open is either corrupted or"
            " missing.\n");
    return false;
  }
  if (!db_file_exists(path)) {
    fprintf(stderr, "%s: does not exists\n", path);
    free(path);
    return false;
  }
  if (is_file_encrypted(path)) {
    fprintf(stderr, "%s: is encrypted.\n", path);
    free(path);
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<db_make_sanity_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117a <db_make_sanity_check+0x3a>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1206 <db_make_sanity_check+0xc6>
mov    -0x10(%rbp),%rdi
call   1040 <db_file_exists@plt>
cmp    $0x0,%eax
jne    11bc <db_make_sanity_check+0x7c>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xed1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    1206 <db_make_sanity_check+0xc6>
mov    -0x10(%rbp),%rdi
call   1060 <is_file_encrypted@plt>
cmp    $0x0,%rax
je     11ff <db_make_sanity_check+0xbf>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    1206 <db_make_sanity_check+0xc6>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_make_sanity_check>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1173 <db_make_sanity_check+0x33>
mov    %rdi,%rbx
call   1040 <db_file_exists@plt>
test   %eax,%eax
je     118e <db_make_sanity_check+0x4e>
mov    %rbx,%rdi
call   1060 <is_file_encrypted@plt>
test   %rax,%rax
je     11b4 <db_make_sanity_check+0x74>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xf15(%rip),%rsi
jmp    119e <db_make_sanity_check+0x5e>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11b9 <db_make_sanity_check+0x79>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xed3(%rip),%rsi
xor    %ebp,%ebp
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11b9 <db_make_sanity_check+0x79>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [113 x i8] c"Database is encrypted or does not exists. It's also possible that\0A~/.steel_open is either corrupted or missing.\0A\00"
@.str.1 = [21 x i8] c"%s: does not exists\0A\00"
@.str.2 = [19 x i8] c"%s: is encrypted.\0A\00"
define i32 @db_make_sanity_check(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([113 x i8], [113 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %30
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @db_file_exists(i8* %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %9
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %3
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %3
%18 = call i32 @free(i8* %17)
store i32 0, i32* %2
br label %30
19: ; preds = %9
%20 = load i8*, i8** %3
%21 = call i64 @is_file_encrypted(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %3
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %3
%28 = call i32 @free(i8* %27)
store i32 0, i32* %2
br label %30
29: ; preds = %19
store i32 1, i32* %2
br label %30
30: ; preds = %29, %23, %13, %6
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [113 x i8] c"Database is encrypted or does not exists. It's also possible that\0A~/.steel_open is either corrupted or missing.\0A\00"
@.str.1 = [21 x i8] c"%s: does not exists\0A\00"
@.str.2 = [19 x i8] c"%s: is encrypted.\0A\00"
define i32 @db_make_sanity_check(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([113 x i8], [113 x i8]* @.str, i64 0, i64 0))
br label %20
6: ; preds = %1
%7 = tail call i32 @db_file_exists(i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = tail call i32 @free(i8* %0)
br label %20
13: ; preds = %6
%14 = tail call i64 @is_file_encrypted(i8* %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%19 = tail call i32 @free(i8* %0)
br label %20
20: ; preds = %13, %16, %9, %3
%21 = phi i32 [ 0, %3 ], [ 0, %16 ], [ 0, %9 ], [ 1, %13 ]
ret i32 %21
}