#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, "htext") == 1)
    errors++;
  if (chk_file(dir, "spgraf") == 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    0xe3b(%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)
cmpl   $0x0,-0x44(%rbp)
jle    121a <chk_all+0xca>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xe11(%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    0xe61(%rip),%rsi
mov    %r14,%rdi
call   1050 <chk_file@plt>
xor    %edx,%edx
cmp    $0x1,%eax
sete   %dl
add    %ebp,%edx
jne    11cc <chk_all+0x7c>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%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"htext\00"
@.str.2 = [7 x i8] c"spgraf\00"
@.str.3 = [10 x i8] c"levels/01\00"
@stderr = global i32 0
@.str.4 = [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 ([7 x i8], [7 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 ([10 x i8], [10 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 = load i32, i32* %2
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = load i32, i32* %2
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %26
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c"htext\00"
@.str.2 = [7 x i8] c"spgraf\00"
@.str.3 = [10 x i8] c"levels/01\00"
@stderr = global i32 0
@.str.4 = [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 ([7 x i8], [7 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 ([10 x i8], [10 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 = icmp eq i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %0
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %0
ret void
}