#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*/ closeFile(int /*<<< orphan*/ *);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
void print_file_content(const char *filename) {
  FILE *filePtr = fopen(filename, "r");
  if (!filePtr)
    error("Can't open file!");
  char bufer[64 + 1];
  while (!feof(filePtr)) {
    size_t readedBytes = fread(bufer, 1, 64, filePtr);
    bufer[readedBytes] = '\0';
    fprintf(stdout, "%s", bufer);
  }
  closeFile(filePtr);
}


x86 assembly (clang, -O0):
<print_file_content>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1197 <print_file_content+0x37>
lea    0xe70(%rip),%rdi
call   1070 <error@plt>
jmp    119c <print_file_content+0x3c>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ba <print_file_content+0x5a>
jmp    11fc <print_file_content+0x9c>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x40,%edx
call   1030 <fread@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rdx
lea    0xe21(%rip),%rsi
call   1040 <fprintf@plt>
jmp    119c <print_file_content+0x3c>
mov    -0x10(%rbp),%rdi
call   1060 <closeFile@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_file_content>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xe8e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    118b <print_file_content+0x2b>
lea    0xe7c(%rip),%rdi
call   1070 <error@plt>
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    11e4 <print_file_content+0x84>
mov    %rsp,%r14
mov    0x2e3f(%rip),%r12
lea    0xe6b(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x40,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
movb   $0x0,(%rsp,%rax,1)
mov    (%r12),%edi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
je     11b0 <print_file_content+0x50>
mov    %rbx,%rdi
call   1060 <closeFile@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [17 x i8] c"Can't open file!\00"
@stdout = global i32 0
@.str.2 = [3 x i8] c"%s\00"
define void @print_file_content(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [65 x i8]
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %3
%8 = load i32*, i32** %3
%9 = icmp ne i32* %8, null
br i1 %9, label %12, label %10
10: ; preds = %1
%11 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %1
br label %13
13: ; preds = %18, %12
%14 = load i32*, i32** %3
%15 = call i32 @feof(i32* %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br i1 %17, label %18, label %27
18: ; preds = %13
%19 = getelementptr inbounds [65 x i8], [65 x i8]* %4, i64 0, i64 0
%20 = load i32*, i32** %3
%21 = call i64 @fread(i8* %19, i32 1, i32 64, i32* %20)
store i64 %21, i64* %5
%22 = load i64, i64* %5
%23 = getelementptr inbounds [65 x i8], [65 x i8]* %4, i64 0, i64 %22
store i8 0, i8* %23
%24 = load i32, i32* @stdout
%25 = getelementptr inbounds [65 x i8], [65 x i8]* %4, i64 0, i64 0
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %13
27: ; preds = %13
%28 = load i32*, i32** %3
%29 = call i32 @closeFile(i32* %28)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [17 x i8] c"Can't open file!\00"
@stdout = global i32 0
@.str.2 = [3 x i8] c"%s\00"
define void @print_file_content(i8* nocapture %0) {
%2 = alloca [65 x i8]
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %1
%8 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
%9 = call i32 @feof(i32* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %7, %11
%12 = call i64 @fread(i8* %8, i32 1, i32 64, i32* %3)
%13 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 %12
store i8 0, i8* %13
%14 = load i32, i32* @stdout
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%16 = call i32 @feof(i32* %3)
%17 = icmp eq i32 %16, 0
br i1 %17, label %11, label %18
18: ; preds = %11, %7
%19 = call i32 @closeFile(i32* %3)
ret void
}