#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_FAILURE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, int,
                           char const *, char *);
int /*<<< orphan*/ *gzopen(char const *, char const *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
gzFile _safeOpen(const char *src, int line, const char *filename,
                 const char *mode) {
  gzFile file = gzopen(filename, mode);
  if (file == NULL) {
    fprintf(stderr, "[%s:%d] Error opening file %s : %s.\n", src, line,
            filename, strerror(errno));
    exit(EXIT_FAILURE);
  }
  return file;
}


x86 assembly (clang, -O0):
<_safeOpen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <gzopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11ce <_safeOpen+0x8e>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%r8
mov    %rax,%r9
lea    0xe45(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x28(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_safeOpen>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %rdi,%rbp
mov    %rdx,%rdi
mov    %rcx,%rsi
call   1040 <gzopen@plt>
test   %rax,%rax
je     116b <_safeOpen+0x2b>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e6e(%rip),%rax
mov    (%rax),%r15d
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe76(%rip),%rsi
mov    %r15d,%edi
mov    %rbp,%rdx
mov    %r14d,%ecx
mov    %rbx,%r8
mov    %rax,%r9
call   1030 <fprintf@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [37 x i8] c"[%s:%d] Error opening file %s : %s.\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32* @_safeOpen(i8* %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = load i8*, i8** %7
%11 = load i8*, i8** %8
%12 = call i32* @gzopen(i8* %10, i8* %11)
store i32* %12, i32** %9
%13 = load i32*, i32** %9
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %25
15: ; preds = %4
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %5
%18 = load i32, i32* %6
%19 = load i8*, i8** %7
%20 = load i32, i32* @errno
%21 = call i8* @strerror(i32 %20)
%22 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %18, i8* %19, i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %4
%26 = load i32*, i32** %9
ret i32* %26
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [37 x i8] c"[%s:%d] Error opening file %s : %s.\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32* @_safeOpen(i8* %0, i32 %1, i8* %2, i8* %3) {
%5 = tail call i32* @gzopen(i8* %2, i8* %3)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i8* %2, i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %4
ret i32* %5
}