#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
size_t fread(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
scalar_t__ ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char const *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int File_Load(const char *fileName, char **buffer, size_t *size) {
  ((void)0);
  FILE *file;
  size_t result;
  if (!fileName)
    return 0;
  file = fopen(fileName, "rb");
  if (!file) {
    printf("File_Load: Could not open file %s (fopen)", fileName);
    return 0;
  }
  fseek(file, 0, SEEK_END);
  (*size) = (size_t)ftell(file);
  rewind(file);
  if (!(*size)) {
    printf("File_Load: Could not open file %s (size is 0)", fileName);
    fclose(file);
    return 0;
  }
  (*buffer) = (char *)malloc(sizeof(char) * (*size));
  if (!(*buffer)) {
    printf("File_Load: Failed to allocate buffer for file %s (size %u)",
           fileName, (*size));
    fclose(file);
    return 0;
  }
  result = fread((*buffer), sizeof(char), (*size), file);
  if (result != (*size)) {
    printf("File_Load: Could not read the same number of bytes (size != "
           "result) for file %s (size %u, result %u)",
           fileName, (*size), result);
    free((*buffer));
    (*buffer) = NULL;
    fclose(file);
    return 0;
  }
  fclose(file);
  return 1;
}


x86 assembly (clang, -O0):
<File_Load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11bb <File_Load+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    133f <File_Load+0x1af>
mov    -0x10(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11f8 <File_Load+0x68>
mov    -0x10(%rbp),%rsi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    133f <File_Load+0x1af>
mov    -0x28(%rbp),%rdi
mov    0x2de5(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x28(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    125d <File_Load+0xcd>
mov    -0x10(%rbp),%rsi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    133f <File_Load+0x1af>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    12b5 <File_Load+0x125>
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    133f <File_Load+0x1af>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%rax
je     132f <File_Load+0x19f>
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
mov    -0x30(%rbp),%rcx
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    133f <File_Load+0x1af>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<File_Load>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %rdi,%rdi
je     1249 <File_Load+0xb9>
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0xe4f(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     124e <File_Load+0xbe>
mov    %rax,%r12
mov    0x2e1f(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
mov    %r12,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %r12,%rdi
call   1080 <ftell@plt>
mov    %rax,(%rbx)
mov    %r12,%rdi
call   1070 <rewind@plt>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     1264 <File_Load+0xd4>
call   1090 <malloc@plt>
mov    %rax,(%r15)
mov    (%rbx),%rdx
test   %rax,%rax
je     1277 <File_Load+0xe7>
mov    $0x1,%r14d
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r12,%rcx
call   1040 <fread@plt>
mov    (%rbx),%rdx
cmp    %rdx,%rax
je     128b <File_Load+0xfb>
lea    0xe6e(%rip),%rdi
xor    %r14d,%r14d
mov    %rbp,%rsi
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r15),%rdi
call   1030 <free@plt>
movq   $0x0,(%r15)
jmp    128b <File_Load+0xfb>
xor    %r14d,%r14d
jmp    1293 <File_Load+0x103>
lea    0xdae(%rip),%rdi
xor    %r14d,%r14d
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1293 <File_Load+0x103>
lea    0xdc2(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    128b <File_Load+0xfb>
lea    0xddd(%rip),%rdi
xor    %r14d,%r14d
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [42 x i8] c"File_Load: Could not open file %s (fopen)\00"
@SEEK_END = global i32 0
@.str.2 = [46 x i8] c"File_Load: Could not open file %s (size is 0)\00"
@.str.3 = [59 x i8] c"File_Load: Failed to allocate buffer for file %s (size %u)\00"
@.str.4 = [101 x i8] c"File_Load: Could not read the same number of bytes (size != result) for file %s (size %u, result %u)\00"
define i32 @File_Load(i8* %0, i8** %1, i64* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i64*
%8 = alloca i32*
%9 = alloca i64
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i64* %2, i64** %7
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %3
store i32 0, i32* %4
br label %82
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %8
%16 = load i32*, i32** %8
%17 = icmp ne i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = load i8*, i8** %5
%20 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %19)
store i32 0, i32* %4
br label %82
21: ; preds = %13
%22 = load i32*, i32** %8
%23 = load i32, i32* @SEEK_END
%24 = call i32 @fseek(i32* %22, i32 0, i32 %23)
%25 = load i32*, i32** %8
%26 = call i64 @ftell(i32* %25)
%27 = load i64*, i64** %7
store i64 %26, i64* %27
%28 = load i32*, i32** %8
%29 = call i32 @rewind(i32* %28)
%30 = load i64*, i64** %7
%31 = load i64, i64* %30
%32 = icmp ne i64 %31, 0
br i1 %32, label %38, label %33
33: ; preds = %21
%34 = load i8*, i8** %5
%35 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = load i32*, i32** %8
%37 = call i32 @fclose(i32* %36)
store i32 0, i32* %4
br label %82
38: ; preds = %21
%39 = load i64*, i64** %7
%40 = load i64, i64* %39
%41 = mul i64 1, %40
%42 = trunc i64 %41 to i32
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to i8*
%45 = load i8**, i8*** %6
store i8* %44, i8** %45
%46 = load i8**, i8*** %6
%47 = load i8*, i8** %46
%48 = icmp ne i8* %47, null
br i1 %48, label %56, label %49
49: ; preds = %38
%50 = load i8*, i8** %5
%51 = load i64*, i64** %7
%52 = load i64, i64* %51
%53 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i8* %50, i64 %52)
%54 = load i32*, i32** %8
%55 = call i32 @fclose(i32* %54)
store i32 0, i32* %4
br label %82
56: ; preds = %38
%57 = load i8**, i8*** %6
%58 = load i8*, i8** %57
%59 = load i64*, i64** %7
%60 = load i64, i64* %59
%61 = load i32*, i32** %8
%62 = call i64 @fread(i8* %58, i32 1, i64 %60, i32* %61)
store i64 %62, i64* %9
%63 = load i64, i64* %9
%64 = load i64*, i64** %7
%65 = load i64, i64* %64
%66 = icmp ne i64 %63, %65
br i1 %66, label %67, label %79
67: ; preds = %56
%68 = load i8*, i8** %5
%69 = load i64*, i64** %7
%70 = load i64, i64* %69
%71 = load i64, i64* %9
%72 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.4, i64 0, i64 0), i8* %68, i64 %70, i64 %71)
%73 = load i8**, i8*** %6
%74 = load i8*, i8** %73
%75 = call i32 @free(i8* %74)
%76 = load i8**, i8*** %6
store i8* null, i8** %76
%77 = load i32*, i32** %8
%78 = call i32 @fclose(i32* %77)
store i32 0, i32* %4
br label %82
79: ; preds = %56
%80 = load i32*, i32** %8
%81 = call i32 @fclose(i32* %80)
store i32 1, i32* %4
br label %82
82: ; preds = %79, %67, %49, %33, %18, %12
%83 = load i32, i32* %4
ret i32 %83
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [42 x i8] c"File_Load: Could not open file %s (fopen)\00"
@SEEK_END = global i32 0
@.str.2 = [46 x i8] c"File_Load: Could not open file %s (size is 0)\00"
@.str.3 = [59 x i8] c"File_Load: Failed to allocate buffer for file %s (size %u)\00"
@.str.4 = [101 x i8] c"File_Load: Could not read the same number of bytes (size != result) for file %s (size %u, result %u)\00"
define i32 @File_Load(i8* %0, i8** nocapture %1, i64* nocapture %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %40, label %5
5: ; preds = %3
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %40
10: ; preds = %5
%11 = load i32, i32* @SEEK_END
%12 = tail call i32 @fseek(i32* %6, i32 0, i32 %11)
%13 = tail call i64 @ftell(i32* %6)
store i64 %13, i64* %2
%14 = tail call i32 @rewind(i32* %6)
%15 = load i64, i64* %2
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%19 = tail call i32 @fclose(i32* %6)
br label %40
20: ; preds = %10
%21 = trunc i64 %15 to i32
%22 = tail call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %1
%24 = icmp eq i64 %22, 0
%25 = load i64, i64* %2
br i1 %24, label %26, label %29
26: ; preds = %20
%27 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i8* %0, i64 %25)
%28 = tail call i32 @fclose(i32* %6)
br label %40
29: ; preds = %20
%30 = tail call i64 @fread(i8* %23, i32 1, i64 %25, i32* %6)
%31 = load i64, i64* %2
%32 = icmp eq i64 %30, %31
br i1 %32, label %38, label %33
33: ; preds = %29
%34 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.4, i64 0, i64 0), i8* %0, i64 %31, i64 %30)
%35 = load i8*, i8** %1
%36 = tail call i32 @free(i8* %35)
store i8* null, i8** %1
%37 = tail call i32 @fclose(i32* %6)
br label %40
38: ; preds = %29
%39 = tail call i32 @fclose(i32* %6)
br label %40
40: ; preds = %3, %38, %33, %26, %17, %8
%41 = phi i32 [ 0, %33 ], [ 1, %38 ], [ 0, %26 ], [ 0, %17 ], [ 0, %8 ], [ 0, %3 ]
ret i32 %41
}