#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*/ SEEK_END;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int main() {
  int c;
  FILE *file;
  file = fopen("../files/content.txt", "r");
  fseek(file, 0, SEEK_END);
  long size = ftell(file);
  rewind(file);
  char content[size];
  fread(content, 1, size, file);
  printf(content);
  fclose(file);
  printf("\n");
  file = fopen("../files/multipleLines.txt", "r");
  if (file) {
    while ((c = getc(file)) != EOF)
      putchar(c);
    fclose(file);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe5a(%rip),%rdi
lea    0xe68(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e27(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x18(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x30(%rbp),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xde5(%rip),%rdi
call   1060 <printf@plt>
lea    0xddb(%rip),%rdi
lea    0xdd0(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     128f <main+0xff>
jmp    125e <main+0xce>
mov    -0x10(%rbp),%rdi
call   10b0 <getc@plt>
mov    %eax,-0x8(%rbp)
mov    0x2d6f(%rip),%rcx
cmp    (%rcx),%eax
je     1286 <main+0xf6>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    125e <main+0xce>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xe5e(%rip),%rdi
lea    0xe6c(%rip),%r14
mov    %r14,%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r12,%rdi
call   1080 <ftell@plt>
mov    %rax,%r15
mov    %r12,%rdi
call   1070 <rewind@plt>
lea    0xf(%r15),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %r12,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
call   1060 <printf@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdf8(%rip),%rdi
mov    %r14,%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     126c <main+0xdc>
mov    %rax,%rbx
mov    %rax,%rdi
call   10b0 <getc@plt>
mov    0x2da2(%rip),%r14
cmp    (%r14),%eax
je     1264 <main+0xd4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   10b0 <getc@plt>
cmp    (%r14),%eax
jne    1250 <main+0xc0>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"../files/content.txt\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [27 x i8] c"../files/multipleLines.txt\00"
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %3
%8 = load i32*, i32** %3
%9 = load i32, i32* @SEEK_END
%10 = call i32 @fseek(i32* %8, i32 0, i32 %9)
%11 = load i32*, i32** %3
%12 = call i64 @ftell(i32* %11)
store i64 %12, i64* %4
%13 = load i32*, i32** %3
%14 = call i32 @rewind(i32* %13)
%15 = load i64, i64* %4
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %5
%17 = alloca i8, i64 %15
store i64 %15, i64* %6
%18 = load i64, i64* %4
%19 = load i32*, i32** %3
%20 = call i32 @fread(i8* %17, i32 1, i64 %18, i32* %19)
%21 = call i32 @printf(i8* %17)
%22 = load i32*, i32** %3
%23 = call i32 @fclose(i32* %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32* @fopen(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %3
%26 = load i32*, i32** %3
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %40
28: ; preds = %0
br label %29
29: ; preds = %34, %28
%30 = load i32*, i32** %3
%31 = call i32 @getc(i32* %30)
store i32 %31, i32* %2
%32 = load i32, i32* @EOF
%33 = icmp ne i32 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = load i32, i32* %2
%36 = call i32 @putchar(i32 %35)
br label %29
37: ; preds = %29
%38 = load i32*, i32** %3
%39 = call i32 @fclose(i32* %38)
br label %40
40: ; preds = %37, %0
store i32 0, i32* %1
%41 = load i8*, i8** %5
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@.str = [21 x i8] c"../files/content.txt\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@.str.3 = [27 x i8] c"../files/multipleLines.txt\00"
@EOF = global i32 0
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = load i32, i32* @SEEK_END
%3 = tail call i32 @fseek(i32* %1, i32 0, i32 %2)
%4 = tail call i64 @ftell(i32* %1)
%5 = tail call i32 @rewind(i32* %1)
%6 = alloca i8, i64 %4
%7 = call i32 @fread(i8* %6, i32 1, i64 %4, i32* %1)
%8 = call i32 @printf(i8* %6)
%9 = tail call i32 @fclose(i32* %1)
%10 = tail call i32 @putchar(i32 10)
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %25, label %13
13: ; preds = %0
%14 = tail call i32 @getc(i32* %11)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %23, label %17
17: ; preds = %13, %17
%18 = phi i32 [ %20, %17 ], [ %14, %13 ]
%19 = tail call i32 @putchar(i32 %18)
%20 = tail call i32 @getc(i32* %11)
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %17
23: ; preds = %17, %13
%24 = tail call i32 @fclose(i32* %11)
br label %25
25: ; preds = %23, %0
ret i32 0
}