#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, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int Load(const char *fileName, char **buffer, int *size) {
  FILE *file;
  size_t result;
  if (!fileName)
    return 1;
  file = fopen(fileName, "rb");
  if (!file)
    return 1;
  fseek(file, 0, SEEK_END);
  *size = ftell(file);
  rewind(file);
  if (!*size)
    return 1;
  *buffer = (char *)malloc(*size * sizeof(char));
  if (!*buffer)
    return 1;
  result = fread(*buffer, sizeof(char), *size, file);
  if (result != *size)
    return 1;
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<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    119b <Load+0x2b>
movl   $0x1,-0x4(%rbp)
jmp    1292 <Load+0x122>
mov    -0x10(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c6 <Load+0x56>
movl   $0x1,-0x4(%rbp)
jmp    1292 <Load+0x122>
mov    -0x28(%rbp),%rdi
mov    0x2e17(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x28(%rbp),%rdi
call   1060 <ftell@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    120d <Load+0x9d>
movl   $0x1,-0x4(%rbp)
jmp    1292 <Load+0x122>
mov    -0x20(%rbp),%rax
movslq (%rax),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1243 <Load+0xd3>
movl   $0x1,-0x4(%rbp)
jmp    1292 <Load+0x122>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
je     1282 <Load+0x112>
movl   $0x1,-0x4(%rbp)
jmp    1292 <Load+0x122>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Load>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r14d
test   %rdi,%rdi
je     11ff <Load+0x8f>
mov    %rdx,%rbx
mov    %rsi,%r15
lea    0xe71(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     11ff <Load+0x8f>
mov    %rax,%rbp
mov    0x2e45(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %rbp,%rdi
call   1060 <ftell@plt>
mov    %eax,(%rbx)
mov    %rbp,%rdi
call   1050 <rewind@plt>
mov    (%rbx),%edi
test   %edi,%edi
je     11ff <Load+0x8f>
call   1070 <malloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     11ff <Load+0x8f>
mov    (%rbx),%edx
mov    $0x1,%r14d
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbp,%rcx
call   1030 <fread@plt>
movslq (%rbx),%rcx
cmp    %rcx,%rax
jne    11ff <Load+0x8f>
mov    %rbp,%rdi
call   1040 <fclose@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
define i32 @Load(i8* %0, i8** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i64
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %3
store i32 1, i32* %4
br label %61
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 %19, label %18
18: ; preds = %13
store i32 1, i32* %4
br label %61
19: ; preds = %13
%20 = load i32*, i32** %8
%21 = load i32, i32* @SEEK_END
%22 = call i32 @fseek(i32* %20, i32 0, i32 %21)
%23 = load i32*, i32** %8
%24 = call i32 @ftell(i32* %23)
%25 = load i32*, i32** %7
store i32 %24, i32* %25
%26 = load i32*, i32** %8
%27 = call i32 @rewind(i32* %26)
%28 = load i32*, i32** %7
%29 = load i32, i32* %28
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %19
store i32 1, i32* %4
br label %61
32: ; preds = %19
%33 = load i32*, i32** %7
%34 = load i32, i32* %33
%35 = sext i32 %34 to i64
%36 = mul i64 %35, 1
%37 = trunc i64 %36 to i32
%38 = call i64 @malloc(i32 %37)
%39 = inttoptr i64 %38 to i8*
%40 = load i8**, i8*** %6
store i8* %39, i8** %40
%41 = load i8**, i8*** %6
%42 = load i8*, i8** %41
%43 = icmp ne i8* %42, null
br i1 %43, label %45, label %44
44: ; preds = %32
store i32 1, i32* %4
br label %61
45: ; preds = %32
%46 = load i8**, i8*** %6
%47 = load i8*, i8** %46
%48 = load i32*, i32** %7
%49 = load i32, i32* %48
%50 = load i32*, i32** %8
%51 = call i64 @fread(i8* %47, i32 1, i32 %49, i32* %50)
store i64 %51, i64* %9
%52 = load i64, i64* %9
%53 = load i32*, i32** %7
%54 = load i32, i32* %53
%55 = sext i32 %54 to i64
%56 = icmp ne i64 %52, %55
br i1 %56, label %57, label %58
57: ; preds = %45
store i32 1, i32* %4
br label %61
58: ; preds = %45
%59 = load i32*, i32** %8
%60 = call i32 @fclose(i32* %59)
store i32 0, i32* %4
br label %61
61: ; preds = %58, %57, %44, %31, %18, %12
%62 = load i32, i32* %4
ret i32 %62
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
define i32 @Load(i8* %0, i8** nocapture writeonly %1, i32* nocapture %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %27, 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 %27, label %8
8: ; preds = %5
%9 = load i32, i32* @SEEK_END
%10 = tail call i32 @fseek(i32* %6, i32 0, i32 %9)
%11 = tail call i32 @ftell(i32* %6)
store i32 %11, i32* %2
%12 = tail call i32 @rewind(i32* %6)
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %8
%16 = tail call i64 @malloc(i32 %13)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %1
%18 = icmp eq i64 %16, 0
br i1 %18, label %27, label %19
19: ; preds = %15
%20 = load i32, i32* %2
%21 = tail call i64 @fread(i8* %17, i32 1, i32 %20, i32* %6)
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = icmp eq i64 %21, %23
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = tail call i32 @fclose(i32* %6)
br label %27
27: ; preds = %19, %15, %8, %5, %3, %25
%28 = phi i32 [ 0, %25 ], [ 1, %3 ], [ 1, %5 ], [ 1, %8 ], [ 1, %15 ], [ 1, %19 ]
ret i32 %28
}