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

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fexists(char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ *gzopen(char const *, char const *);
int /*<<< orphan*/ stderr;
gzFile getGz(const char *fname, const char *mode) {
  if (fexists(fname)) {
    fprintf(stderr, "\t->File exists: %s exiting...\n", fname);
    exit(0);
  }
  gzFile fp;
  if (NULL == (fp = gzopen(fname, mode))) {
    fprintf(stderr, "\t-> Error opening gzFile handle for file:%s exiting\n",
            fname);
    exit(0);
  }
  return fp;
}


x86 assembly (clang, -O0):
<getGz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fexists@plt>
cmp    $0x0,%rax
je     1183 <getGz+0x43>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <gzopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    11c2 <getGz+0x82>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe69(%rip),%rsi
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getGz>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <fexists@plt>
test   %rax,%rax
jne    116c <getGz+0x2c>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <gzopen@plt>
test   %rax,%rax
je     117e <getGz+0x3e>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
jmp    118e <getGz+0x4e>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"\09->File exists: %s exiting...\0A\00"
@.str.1 = [53 x i8] c"\09-> Error opening gzFile handle for file:%s exiting\0A\00"
define i32* @getGz(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 = call i64 @fexists(i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %3
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %2
%15 = load i8*, i8** %3
%16 = load i8*, i8** %4
%17 = call i32* @gzopen(i8* %15, i8* %16)
store i32* %17, i32** %5
%18 = icmp eq i32* null, %17
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %3
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %14
%25 = load i32*, i32** %5
ret i32* %25
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"\09->File exists: %s exiting...\0A\00"
@.str.1 = [53 x i8] c"\09-> Error opening gzFile handle for file:%s exiting\0A\00"
define i32* @getGz(i8* %0, i8* %1) {
%3 = tail call i64 @fexists(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %2
%10 = tail call i32* @gzopen(i8* %0, i8* %1)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%15 = tail call i32 @exit(i32 0)
unreachable
16: ; preds = %9
ret i32* %10
}