#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void print_file_content(char *file_name) {
  FILE *fp;
  int c;
  if ((fp = fopen(file_name, "r")) == NULL) {
    fprintf(stderr, "Err. opening filename %s\n", file_name);
    exit(EXIT_FAILURE);
  }
  while ((c = fgetc(fp)) != EOF)
    fputc(c, stdout);
  fclose(fp);
}


x86 assembly (clang, -O0):
<print_file_content>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11b1 <print_file_content+0x51>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe64(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11b6 <print_file_content+0x56>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e1f(%rip),%rcx
cmp    (%rcx),%eax
je     11e7 <print_file_content+0x87>
mov    -0x14(%rbp),%edi
mov    0x2ded(%rip),%rax
mov    (%rax),%esi
call   1050 <fputc@plt>
jmp    11b6 <print_file_content+0x56>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_file_content>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xe91(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c4 <print_file_content+0x64>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <fgetc@plt>
mov    0x2e5d(%rip),%r14
cmp    (%r14),%eax
je     11b7 <print_file_content+0x57>
mov    0x2e31(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    (%r15),%esi
mov    %eax,%edi
call   1050 <fputc@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    (%r14),%eax
jne    11a0 <print_file_content+0x40>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Err. opening filename %s\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
@stdout = global i32 0
define void @print_file_content(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
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 = icmp eq i32* %6, null
br i1 %7, label %8, label %14
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %2
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %1
br label %15
15: ; preds = %20, %14
%16 = load i32*, i32** %3
%17 = call i32 @fgetc(i32* %16)
store i32 %17, i32* %4
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32, i32* %4
%22 = load i32, i32* @stdout
%23 = call i32 @fputc(i32 %21, i32 %22)
br label %15
24: ; preds = %15
%25 = load i32*, i32** %3
%26 = call i32 @fclose(i32* %25)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Err. opening filename %s\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
@stdout = global i32 0
define void @print_file_content(i8* %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 %8, label %4
4: ; preds = %1
%5 = tail call i32 @fgetc(i32* %2)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %20, label %13
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %4, %13
%14 = phi i32 [ %17, %13 ], [ %5, %4 ]
%15 = load i32, i32* @stdout
%16 = tail call i32 @fputc(i32 %14, i32 %15)
%17 = tail call i32 @fgetc(i32* %2)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %13
20: ; preds = %13, %4
%21 = tail call i32 @fclose(i32* %2)
ret void
}