#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 *);
long fread(unsigned char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int prussdrv_exec_code(int, unsigned int const *, int);
int prussdrv_exec_program(int prunum, const char *filename) {
  FILE *fPtr;
  unsigned char fileDataArray[8192];
  long 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_exec_code(prunum, (const unsigned int *)fileDataArray,
                            (int)fileSize);
}


x86 assembly (clang, -O0):
<prussdrv_exec_program>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x2028(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a8 <prussdrv_exec_program+0x48>
movl   $0xffffffff,-0x4(%rbp)
jmp    127e <prussdrv_exec_program+0x11e>
jmp    11ad <prussdrv_exec_program+0x4d>
mov    -0x18(%rbp),%rdi
mov    0x2e30(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x2028(%rbp)
cmpq   $0x0,-0x2028(%rbp)
jne    11f4 <prussdrv_exec_program+0x94>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127e <prussdrv_exec_program+0x11e>
mov    -0x18(%rbp),%rdi
mov    0x2dd9(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x2028(%rbp),%rax
mov    %rax,-0x2030(%rbp)
lea    -0x2020(%rbp),%rdi
mov    -0x2028(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,%rcx
mov    -0x2030(%rbp),%rax
cmp    %rcx,%rax
je     125a <prussdrv_exec_program+0xfa>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127e <prussdrv_exec_program+0x11e>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%edi
lea    -0x2020(%rbp),%rsi
mov    -0x2028(%rbp),%rax
mov    %eax,%edx
call   1060 <prussdrv_exec_code@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prussdrv_exec_program>:
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     1205 <prussdrv_exec_program+0xa5>
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   %rax,%rax
je     11fd <prussdrv_exec_program+0x9d>
mov    %rax,%rbx
mov    0x2e1c(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1030 <fread@plt>
mov    %rax,%r12
mov    %rbp,%rdi
call   1040 <fclose@plt>
cmp    %r12,%rbx
jne    1205 <prussdrv_exec_program+0xa5>
mov    %rsp,%rsi
mov    %r14d,%edi
mov    %ebx,%edx
call   1060 <prussdrv_exec_code@plt>
mov    %eax,%r15d
jmp    1205 <prussdrv_exec_program+0xa5>
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_exec_program(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca [8192 x i8]
%8 = alloca i64
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 0, i64* %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 %48
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 i64 @ftell(i32* %19)
store i64 %20, i64* %8
%21 = load i64, i64* %8
%22 = icmp eq i64 %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 %48
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 i64, i64* %8
%31 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%32 = load i64, i64* %8
%33 = load i32*, i32** %6
%34 = call i64 @fread(i8* %31, i32 1, i64 %32, i32* %33)
%35 = icmp ne i64 %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 %48
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 i64, i64* %8
%46 = trunc i64 %45 to i32
%47 = call i32 @prussdrv_exec_code(i32 %42, i32* %44, i32 %46)
store i32 %47, i32* %3
br label %48
48: ; preds = %39, %36, %23, %13
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i32 @prussdrv_exec_program(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 %24, 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 i64 @ftell(i32* %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @fclose(i32* %5)
br label %24
14: ; preds = %7
%15 = load i32, i32* @SEEK_SET
%16 = tail call i32 @fseek(i32* %5, i32 0, i32 %15)
%17 = call i64 @fread(i8* %4, i32 1, i64 %10, i32* %5)
%18 = icmp eq i64 %10, %17
%19 = tail call i32 @fclose(i32* %5)
br i1 %18, label %20, label %24
20: ; preds = %14
%21 = bitcast [8192 x i8]* %3 to i32*
%22 = trunc i64 %10 to i32
%23 = call i32 @prussdrv_exec_code(i32 %0, i32* %21, i32 %22)
br label %24
24: ; preds = %14, %2, %20, %12
%25 = phi i32 [ -1, %12 ], [ %23, %20 ], [ -1, %2 ], [ -1, %14 ]
ret i32 %25
}