#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*/ EINTR;
#define Z_ERRNO 129
#define Z_OK 128
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fatal_error(char *, char *, char const *, char const *);
int /*<<< orphan*/ fatal_error_with_errno(char *, char *, char const *);
char *gzerror(int /*<<< orphan*/, int *);
void check_gzerror(gzFile gzf, bool was_writing, const char *name) {
  int errnum;
  const char *error_str;
  error_str = gzerror(gzf, &errnum);
  switch (errnum) {
  case Z_OK:
    return;
  case Z_ERRNO:
    if (errno == EINTR)
      return;
    fatal_error_with_errno("Error %s \"%s\"",
                           (was_writing ? "writing" : "reading"), name);
  default:
    fatal_error("zlib error %s \"%s\": %s",
                (was_writing ? "writing" : "reading"), name, error_str);
  }
}


x86 assembly (clang, -O0):
<check_gzerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x14(%rbp),%rsi
call   1050 <gzerror@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x80,%eax
je     117b <check_gzerror+0x4b>
jmp    1168 <check_gzerror+0x38>
mov    -0x24(%rbp),%eax
sub    $0x81,%eax
je     1180 <check_gzerror+0x50>
jmp    11c5 <check_gzerror+0x95>
jmp    11f1 <check_gzerror+0xc1>
mov    0x2e59(%rip),%rax
mov    (%rax),%eax
mov    0x2e48(%rip),%rcx
cmp    (%rcx),%eax
jne    119d <check_gzerror+0x6d>
jmp    11f1 <check_gzerror+0xc1>
mov    -0x8(%rbp),%ecx
lea    0xe6f(%rip),%rsi
lea    0xe60(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x10(%rbp),%rdx
lea    0xe40(%rip),%rdi
call   1030 <fatal_error_with_errno@plt>
mov    -0x8(%rbp),%ecx
lea    0xe47(%rip),%rsi
lea    0xe38(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe32(%rip),%rdi
call   1040 <fatal_error@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_gzerror>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %esi,%ebp
lea    0xc(%rsp),%rsi
call   1050 <gzerror@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%eax
cmp    $0x80,%eax
je     11b9 <check_gzerror+0x89>
cmp    $0x81,%eax
jne    1193 <check_gzerror+0x63>
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
mov    0x2e6c(%rip),%rcx
cmp    (%rcx),%eax
je     11b9 <check_gzerror+0x89>
test   %ebp,%ebp
lea    0xe9d(%rip),%rax
lea    0xe8e(%rip),%rsi
cmove  %rax,%rsi
lea    0xe75(%rip),%rdi
mov    %r14,%rdx
call   1030 <fatal_error_with_errno@plt>
test   %ebp,%ebp
lea    0xe7a(%rip),%rax
lea    0xe6b(%rip),%rsi
cmove  %rax,%rsi
lea    0xe70(%rip),%rdi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1040 <fatal_error@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i32 0
@EINTR = global i32 0
@.str = [14 x i8] c"Error %s \22%s\22\00"
@.str.1 = [8 x i8] c"writing\00"
@.str.2 = [8 x i8] c"reading\00"
@.str.3 = [23 x i8] c"zlib error %s \22%s\22: %s\00"
define void @check_gzerror(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i32, i32* %4
%10 = call i8* @gzerror(i32 %9, i32* %7)
store i8* %10, i8** %8
%11 = load i32, i32* %7
switch i32 %11, label %25 [
i32 128, label %12
i32 129, label %13
]
12: ; preds = %3
br label %33
13: ; preds = %3
%14 = load i32, i32* @errno
%15 = load i32, i32* @EINTR
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %13
br label %33
18: ; preds = %13
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%23 = load i8*, i8** %6
%24 = call i32 @fatal_error_with_errno(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %22, i8* %23)
br label %25
25: ; preds = %3, %18
%26 = load i32, i32* %5
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i64
%29 = select i1 %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%30 = load i8*, i8** %6
%31 = load i8*, i8** %8
%32 = call i32 @fatal_error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %29, i8* %30, i8* %31)
br label %33
33: ; preds = %12, %17, %25
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@EINTR = global i32 0
@.str = [14 x i8] c"Error %s \22%s\22\00"
@.str.1 = [8 x i8] c"writing\00"
@.str.2 = [8 x i8] c"reading\00"
@.str.3 = [23 x i8] c"zlib error %s \22%s\22: %s\00"
define void @check_gzerror(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = call i8* @gzerror(i32 %0, i32* %4)
%7 = load i32, i32* %4
switch i32 %7, label %16 [
i32 128, label %20
i32 129, label %8
]
8: ; preds = %3
%9 = load i32, i32* @errno
%10 = load i32, i32* @EINTR
%11 = icmp eq i32 %9, %10
br i1 %11, label %20, label %12
12: ; preds = %8
%13 = icmp eq i32 %1, 0
%14 = select i1 %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
%15 = call i32 @fatal_error_with_errno(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %2)
br label %16
16: ; preds = %3, %12
%17 = icmp eq i32 %1, 0
%18 = select i1 %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
%19 = call i32 @fatal_error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %18, i8* %2, i8* %6)
br label %20
20: ; preds = %8, %3, %16
ret void
}