#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*/ abort();
int /*<<< orphan*/ fileno(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *);
int /*<<< orphan*/ gzdopen(int /*<<< orphan*/, char const *);
int /*<<< orphan*/ gzopen(char const *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char const *, char *);
scalar_t__ strstr(char const *, char *);
gzFile err_xzopen_core(const char *func, const char *fn, const char *mode) {
  gzFile fp;
  if (strcmp(fn, "-") == 0)
    return gzdopen(fileno((strstr(mode, "r")) ? stdin : stdout), mode);
  if ((fp = gzopen(fn, mode)) == 0) {
    fprintf(stderr, "[%s] fail to open file '%s'. Abort!\n", func, fn);
    abort();
  }
  return fp;
}


x86 assembly (clang, -O0):
<err_xzopen_core>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11f0 <err_xzopen_core+0x80>
mov    -0x20(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     11c9 <err_xzopen_core+0x59>
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
jmp    11d5 <err_xzopen_core+0x65>
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
call   1070 <fileno@plt>
mov    %eax,%edi
mov    -0x20(%rbp),%rsi
call   1040 <gzdopen@plt>
mov    %eax,-0x4(%rbp)
jmp    1233 <err_xzopen_core+0xc3>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <gzopen@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jne    122d <err_xzopen_core+0xbd>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xde3(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<err_xzopen_core>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11a7 <err_xzopen_core+0x37>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <gzopen@plt>
test   %eax,%eax
je     11e1 <err_xzopen_core+0x71>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe54(%rip),%rsi
mov    %r14,%rdi
call   1090 <strstr@plt>
test   %rax,%rax
jne    11c4 <err_xzopen_core+0x54>
mov    0x2e0e(%rip),%rax
jmp    11cb <err_xzopen_core+0x5b>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1070 <fileno@plt>
mov    %eax,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <gzdopen@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    0xe13(%rip),%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@stdout = global i32 0
@stderr = global i32 0
@.str.2 = [37 x i8] c"[%s] fail to open file '%s'. Abort!\0A\00"
define i32 @err_xzopen_core(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %6
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %25
12: ; preds = %3
%13 = load i8*, i8** %7
%14 = call i64 @strstr(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = load i32, i32* @stdin
br label %20
18: ; preds = %12
%19 = load i32, i32* @stdout
br label %20
20: ; preds = %18, %16
%21 = phi i32 [ %17, %16 ], [ %19, %18 ]
%22 = call i32 @fileno(i32 %21)
%23 = load i8*, i8** %7
%24 = call i32 @gzdopen(i32 %22, i8* %23)
store i32 %24, i32* %4
br label %38
25: ; preds = %3
%26 = load i8*, i8** %6
%27 = load i8*, i8** %7
%28 = call i32 @gzopen(i8* %26, i8* %27)
store i32 %28, i32* %8
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %25
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %5
%33 = load i8*, i8** %6
%34 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %32, i8* %33)
%35 = call i32 (...) @abort()
unreachable
36: ; preds = %25
%37 = load i32, i32* %8
store i32 %37, i32* %4
br label %38
38: ; preds = %36, %20
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@stdout = global i32 0
@stderr = global i32 0
@.str.2 = [37 x i8] c"[%s] fail to open file '%s'. Abort!\0A\00"
define i32 @err_xzopen_core(i8* %0, i8* %1, i8* %2) {
%4 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = tail call i64 @strstr(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = load i32, i32* @stdin
%10 = load i32, i32* @stdout
%11 = select i1 %8, i32 %10, i32 %9
%12 = tail call i32 @fileno(i32 %11)
%13 = tail call i32 @gzdopen(i32 %12, i8* %2)
br label %21
14: ; preds = %3
%15 = tail call i32 @gzopen(i8* %1, i8* %2)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
%20 = tail call i32 (...) @abort()
unreachable
21: ; preds = %14, %6
%22 = phi i32 [ %13, %6 ], [ %15, %14 ]
ret i32 %22
}