#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*/ *Z_NULL;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ *gzopen(char const *, char const *);
int /*<<< orphan*/ stderr;
size_t strlen(char const *);
gzFile getGz(const char *fname, const char *mode) {
  if (1)
    fprintf(stderr, "doing %s with %s\n", fname, mode);
  int writeFile = 0;
  for (size_t i = 0; i < strlen(mode); i++)
    if (mode[i] == 'w')
      writeFile = 1;
  gzFile fp = Z_NULL;
  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    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jae    11d1 <getGz+0x91>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x77,%eax
jne    11bb <getGz+0x7b>
movl   $0x1,-0x14(%rbp)
jmp    11c0 <getGz+0x80>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    117e <getGz+0x3e>
mov    0x2e00(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <gzopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x28(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1220 <getGz+0xe0>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getGz>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2e9e(%rip),%r15
mov    (%r15),%edi
lea    0xeb4(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <gzopen@plt>
test   %rax,%rax
je     116f <getGz+0x3f>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    (%r15),%edi
lea    0xe99(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"doing %s with %s\0A\00"
@Z_NULL = global i32* null
@.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
%6 = alloca i64
%7 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %3
%10 = load i8*, i8** %4
%11 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10)
store i32 0, i32* %5
store i64 0, i64* %6
br label %12
12: ; preds = %26, %2
%13 = load i64, i64* %6
%14 = load i8*, i8** %4
%15 = call i64 @strlen(i8* %14)
%16 = icmp ult i64 %13, %15
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = load i64, i64* %6
%20 = getelementptr inbounds i8, i8* %18, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 119
br i1 %23, label %24, label %25
24: ; preds = %17
store i32 1, i32* %5
br label %25
25: ; preds = %24, %17
br label %26
26: ; preds = %25
%27 = load i64, i64* %6
%28 = add i64 %27, 1
store i64 %28, i64* %6
br label %12
29: ; preds = %12
%30 = load i32*, i32** @Z_NULL
store i32* %30, i32** %7
%31 = load i8*, i8** %3
%32 = load i8*, i8** %4
%33 = call i32* @gzopen(i8* %31, i8* %32)
store i32* %33, i32** %7
%34 = icmp eq i32* null, %33
br i1 %34, label %35, label %40
35: ; preds = %29
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %3
%38 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %37)
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %29
%41 = load i32*, i32** %7
ret i32* %41
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"doing %s with %s\0A\00"
@Z_NULL = global i32* null
@.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 = load i32, i32* @stderr
%4 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%5 = tail call i32* @gzopen(i8* %0, i8* %1)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %2
ret i32* %5
}