#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int prussdrv_load_data(int, unsigned int const *, int);
int prussdrv_load_datafile(int prunum, const char *filename) {
  FILE *fPtr;
  unsigned char fileDataArray[8192];
  int fileSize = 0;
  fPtr = fopen(filename, "rb");
  if (fPtr == NULL) {
    ;
    return -1;
  } else {
    ;
  }
  fseek(fPtr, 0, SEEK_END);
  fileSize = ftell(fPtr);
  if (fileSize == 0) {
    ;
    fclose(fPtr);
    return -1;
  }
  fseek(fPtr, 0, SEEK_SET);
  if (fileSize != fread((unsigned char *)fileDataArray, 1, fileSize, fPtr)) {
    ;
    fclose(fPtr);
    return -1;
  }
  fclose(fPtr);
  return prussdrv_load_data(prunum, (const unsigned int *)fileDataArray,
                            fileSize);
}


x86 assembly (clang, -O0):
<prussdrv_load_datafile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2024(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a7 <prussdrv_load_datafile+0x47>
movl   $0xffffffff,-0x4(%rbp)
jmp    1272 <prussdrv_load_datafile+0x112>
jmp    11ac <prussdrv_load_datafile+0x4c>
mov    -0x18(%rbp),%rdi
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%rbp)
jne    11f1 <prussdrv_load_datafile+0x91>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1272 <prussdrv_load_datafile+0x112>
mov    -0x18(%rbp),%rdi
mov    0x2ddc(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x2024(%rbp),%eax
mov    %eax,-0x2028(%rbp)
lea    -0x2020(%rbp),%rdi
mov    -0x2024(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %eax,%ecx
mov    -0x2028(%rbp),%eax
cmp    %ecx,%eax
je     1251 <prussdrv_load_datafile+0xf1>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1272 <prussdrv_load_datafile+0x112>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%edi
lea    -0x2020(%rbp),%rsi
mov    -0x2024(%rbp),%edx
call   1060 <prussdrv_load_data@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prussdrv_load_datafile>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2000,%rsp
mov    %rsi,%rax
mov    %edi,%r14d
lea    0xe84(%rip),%rsi
mov    %rax,%rdi
call   1080 <fopen@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
je     1202 <prussdrv_load_datafile+0xa2>
mov    %rax,%rbp
mov    0x2e4f(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
mov    %rbp,%rdi
call   1050 <ftell@plt>
test   %eax,%eax
je     11fa <prussdrv_load_datafile+0x9a>
mov    %eax,%ebx
mov    0x2e1e(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %rbp,%rcx
call   1030 <fread@plt>
mov    %eax,%r12d
mov    %rbp,%rdi
call   1040 <fclose@plt>
cmp    %r12d,%ebx
jne    1202 <prussdrv_load_datafile+0xa2>
mov    %rsp,%rsi
mov    %r14d,%edi
mov    %ebx,%edx
call   1060 <prussdrv_load_data@plt>
mov    %eax,%r15d
jmp    1202 <prussdrv_load_datafile+0xa2>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %r15d,%eax
add    $0x2000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i32 @prussdrv_load_datafile(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca [8192 x i8]
%8 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 0, i32* %8
%9 = load i8*, i8** %5
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %6
%11 = load i32*, i32** %6
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 -1, i32* %3
br label %47
14: ; preds = %2
br label %15
15: ; preds = %14
%16 = load i32*, i32** %6
%17 = load i32, i32* @SEEK_END
%18 = call i32 @fseek(i32* %16, i32 0, i32 %17)
%19 = load i32*, i32** %6
%20 = call i32 @ftell(i32* %19)
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = load i32*, i32** %6
%25 = call i32 @fclose(i32* %24)
store i32 -1, i32* %3
br label %47
26: ; preds = %15
%27 = load i32*, i32** %6
%28 = load i32, i32* @SEEK_SET
%29 = call i32 @fseek(i32* %27, i32 0, i32 %28)
%30 = load i32, i32* %8
%31 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%32 = load i32, i32* %8
%33 = load i32*, i32** %6
%34 = call i32 @fread(i8* %31, i32 1, i32 %32, i32* %33)
%35 = icmp ne i32 %30, %34
br i1 %35, label %36, label %39
36: ; preds = %26
%37 = load i32*, i32** %6
%38 = call i32 @fclose(i32* %37)
store i32 -1, i32* %3
br label %47
39: ; preds = %26
%40 = load i32*, i32** %6
%41 = call i32 @fclose(i32* %40)
%42 = load i32, i32* %4
%43 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%44 = bitcast i8* %43 to i32*
%45 = load i32, i32* %8
%46 = call i32 @prussdrv_load_data(i32 %42, i32* %44, i32 %45)
store i32 %46, i32* %3
br label %47
47: ; preds = %39, %36, %23, %13
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i32 @prussdrv_load_datafile(i32 %0, i8* nocapture %1) {
%3 = alloca [8192 x i8]
%4 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %23, label %7
7: ; preds = %2
%8 = load i32, i32* @SEEK_END
%9 = tail call i32 @fseek(i32* %5, i32 0, i32 %8)
%10 = tail call i32 @ftell(i32* %5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @fclose(i32* %5)
br label %23
14: ; preds = %7
%15 = load i32, i32* @SEEK_SET
%16 = tail call i32 @fseek(i32* %5, i32 0, i32 %15)
%17 = call i32 @fread(i8* %4, i32 1, i32 %10, i32* %5)
%18 = icmp eq i32 %10, %17
%19 = tail call i32 @fclose(i32* %5)
br i1 %18, label %20, label %23
20: ; preds = %14
%21 = bitcast [8192 x i8]* %3 to i32*
%22 = call i32 @prussdrv_load_data(i32 %0, i32* %21, i32 %10)
br label %23
23: ; preds = %14, %2, %20, %12
%24 = phi i32 [ -1, %12 ], [ %22, %20 ], [ -1, %2 ], [ -1, %14 ]
ret i32 %24
}