#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putchar(int);
void readEntireFile() {
  int ch;
  FILE *fp;
  fp = fopen("/home/caleb/Documents/genesis/data/me", "r");
  ch = getc(fp);
  while (ch != EOF) {
    putchar(ch);
    ch = getc(fp);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<readEntireFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0xed0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%eax
je     1196 <readEntireFile+0x56>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x4(%rbp)
jmp    116b <readEntireFile+0x2b>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readEntireFile>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
lea    0xed4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <getc@plt>
mov    0x2e7f(%rip),%r14
cmp    (%r14),%eax
je     1184 <readEntireFile+0x44>
xchg   %ax,%ax
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    (%r14),%eax
jne    1170 <readEntireFile+0x30>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"/home/caleb/Documents/genesis/data/me\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
define void @readEntireFile() {
%1 = alloca i32
%2 = alloca i32*
%3 = call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 @getc(i32* %4)
store i32 %5, i32* %1
br label %6
6: ; preds = %10, %0
%7 = load i32, i32* %1
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = load i32, i32* %1
%12 = call i32 @putchar(i32 %11)
%13 = load i32*, i32** %2
%14 = call i32 @getc(i32* %13)
store i32 %14, i32* %1
br label %6
15: ; preds = %6
%16 = load i32*, i32** %2
%17 = call i32 @fclose(i32* %16)
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"/home/caleb/Documents/genesis/data/me\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
define void @readEntireFile() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @getc(i32* %1)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %11, label %5
5: ; preds = %0, %5
%6 = phi i32 [ %8, %5 ], [ %2, %0 ]
%7 = tail call i32 @putchar(i32 %6)
%8 = tail call i32 @getc(i32* %1)
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %5
11: ; preds = %5, %0
%12 = tail call i32 @fclose(i32* %1)
ret void
}