#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*/ clearScreen();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ pause();
int /*<<< orphan*/ printf(char *, ...);
void displayError(const char *filename) {
  clearScreen();
  printf("Failure:\n");
  FILE *fp = fopen(filename, "r");
  char linebuf[1024];
  char *line;
  while ((line = fgets(linebuf, 1024, fp)) != NULL) {
    printf("%s", line);
  };
  fclose(fp);
  printf("Installer terminating.\n");
  while (1)
    pause();
}


x86 assembly (clang, -O0):
<displayError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <clearScreen@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
mov    %rax,-0x418(%rbp)
cmp    $0x0,%rax
je     11d8 <displayError+0x78>
mov    -0x418(%rbp),%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1198 <displayError+0x38>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <pause@plt>
jmp    11ef <displayError+0x8f>

x86 assembly (clang, -O2):
<displayError>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1070 <clearScreen@plt>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11f2 <displayError+0x82>
lea    0xe42(%rip),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    11d0 <displayError+0x60>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe0d(%rip),%rdi
call   1030 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <pause@plt>
jmp    1210 <displayError+0xa0>

LLVM IR (-O0):
@.str = [10 x i8] c"Failure:\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [24 x i8] c"Installer terminating.\0A\00"
define void @displayError(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [1024 x i8]
%5 = alloca i8*
store i8* %0, i8** %2
%6 = call i32 (...) @clearScreen()
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %2
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %3
br label %10
10: ; preds = %15, %1
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%12 = load i32*, i32** %3
%13 = call i8* @fgets(i8* %11, i32 1024, i32* %12)
store i8* %13, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i8*, i8** %5
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %10
18: ; preds = %10
%19 = load i32*, i32** %3
%20 = call i32 @fclose(i32* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %18, %22
%23 = call i32 (...) @pause()
br label %22
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@str = [9 x i8] c"Failure:\00"
@str.4 = [23 x i8] c"Installer terminating.\00"
define void @displayError(i8* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = tail call i32 (...) @clearScreen()
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%7 = call i8* @fgets(i8* %6, i32 1024, i32* %5)
%8 = icmp eq i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %1, %9
%10 = phi i8* [ %12, %9 ], [ %7, %1 ]
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = call i8* @fgets(i8* %6, i32 1024, i32* %5)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %9
14: ; preds = %9, %1
%15 = call i32 @fclose(i32* %5)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.4, i64 0, i64 0))
br label %17
17: ; preds = %17, %14
%18 = call i32 (...) @pause()
br label %17
}