#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 EOF;
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ writeByte(unsigned int, unsigned char);
void loadMemoryFromFile(FILE *input) {
  int b;
  unsigned int a = 0U;
  while ((!feof(input)) && ((b = fgetc(input)) != EOF)) {
    writeByte(a, (unsigned char)b);
    ++a;
  }
}


x86 assembly (clang, -O0):
<loadMemoryFromFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jne    1177 <loadMemoryFromFile+0x47>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e79(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1187 <loadMemoryFromFile+0x57>
jmp    11a3 <loadMemoryFromFile+0x73>
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%eax
movzbl %al,%esi
call   1050 <writeByte@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1143 <loadMemoryFromFile+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadMemoryFromFile>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <feof@plt>
test   %eax,%eax
jne    1176 <loadMemoryFromFile+0x46>
xor    %ebp,%ebp
mov    0x2e9f(%rip),%r14
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    (%r14),%eax
je     1176 <loadMemoryFromFile+0x46>
movzbl %al,%esi
mov    %ebp,%edi
call   1050 <writeByte@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %eax,%eax
je     1150 <loadMemoryFromFile+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define void @loadMemoryFromFile(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %4
br label %5
5: ; preds = %16, %1
%6 = load i32*, i32** %2
%7 = call i32 @feof(i32* %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %5
%10 = load i32*, i32** %2
%11 = call i32 @fgetc(i32* %10)
store i32 %11, i32* %3
%12 = load i32, i32* @EOF
%13 = icmp ne i32 %11, %12
br label %14
14: ; preds = %9, %5
%15 = phi i1 [ false, %5 ], [ %13, %9 ]
br i1 %15, label %16, label %23
16: ; preds = %14
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = trunc i32 %18 to i8
%20 = call i32 @writeByte(i32 %17, i8 zeroext %19)
%21 = load i32, i32* %4
%22 = add i32 %21, 1
store i32 %22, i32* %4
br label %5
23: ; preds = %14
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @loadMemoryFromFile(i32* nocapture %0) {
%2 = tail call i32 @feof(i32* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %15
4: ; preds = %1, %9
%5 = phi i32 [ %12, %9 ], [ 0, %1 ]
%6 = tail call i32 @fgetc(i32* %0)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %15, label %9
9: ; preds = %4
%10 = trunc i32 %6 to i8
%11 = tail call i32 @writeByte(i32 %5, i8 zeroext %10)
%12 = add i32 %5, 1
%13 = tail call i32 @feof(i32* %0)
%14 = icmp eq i32 %13, 0
br i1 %14, label %4, label %15
15: ; preds = %4, %9, %1
ret void
}