#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stdout;
FILE *fileOpen(char *fileName, char *mode) {
  FILE *fp;
  fp = fopen(fileName, mode);
  if (fp == NULL) {
    fprintf(stdout, "Error: Cannot Open the file %s\n", fileName);
    fflush(stdout);
    exit(EXIT_FAILURE);
  }
  return fp;
}


x86 assembly (clang, -O0):
<fileOpen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a1 <fileOpen+0x61>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe80(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fileOpen>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <fopen@plt>
test   %rax,%rax
je     1159 <fileOpen+0x19>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e78(%rip),%r14
mov    (%r14),%edi
lea    0xe96(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    (%r14),%edi
call   1040 <fflush@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [32 x i8] c"Error: Cannot Open the file %s\0A\00"
@EXIT_FAILURE = global i32 0
define i32* @fileOpen(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call i32* @fopen(i8* %6, i8* %7)
store i32* %8, i32** %5
%9 = load i32*, i32** %5
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i32, i32* @stdout
%13 = load i8*, i8** %3
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @stdout
%16 = call i32 @fflush(i32 %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i32*, i32** %5
ret i32* %20
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [32 x i8] c"Error: Cannot Open the file %s\0A\00"
@EXIT_FAILURE = global i32 0
define noalias i32* @fileOpen(i8* %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* %1)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = load i32, i32* @stdout
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = load i32, i32* @stdout
%9 = tail call i32 @fflush(i32 %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
ret i32* %3
}