#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ db_file_exists(char *);
char *db_last_modified(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
scalar_t__ is_file_encrypted(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int status_count_file_lines(int /*<<< orphan*/ *);
int /*<<< orphan*/ status_del_tracking(char *);
int /*<<< orphan*/ *status_get_file_ptr(char *);
char *status_read_file_line(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ steel_tracker_file_exists();
void show_database_statuses() {
  int count;
  FILE *fp = NULL;
  if (!steel_tracker_file_exists())
    return;
  fp = status_get_file_ptr("r");
  if (fp == NULL)
    return;
  count = status_count_file_lines(fp);
  if (count == -2) {
    fprintf(stdout, "No databases found.\n");
    fclose(fp);
    return;
  }
  rewind(fp);
  while (count >= 0) {
    char *line = NULL;
    line = status_read_file_line(fp);
    if (line == NULL) {
      fprintf(stderr, "Error reading line. Corrupted .steel_dbs file?\n");
      fclose(fp);
      return;
    }
    if (!db_file_exists(line)) {
      fprintf(stderr, "Database file %s does not exist.\n", line);
      fprintf(stderr, "Will disable tracking for it.\n");
      status_del_tracking(line);
      count--;
      free(line);
      continue;
    }
    if (is_file_encrypted(line))
      fprintf(stdout, "%s\t%s\t%s\n", "[Encrypted]", db_last_modified(line),
              line);
    else
      fprintf(stdout, "%s\t%s\t%s\n", "[Decrypted]", db_last_modified(line),
              line);
    free(line);
    count--;
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<show_database_statuses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   10a0 <steel_tracker_file_exists@plt>
cmp    $0x0,%eax
jne    11e5 <show_database_statuses+0x25>
jmp    139c <show_database_statuses+0x1dc>
lea    0xe14(%rip),%rdi
call   1090 <status_get_file_ptr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1205 <show_database_statuses+0x45>
jmp    139c <show_database_statuses+0x1dc>
mov    -0x10(%rbp),%rdi
call   10c0 <status_count_file_lines@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xfffffffe,-0x4(%rbp)
jne    1240 <show_database_statuses+0x80>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
lea    0xdd7(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
jmp    139c <show_database_statuses+0x1dc>
mov    -0x10(%rbp),%rdi
call   1060 <rewind@plt>
cmpl   $0x0,-0x4(%rbp)
jl     1393 <show_database_statuses+0x1d3>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <status_read_file_line@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1298 <show_database_statuses+0xd8>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
jmp    139c <show_database_statuses+0x1dc>
mov    -0x18(%rbp),%rdi
call   1040 <db_file_exists@plt>
cmp    $0x0,%eax
jne    12fc <show_database_statuses+0x13c>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd89(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <status_del_tracking@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    1249 <show_database_statuses+0x89>
mov    -0x18(%rbp),%rdi
call   10d0 <is_file_encrypted@plt>
cmp    $0x0,%rax
je     1348 <show_database_statuses+0x188>
mov    0x2cc2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   10b0 <db_last_modified@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rcx
mov    -0x18(%rbp),%r8
lea    0xd53(%rip),%rsi
lea    0xd56(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    137c <show_database_statuses+0x1bc>
mov    0x2c89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   10b0 <db_last_modified@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rcx
mov    -0x18(%rbp),%r8
lea    0xd1a(%rip),%rsi
lea    0xd29(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1249 <show_database_statuses+0x89>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_database_statuses>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   10a0 <steel_tracker_file_exists@plt>
test   %eax,%eax
je     120a <show_database_statuses+0x4a>
lea    0xe23(%rip),%rdi
call   1090 <status_get_file_ptr@plt>
test   %rax,%rax
je     120a <show_database_statuses+0x4a>
mov    %rax,%rbx
mov    %rax,%rdi
call   10c0 <status_count_file_lines@plt>
cmp    $0xfffffffe,%eax
jne    1219 <show_database_statuses+0x59>
lea    0xe04(%rip),%rsi
mov    0x2dd3(%rip),%r13
jmp    12ec <show_database_statuses+0x12c>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <rewind@plt>
test   %ebp,%ebp
js     12f7 <show_database_statuses+0x137>
add    $0x1,%ebp
mov    0x2dab(%rip),%r13
jmp    1298 <show_database_statuses+0xd8>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   10d0 <is_file_encrypted@plt>
mov    %rax,%r12
mov    0x2d86(%rip),%rax
mov    (%rax),%r14d
mov    %r15,%rdi
call   10b0 <db_last_modified@plt>
test   %r12,%r12
lea    0xe2b(%rip),%rdx
lea    0xe30(%rip),%rcx
cmove  %rcx,%rdx
mov    %r14d,%edi
lea    0xe0c(%rip),%rsi
mov    %rax,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
add    $0xffffffff,%ebp
test   %ebp,%ebp
jle    12f7 <show_database_statuses+0x137>
mov    %rbx,%rdi
call   1070 <status_read_file_line@plt>
test   %rax,%rax
je     12e5 <show_database_statuses+0x125>
mov    %rax,%r15
mov    %rax,%rdi
call   1040 <db_file_exists@plt>
test   %eax,%eax
jne    1240 <show_database_statuses+0x80>
mov    0x0(%r13),%edi
lea    0xd88(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xd95(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,%rdi
call   10e0 <status_del_tracking@plt>
jmp    1289 <show_database_statuses+0xc9>
lea    0xd2b(%rip),%rsi
mov    0x0(%r13),%edi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stdout = global i32 0
@.str.1 = [21 x i8] c"No databases found.\0A\00"
@stderr = global i32 0
@.str.2 = [48 x i8] c"Error reading line. Corrupted .steel_dbs file?\0A\00"
@.str.3 = [34 x i8] c"Database file %s does not exist.\0A\00"
@.str.4 = [31 x i8] c"Will disable tracking for it.\0A\00"
@.str.5 = [10 x i8] c"%s\09%s\09%s\0A\00"
@.str.6 = [12 x i8] c"[Encrypted]\00"
@.str.7 = [12 x i8] c"[Decrypted]\00"
define void @show_database_statuses() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
store i32* null, i32** %2
%4 = call i32 (...) @steel_tracker_file_exists()
%5 = icmp ne i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %0
br label %78
7: ; preds = %0
%8 = call i32* @status_get_file_ptr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %7
br label %78
12: ; preds = %7
%13 = load i32*, i32** %2
%14 = call i32 @status_count_file_lines(i32* %13)
store i32 %14, i32* %1
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, -2
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i32, i32* @stdout
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32*, i32** %2
%21 = call i32 @fclose(i32* %20)
br label %78
22: ; preds = %12
%23 = load i32*, i32** %2
%24 = call i32 @rewind(i32* %23)
br label %25
25: ; preds = %70, %42, %22
%26 = load i32, i32* %1
%27 = icmp sge i32 %26, 0
br i1 %27, label %28, label %75
28: ; preds = %25
store i8* null, i8** %3
%29 = load i32*, i32** %2
%30 = call i8* @status_read_file_line(i32* %29)
store i8* %30, i8** %3
%31 = load i8*, i8** %3
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %38
33: ; preds = %28
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32*, i32** %2
%37 = call i32 @fclose(i32* %36)
br label %78
38: ; preds = %28
%39 = load i8*, i8** %3
%40 = call i32 @db_file_exists(i8* %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %54, label %42
42: ; preds = %38
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %3
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%48 = load i8*, i8** %3
%49 = call i32 @status_del_tracking(i8* %48)
%50 = load i32, i32* %1
%51 = add nsw i32 %50, -1
store i32 %51, i32* %1
%52 = load i8*, i8** %3
%53 = call i32 @free(i8* %52)
br label %25
54: ; preds = %38
%55 = load i8*, i8** %3
%56 = call i64 @is_file_encrypted(i8* %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %54
%59 = load i32, i32* @stdout
%60 = load i8*, i8** %3
%61 = call i8* @db_last_modified(i8* %60)
%62 = load i8*, i8** %3
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %61, i8* %62)
br label %70
64: ; preds = %54
%65 = load i32, i32* @stdout
%66 = load i8*, i8** %3
%67 = call i8* @db_last_modified(i8* %66)
%68 = load i8*, i8** %3
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %67, i8* %68)
br label %70
70: ; preds = %64, %58
%71 = load i8*, i8** %3
%72 = call i32 @free(i8* %71)
%73 = load i32, i32* %1
%74 = add nsw i32 %73, -1
store i32 %74, i32* %1
br label %25
75: ; preds = %25
%76 = load i32*, i32** %2
%77 = call i32 @fclose(i32* %76)
br label %78
78: ; preds = %75, %33, %17, %11, %6
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stdout = global i32 0
@.str.1 = [21 x i8] c"No databases found.\0A\00"
@stderr = global i32 0
@.str.2 = [48 x i8] c"Error reading line. Corrupted .steel_dbs file?\0A\00"
@.str.3 = [34 x i8] c"Database file %s does not exist.\0A\00"
@.str.4 = [31 x i8] c"Will disable tracking for it.\0A\00"
@.str.5 = [10 x i8] c"%s\09%s\09%s\0A\00"
@.str.6 = [12 x i8] c"[Encrypted]\00"
@.str.7 = [12 x i8] c"[Decrypted]\00"
define void @show_database_statuses() {
%1 = tail call i32 (...) @steel_tracker_file_exists()
%2 = icmp eq i32 %1, 0
br i1 %2, label %43, label %3
3: ; preds = %0
%4 = tail call i32* @status_get_file_ptr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %43, label %6
6: ; preds = %3
%7 = tail call i32 @status_count_file_lines(i32* %4)
%8 = icmp eq i32 %7, -2
br i1 %8, label %36, label %9
9: ; preds = %6
%10 = tail call i32 @rewind(i32* %4)
%11 = icmp sgt i32 %7, -1
br i1 %11, label %12, label %41
12: ; preds = %9, %32
%13 = phi i32 [ %34, %32 ], [ %7, %9 ]
%14 = tail call i8* @status_read_file_line(i32* %4)
%15 = icmp eq i8* %14, null
br i1 %15, label %36, label %16
16: ; preds = %12
%17 = tail call i32 @db_file_exists(i8* %14)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%24 = tail call i32 @status_del_tracking(i8* %14)
br label %32
25: ; preds = %16
%26 = tail call i64 @is_file_encrypted(i8* %14)
%27 = icmp eq i64 %26, 0
%28 = load i32, i32* @stdout
%29 = tail call i8* @db_last_modified(i8* %14)
%30 = select i1 %27, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0)
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %30, i8* %29, i8* %14)
br label %32
32: ; preds = %25, %19
%33 = tail call i32 @free(i8* %14)
%34 = add nsw i32 %13, -1
%35 = icmp sgt i32 %13, 0
br i1 %35, label %12, label %41
36: ; preds = %12, %6
%37 = phi i32* [ @stdout, %6 ], [ @stderr, %12 ]
%38 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), %6 ], [ getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), %12 ]
%39 = load i32, i32* %37
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* %38)
br label %41
41: ; preds = %32, %36, %9
%42 = tail call i32 @fclose(i32* %4)
br label %43
43: ; preds = %41, %3, %0
ret void
}