#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 scalar_t__ gzFile;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fileno(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ gzbuffer(scalar_t__, int);
scalar_t__ gzdopen(int /*<<< orphan*/, char *);
scalar_t__ gzopen(char const *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
gzFile fastq_open(const char *filename, const char *mode) {
  gzFile fd1;
  if (filename[0] == '-' && filename[1] == '\0') {
    if (mode[0] == 'r') {
      fd1 = gzdopen(fileno(stdin), "rb");
      if (fd1 == 0) {
        {
          fprintf(stderr, "\nERROR: ");
          fprintf(stderr, "Unable to gzdopen stdin");
          fprintf(stderr, "\n");
        };
        exit(1);
      }
    } else {
      fd1 = gzdopen(fileno(stdout), "wb");
      if (fd1 == 0) {
        {
          fprintf(stderr, "\nERROR: ");
          fprintf(stderr, "Unable to gzdopen stdout");
          fprintf(stderr, "\n");
        };
        exit(1);
      }
    }
  } else {
    fd1 = gzopen(filename, mode);
    if (fd1 == 0) {
      {
        fprintf(stderr, "\nERROR: ");
        fprintf(stderr, "Unable to open %s", filename);
        fprintf(stderr, "\n");
      };
      exit(1);
    }
  }
  gzbuffer(fd1, 128000);
  return (fd1);
}


x86 assembly (clang, -O0):
<fastq_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    12a4 <fastq_open+0x144>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    12a4 <fastq_open+0x144>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x72,%eax
jne    1220 <fastq_open+0xc0>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
call   1060 <fileno@plt>
mov    %eax,%edi
lea    0xe48(%rip),%rsi
call   1040 <gzdopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    121b <fastq_open+0xbb>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xe1a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    129f <fastq_open+0x13f>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
call   1060 <fileno@plt>
mov    %eax,%edi
lea    0xdef(%rip),%rsi
call   1040 <gzdopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    129a <fastq_open+0x13a>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
lea    0xda8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
lea    0xdb7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
lea    0xd9b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    129f <fastq_open+0x13f>
jmp    1318 <fastq_open+0x1b8>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <gzopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1313 <fastq_open+0x1b3>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
lea    0xd33(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xd57(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
lea    0xd22(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    1318 <fastq_open+0x1b8>
mov    -0x18(%rbp),%rdi
mov    $0x1f400,%esi
call   1030 <gzbuffer@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fastq_open>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
cmpb   $0x2d,(%rdi)
jne    1173 <fastq_open+0x13>
cmpb   $0x0,0x1(%r14)
je     119f <fastq_open+0x3f>
mov    %r14,%rdi
call   1070 <gzopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     123b <fastq_open+0xdb>
mov    %rbx,%rdi
mov    $0x1f400,%esi
call   1030 <gzbuffer@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
cmpb   $0x72,(%rsi)
jne    11ea <fastq_open+0x8a>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1060 <fileno@plt>
lea    0xe47(%rip),%rsi
mov    %eax,%edi
call   1040 <gzdopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1187 <fastq_open+0x27>
mov    0x2e09(%rip),%rbx
mov    (%rbx),%edi
lea    0xe2b(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe24(%rip),%rsi
jmp    1232 <fastq_open+0xd2>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   1060 <fileno@plt>
lea    0xe27(%rip),%rsi
mov    %eax,%edi
call   1040 <gzdopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1187 <fastq_open+0x27>
mov    0x2dbf(%rip),%rbx
mov    (%rbx),%edi
lea    0xde1(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xdf7(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1265 <fastq_open+0x105>
mov    0x2d96(%rip),%rbx
mov    (%rbx),%edi
lea    0xdb8(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xde7(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xdb6(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [9 x i8] c"\0AERROR: \00"
@.str.2 = [24 x i8] c"Unable to gzdopen stdin\00"
@.str.3 = [2 x i8] c"\0A\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [25 x i8] c"Unable to gzdopen stdout\00"
@.str.6 = [18 x i8] c"Unable to open %s\00"
define i64 @fastq_open(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 45
br i1 %10, label %11, label %54
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %54
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 114
br i1 %22, label %23, label %38
23: ; preds = %17
%24 = load i32, i32* @stdin
%25 = call i32 @fileno(i32 %24)
%26 = call i64 @gzdopen(i32 %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i64 %26, i64* %5
%27 = load i64, i64* %5
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %37
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %23
br label %53
38: ; preds = %17
%39 = load i32, i32* @stdout
%40 = call i32 @fileno(i32 %39)
%41 = call i64 @gzdopen(i32 %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i64 %41, i64* %5
%42 = load i64, i64* %5
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %52
44: ; preds = %38
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %38
br label %53
53: ; preds = %52, %37
br label %70
54: ; preds = %11, %2
%55 = load i8*, i8** %3
%56 = load i8*, i8** %4
%57 = call i64 @gzopen(i8* %55, i8* %56)
store i64 %57, i64* %5
%58 = load i64, i64* %5
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %69
60: ; preds = %54
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%63 = load i32, i32* @stderr
%64 = load i8*, i8** %3
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %64)
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%68 = call i32 @exit(i32 1)
unreachable
69: ; preds = %54
br label %70
70: ; preds = %69, %53
%71 = load i64, i64* %5
%72 = call i32 @gzbuffer(i64 %71, i32 128000)
%73 = load i64, i64* %5
ret i64 %73
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [9 x i8] c"\0AERROR: \00"
@.str.2 = [24 x i8] c"Unable to gzdopen stdin\00"
@.str.3 = [2 x i8] c"\0A\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [25 x i8] c"Unable to gzdopen stdout\00"
@.str.6 = [18 x i8] c"Unable to open %s\00"
define i64 @fastq_open(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 45
br i1 %4, label %5, label %38
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %38
9: ; preds = %5
%10 = load i8, i8* %1
%11 = icmp eq i8 %10, 114
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = load i32, i32* @stdin
%14 = tail call i32 @fileno(i32 %13)
%15 = tail call i64 @gzdopen(i32 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %49
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %9
%26 = load i32, i32* @stdout
%27 = tail call i32 @fileno(i32 %26)
%28 = tail call i64 @gzdopen(i32 %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %49
30: ; preds = %25
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %5, %2
%39 = tail call i64 @gzopen(i8* %0, i8* %1)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %49
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%44 = load i32, i32* @stderr
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %0)
%46 = load i32, i32* @stderr
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%48 = tail call i32 @exit(i32 1)
unreachable
49: ; preds = %38, %12, %25
%50 = phi i64 [ %15, %12 ], [ %28, %25 ], [ %39, %38 ]
%51 = tail call i32 @gzbuffer(i64 %50, i32 128000)
ret i64 %50
}