#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 chk_file(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *get_data_dir(int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
void chk_all(void) {
  char dir[64];
  int errors = 0;
  snprintf(dir, sizeof dir, "%s", get_data_dir(0));
  if (dir == NULL) {
    fprintf(stderr, "Unable to find data, aborting.\n");
    exit(1);
  }
  if (chk_file(dir, "gover") == 1)
    errors++;
  if (chk_file(dir, "htext") == 1)
    errors++;
  if (chk_file(dir, "spgraf") == 1)
    errors++;
  if (chk_file(dir, "tdesc") == 1)
    errors++;
  if (chk_file(dir, "levels/01") == 1)
    errors++;
  if (errors > 0) {
    fprintf(stderr, "%d or more required data files are missing, aborting.\n",
            errors);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<chk_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x44(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
xor    %edi,%edi
call   1070 <get_data_dir@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rcx
mov    $0x40,%esi
lea    0xe7f(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x40(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1050 <chk_file@plt>
cmp    $0x1,%eax
jne    11a8 <chk_all+0x58>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1050 <chk_file@plt>
cmp    $0x1,%eax
jne    11ca <chk_all+0x7a>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1050 <chk_file@plt>
cmp    $0x1,%eax
jne    11ec <chk_all+0x9c>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1050 <chk_file@plt>
cmp    $0x1,%eax
jne    120e <chk_all+0xbe>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe03(%rip),%rsi
call   1050 <chk_file@plt>
cmp    $0x1,%eax
jne    1230 <chk_all+0xe0>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jle    125e <chk_all+0x10e>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chk_all>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
xor    %edi,%edi
call   1070 <get_data_dir@plt>
lea    0xe9a(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rax,%rcx
call   1030 <snprintf@plt>
lea    0xe83(%rip),%rsi
mov    %r14,%rdi
call   1050 <chk_file@plt>
xor    %ebx,%ebx
cmp    $0x1,%eax
sete   %bl
lea    0xe72(%rip),%rsi
mov    %r14,%rdi
call   1050 <chk_file@plt>
lea    0x1(%rbx),%ebp
cmp    $0x1,%eax
cmovne %ebx,%ebp
lea    0xe60(%rip),%rsi
mov    %r14,%rdi
call   1050 <chk_file@plt>
xor    %ebx,%ebx
cmp    $0x1,%eax
sete   %bl
add    %ebp,%ebx
lea    0xe4e(%rip),%rsi
mov    %r14,%rdi
call   1050 <chk_file@plt>
xor    %ebp,%ebp
cmp    $0x1,%eax
sete   %bpl
add    %ebx,%ebp
lea    0xe3a(%rip),%rsi
mov    %r14,%rdi
call   1050 <chk_file@plt>
xor    %edx,%edx
cmp    $0x1,%eax
sete   %dl
add    %ebp,%edx
jne    11ff <chk_all+0xaf>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xe17(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c"gover\00"
@.str.2 = [6 x i8] c"htext\00"
@.str.3 = [7 x i8] c"spgraf\00"
@.str.4 = [6 x i8] c"tdesc\00"
@.str.5 = [10 x i8] c"levels/01\00"
@stderr = global i32 0
@.str.6 = [55 x i8] c"%d or more required data files are missing, aborting.\0A\00"
define void @chk_all() {
%1 = alloca [64 x i8]
%2 = alloca i32
store i32 0, i32* %2
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%4 = call i8* @get_data_dir(i32 0)
%5 = call i32 @snprintf(i8* %3, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%7 = call i32 @chk_file(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
store i32 %11, i32* %2
br label %12
12: ; preds = %9, %0
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%14 = call i32 @chk_file(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %19
19: ; preds = %16, %12
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%21 = call i32 @chk_file(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %26
26: ; preds = %23, %19
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%28 = call i32 @chk_file(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %33
33: ; preds = %30, %26
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%35 = call i32 @chk_file(i8* %34, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* %2
%39 = add nsw i32 %38, 1
store i32 %39, i32* %2
br label %40
40: ; preds = %37, %33
%41 = load i32, i32* %2
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = load i32, i32* %2
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i32 %45)
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %40
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c"gover\00"
@.str.2 = [6 x i8] c"htext\00"
@.str.3 = [7 x i8] c"spgraf\00"
@.str.4 = [6 x i8] c"tdesc\00"
@.str.5 = [10 x i8] c"levels/01\00"
@stderr = global i32 0
@.str.6 = [55 x i8] c"%d or more required data files are missing, aborting.\0A\00"
define void @chk_all() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = tail call i8* @get_data_dir(i32 0)
%4 = call i32 @snprintf(i8* %2, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 @chk_file(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 1
%7 = zext i1 %6 to i32
%8 = call i32 @chk_file(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 1
%10 = select i1 %6, i32 2, i32 1
%11 = select i1 %9, i32 %10, i32 %7
%12 = call i32 @chk_file(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i32 %12, 1
%14 = zext i1 %13 to i32
%15 = add nuw nsw i32 %11, %14
%16 = call i32 @chk_file(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i32 %16, 1
%18 = zext i1 %17 to i32
%19 = add nuw nsw i32 %15, %18
%20 = call i32 @chk_file(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%21 = icmp eq i32 %20, 1
%22 = zext i1 %21 to i32
%23 = add nuw nsw i32 %19, %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %0
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i32 %23)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %0
ret void
}