#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;
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*/ printf(char *, int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int Load(FILE *file, char **buffer, int *size) {
  ((void)0);
  size_t result;
  fseek(file, 0, SEEK_END);
  *size = ftell(file);
  rewind(file);
  if (!*size)
    return 1;
  printf("size: %d", *size);
  *buffer = (char *)malloc(*size * sizeof(char));
  if (!*buffer)
    return 1;
  result = fread(*buffer, sizeof(char), *size, file);
  if (result != *size)
    return 1;
  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)
mov    -0x10(%rbp),%rdi
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11bb <Load+0x5b>
movl   $0x1,-0x4(%rbp)
jmp    1249 <Load+0xe9>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
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    1203 <Load+0xa3>
movl   $0x1,-0x4(%rbp)
jmp    1249 <Load+0xe9>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
je     1242 <Load+0xe2>
movl   $0x1,-0x4(%rbp)
jmp    1249 <Load+0xe9>
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    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x2e71(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %rbx,%rdi
call   1060 <ftell@plt>
mov    %eax,(%r14)
mov    %rbx,%rdi
call   1050 <rewind@plt>
mov    (%r14),%esi
mov    $0x1,%ebp
test   %esi,%esi
je     11da <Load+0x7a>
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
mov    (%r14),%edi
call   1070 <malloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     11da <Load+0x7a>
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbx,%rcx
call   1030 <fread@plt>
movslq (%r14),%rcx
xor    %ebp,%ebp
cmp    %rcx,%rax
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@SEEK_END = global i32 0
@.str = [9 x i8] c"size: %d\00"
define i32 @Load(i32* nocapture %0, i8** nocapture writeonly %1, i32* nocapture %2) {
%4 = load i32, i32* @SEEK_END
%5 = tail call i32 @fseek(i32* %0, i32 0, i32 %4)
%6 = tail call i32 @ftell(i32* %0)
store i32 %6, i32* %2
%7 = tail call i32 @rewind(i32* %0)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %3
%11 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %8)
%12 = load i32, i32* %2
%13 = tail call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %1
%15 = icmp eq i64 %13, 0
br i1 %15, label %23, label %16
16: ; preds = %10
%17 = load i32, i32* %2
%18 = tail call i64 @fread(i8* %14, i32 1, i32 %17, i32* %0)
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = icmp ne i64 %18, %20
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %16, %10, %3
%24 = phi i32 [ 1, %3 ], [ 1, %10 ], [ %22, %16 ]
ret i32 %24
}