#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 ssize_t;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int inputFd;
  ssize_t numRead;
  int BUF_SIZE = 89;
  char buf[BUF_SIZE];
  inputFd = open("/net/home/f10/awzurn/zurnCAssignTxt.txt", O_RDONLY);
  if (inputFd == -1) {
    printf("There was an error in opening the file. System will exit!");
    return -1;
  }
  numRead = read(inputFd, buf, BUF_SIZE);
  if (numRead <= BUF_SIZE) {
    fprintf(stdout, "The contents of the file: \n %s \n", buf);
    return 0;
  } else {
    fprintf(stderr, "There was an error in printing the file to the command "
                    "line. System will exit!");
    return -1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x59,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    0x2e5e(%rip),%rax
mov    (%rax),%esi
lea    0xe6d(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11c4 <main+0x84>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    1235 <main+0xf5>
mov    -0x40(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%edx
call   1040 <read@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1210 <main+0xd0>
mov    -0x40(%rbp),%rdx
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    1235 <main+0xf5>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
lea    0xeab(%rip),%rdi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     1191 <main+0x51>
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x59,%edx
call   1040 <read@plt>
cmp    $0x59,%eax
jg     119f <main+0x5f>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xedf(%rip),%rsi
xor    %ebx,%ebx
mov    %rsp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11bb <main+0x7b>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
jmp    11b6 <main+0x76>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xed4(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [40 x i8] c"/net/home/f10/awzurn/zurnCAssignTxt.txt\00"
@O_RDONLY = global i32 0
@.str.1 = [58 x i8] c"There was an error in opening the file. System will exit!\00"
@stdout = global i32 0
@.str.2 = [33 x i8] c"The contents of the file: \0A %s \0A\00"
@stderr = global i32 0
@.str.3 = [79 x i8] c"There was an error in printing the file to the command line. System will exit!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 89, i32* %8
%12 = load i32, i32* %8
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %9
%15 = alloca i8, i64 %13
store i64 %13, i64* %10
%16 = load i32, i32* @O_RDONLY
%17 = call i32 @open(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %11
br label %35
22: ; preds = %2
%23 = load i32, i32* %6
%24 = load i32, i32* %8
%25 = call i32 @read(i32 %23, i8* %15, i32 %24)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = load i32, i32* %8
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %32
29: ; preds = %22
%30 = load i32, i32* @stdout
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %15)
store i32 0, i32* %3
store i32 1, i32* %11
br label %35
32: ; preds = %22
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %11
br label %35
35: ; preds = %32, %29, %20
%36 = load i8*, i8** %9
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [40 x i8] c"/net/home/f10/awzurn/zurnCAssignTxt.txt\00"
@O_RDONLY = global i32 0
@.str.1 = [58 x i8] c"There was an error in opening the file. System will exit!\00"
@stdout = global i32 0
@.str.2 = [33 x i8] c"The contents of the file: \0A %s \0A\00"
@stderr = global i32 0
@.str.3 = [79 x i8] c"There was an error in printing the file to the command line. System will exit!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [89 x i8]
%4 = getelementptr inbounds [89 x i8], [89 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @O_RDONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
br label %19
10: ; preds = %2
%11 = call i32 @read(i32 %6, i8* %4, i32 89)
%12 = icmp slt i32 %11, 90
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* @stdout
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %19
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %16, %13, %8
%20 = phi i32 [ -1, %8 ], [ 0, %13 ], [ -1, %16 ]
ret i32 %20
}