#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
void *fopen(char *, char *);
void *gzopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int setupInput(char *inputName, void **fileDescriptor, int isZip) {
  if (isZip == 0) {
    (*fileDescriptor) = fopen(inputName, "r");
  } else {
    (*fileDescriptor) = gzopen(inputName, "r");
  }
  if ((*fileDescriptor) == NULL) {
    printf("Sorry!! Not possible to read file: %s \n", inputName);
    printf("Errno:%i \n", errno);
    exit(EXIT_FAILURE);
  }
  return 1;
}


x86 assembly (clang, -O0):
<setupInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    117c <setupInput+0x3c>
mov    -0x8(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1196 <setupInput+0x56>
mov    -0x8(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1040 <gzopen@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11db <setupInput+0x9b>
mov    -0x8(%rbp),%rsi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setupInput>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xeaf(%rip),%rsi
test   %edx,%edx
je     115c <setupInput+0x1c>
call   1040 <gzopen@plt>
jmp    1161 <setupInput+0x21>
call   1050 <fopen@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     1176 <setupInput+0x36>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe85(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%esi
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [40 x i8] c"Sorry!! Not possible to read file: %s \0A\00"
@.str.2 = [11 x i8] c"Errno:%i \0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @setupInput(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = call i8* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = load i8**, i8*** %5
store i8* %11, i8** %12
br label %17
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = call i8* @gzopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = load i8**, i8*** %5
store i8* %15, i8** %16
br label %17
17: ; preds = %13, %9
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i8*, i8** %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @errno
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %17
ret i32 1
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [40 x i8] c"Sorry!! Not possible to read file: %s \0A\00"
@.str.2 = [11 x i8] c"Errno:%i \0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @setupInput(i8* %0, i8** nocapture writeonly %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i8* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %9
7: ; preds = %3
%8 = tail call i8* @gzopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = phi i8* [ %8, %7 ], [ %6, %5 ]
store i8* %10, i8** %1
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%14 = load i32, i32* @errno
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %9
ret i32 1
}