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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseeko(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ ftello(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char Dat1Check(char *path) {
  FILE *file = fopen(path, "rb");
  char Unknown0;
  uint32_t Unknown1;
  uint64_t i;
  int e;
  fseeko(file, 7, SEEK_SET);
  i = ftello(file);
  Unknown0 = fgetc(file);
  e = fread(&Unknown1, 4, 1, file);
  if (!e)
    fprintf(stderr, "Dat1Check couldn't read a dword from 0x%lx\n", i);
  fclose(file);
  if ((Unknown0 == 0x0A || Unknown0 == 0x5E) && !Unknown1)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<Dat1Check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e3d(%rip),%rax
mov    (%rax),%edx
mov    $0x7,%esi
call   1080 <fseeko@plt>
mov    -0x18(%rbp),%rdi
call   1030 <ftello@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    11fb <Dat1Check+0x8b>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
lea    0xe0d(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
je     121e <Dat1Check+0xae>
movsbl -0x19(%rbp),%eax
cmp    $0x5e,%eax
jne    1231 <Dat1Check+0xc1>
cmpl   $0x0,-0x20(%rbp)
jne    1231 <Dat1Check+0xc1>
movb   $0x1,-0x1(%rbp)
jmp    1235 <Dat1Check+0xc5>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Dat1Check>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe81(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x7,%esi
call   1080 <fseeko@plt>
mov    %rbx,%rdi
call   1030 <ftello@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
test   %eax,%eax
jne    11e5 <Dat1Check+0x75>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
mov    %r14d,%edx
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
cmp    $0xa,%bpl
sete   %cl
cmp    $0x5e,%bpl
sete   %al
cmpl   $0x0,0xc(%rsp)
sete   %dl
or     %cl,%al
and    %dl,%al
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str.1 = [44 x i8] c"Dat1Check couldn't read a dword from 0x%lx\0A\00"
define signext i8 @Dat1Check(i8* %0) {
%2 = alloca i8
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %4
%11 = load i32*, i32** %4
%12 = load i32, i32* @SEEK_SET
%13 = call i32 @fseeko(i32* %11, i32 7, i32 %12)
%14 = load i32*, i32** %4
%15 = call i32 @ftello(i32* %14)
store i32 %15, i32* %7
%16 = load i32*, i32** %4
%17 = call signext i8 @fgetc(i32* %16)
store i8 %17, i8* %5
%18 = load i32*, i32** %4
%19 = call i32 @fread(i32* %6, i32 4, i32 1, i32* %18)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = icmp ne i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %1
%23 = load i32, i32* @stderr
%24 = load i32, i32* %7
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %22, %1
%27 = load i32*, i32** %4
%28 = call i32 @fclose(i32* %27)
%29 = load i8, i8* %5
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 10
br i1 %31, label %36, label %32
32: ; preds = %26
%33 = load i8, i8* %5
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 94
br i1 %35, label %36, label %40
36: ; preds = %32, %26
%37 = load i32, i32* %6
%38 = icmp ne i32 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %36
store i8 1, i8* %2
br label %41
40: ; preds = %36, %32
store i8 0, i8* %2
br label %41
41: ; preds = %40, %39
%42 = load i8, i8* %2
ret i8 %42
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str.1 = [44 x i8] c"Dat1Check couldn't read a dword from 0x%lx\0A\00"
define signext i8 @Dat1Check(i8* nocapture %0) {
%2 = alloca i32
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = bitcast i32* %2 to i8*
%5 = load i32, i32* @SEEK_SET
%6 = tail call i32 @fseeko(i32* %3, i32 7, i32 %5)
%7 = tail call i32 @ftello(i32* %3)
%8 = tail call signext i8 @fgetc(i32* %3)
%9 = call i32 @fread(i32* %2, i32 4, i32 1, i32* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %7)
br label %14
14: ; preds = %11, %1
%15 = tail call i32 @fclose(i32* %3)
%16 = icmp eq i8 %8, 10
%17 = icmp eq i8 %8, 94
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 0
%20 = or i1 %16, %17
%21 = select i1 %20, i1 %19, i1 false
%22 = zext i1 %21 to i8
ret i8 %22
}