#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putchar(char);
void printFileContent(char *filename) {
  FILE *fp = fopen(filename, "r");
  char c;
  if (fp) {
    while ((c = getc(fp)) != EOF)
      putchar(c);
    fclose(fp);
  }
}


x86 assembly (clang, -O0):
<printFileContent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a8 <printFileContent+0x68>
jmp    1170 <printFileContent+0x30>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e62(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     119f <printFileContent+0x5f>
movsbl -0x11(%rbp),%edi
call   1030 <putchar@plt>
jmp    1170 <printFileContent+0x30>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printFileContent>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1194 <printFileContent+0x54>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <getc@plt>
mov    0x2e81(%rip),%r14
cmp    (%r14),%al
je     1185 <printFileContent+0x45>
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    (%r14),%al
jne    1170 <printFileContent+0x30>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i8 0
define void @printFileContent(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %23
9: ; preds = %1
br label %10
10: ; preds = %17, %9
%11 = load i32*, i32** %3
%12 = call signext i8 @getc(i32* %11)
store i8 %12, i8* %4
%13 = sext i8 %12 to i32
%14 = load i8, i8* @EOF
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %13, %15
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i8, i8* %4
%19 = call i32 @putchar(i8 signext %18)
br label %10
20: ; preds = %10
%21 = load i32*, i32** %3
%22 = call i32 @fclose(i32* %21)
br label %23
23: ; preds = %20, %1
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i8 0
define void @printFileContent(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = tail call signext i8 @getc(i32* %2)
%6 = load i8, i8* @EOF
%7 = icmp eq i8 %5, %6
br i1 %7, label %14, label %8
8: ; preds = %4, %8
%9 = phi i8 [ %11, %8 ], [ %5, %4 ]
%10 = tail call i32 @putchar(i8 signext %9)
%11 = tail call signext i8 @getc(i32* %2)
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %11, %12
br i1 %13, label %14, label %8
14: ; preds = %8, %4
%15 = tail call i32 @fclose(i32* %2)
br label %16
16: ; preds = %14, %1
ret void
}