#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 fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void disp(char *filename) {
  int i;
  FILE *fp;
  if ((fp = fopen(filename, "r")) == NULL) {
    fprintf(stderr, "The file was not able to be opened.");
  } else {
    while ((i = fgetc(fp)) != EOF) {
      fputc(i, stdout);
    }
    fclose(fp);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<disp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a4 <disp+0x44>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1070 <fprintf@plt>
jmp    11e3 <disp+0x83>
jmp    11a9 <disp+0x49>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e2c(%rip),%rcx
cmp    (%rcx),%eax
je     11da <disp+0x7a>
mov    -0xc(%rbp),%edi
mov    0x2e02(%rip),%rax
mov    (%rax),%esi
call   1060 <fputc@plt>
jmp    11a9 <disp+0x49>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disp>:
push   %r15
push   %r14
push   %rbx
lea    0xe94(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11c1 <disp+0x61>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fgetc@plt>
mov    0x2e60(%rip),%r14
cmp    (%r14),%eax
je     11b7 <disp+0x57>
mov    0x2e3c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15),%esi
mov    %eax,%edi
call   1060 <fputc@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    (%r14),%eax
jne    11a0 <disp+0x40>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11d6 <disp+0x76>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [36 x i8] c"The file was not able to be opened.\00"
@EOF = global i32 0
@stdout = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
define void @disp(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** %4
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %24
11: ; preds = %1
br label %12
12: ; preds = %17, %11
%13 = load i32*, i32** %4
%14 = call i32 @fgetc(i32* %13)
store i32 %14, i32* %3
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32, i32* %3
%19 = load i32, i32* @stdout
%20 = call i32 @fputc(i32 %18, i32 %19)
br label %12
21: ; preds = %12
%22 = load i32*, i32** %4
%23 = call i32 @fclose(i32* %22)
br label %24
24: ; preds = %21, %8
%25 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [36 x i8] c"The file was not able to be opened.\00"
@EOF = global i32 0
@stdout = global i32 0
define void @disp(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 %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 %18, label %11
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %20
11: ; preds = %4, %11
%12 = phi i32 [ %15, %11 ], [ %5, %4 ]
%13 = load i32, i32* @stdout
%14 = tail call i32 @fputc(i32 %12, i32 %13)
%15 = tail call i32 @fgetc(i32* %2)
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %11
18: ; preds = %11, %4
%19 = tail call i32 @fclose(i32* %2)
br label %20
20: ; preds = %18, %8
%21 = tail call i32 @putchar(i32 10)
ret void
}