#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 */

/* Variables and functions */
int /*<<< orphan*/ ferror(int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
void zerr(int ret) {
  fputs("zpipe: ", stderr);
  switch (ret) {
  case (-1):
    if (ferror(stdin))
      fputs("error reading stdin\n", stderr);
    if (ferror(stdout))
      fputs("error writing stdout\n", stderr);
    break;
  case (-2):
    fputs("invalid compression level\n", stderr);
    break;
  case (-3):
    fputs("invalid or incomplete deflate data\n", stderr);
    break;
  case (-4):
    fputs("out of memory\n", stderr);
    break;
  case (-6):
    fputs("zlib version mismatch!\n", stderr);
  }
}


x86 assembly (clang, -O0):
<zerr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%esi
lea    0xedd(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x4(%rbp),%eax
add    $0x6,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     1229 <zerr+0x109>
mov    -0x10(%rbp),%rax
lea    0xea0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%eax
je     1195 <zerr+0x75>
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
lea    0xe90(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%eax
je     11c1 <zerr+0xa1>
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
lea    0xe79(%rip),%rdi
call   1040 <fputs@plt>
jmp    1229 <zerr+0x109>
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
lea    0xe75(%rip),%rdi
call   1040 <fputs@plt>
jmp    1229 <zerr+0x109>
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
lea    0xe76(%rip),%rdi
call   1040 <fputs@plt>
jmp    1229 <zerr+0x109>
mov    0x2dd7(%rip),%rax
mov    (%rax),%esi
lea    0xe80(%rip),%rdi
call   1040 <fputs@plt>
jmp    1229 <zerr+0x109>
mov    0x2dbd(%rip),%rax
mov    (%rax),%esi
lea    0xe75(%rip),%rdi
call   1040 <fputs@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zerr>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2eab(%rip),%r14
mov    (%r14),%esi
lea    0xee1(%rip),%rdi
call   1040 <fputs@plt>
add    $0x6,%ebx
cmp    $0x5,%ebx
ja     11bf <zerr+0x9f>
lea    0xf00(%rip),%rdi
lea    0xeae(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xf37(%rip),%rdi
jmp    11b0 <zerr+0x90>
lea    0xf1f(%rip),%rdi
jmp    11b0 <zerr+0x90>
lea    0xef2(%rip),%rdi
jmp    11b0 <zerr+0x90>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
test   %eax,%eax
je     1197 <zerr+0x77>
mov    (%r14),%esi
lea    0xe8e(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
test   %eax,%eax
je     11bf <zerr+0x9f>
lea    0xe85(%rip),%rdi
mov    (%r14),%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fputs@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"zpipe: \00"
@stderr = global i32 0
@stdin = global i32 0
@.str.1 = [21 x i8] c"error reading stdin\0A\00"
@stdout = global i32 0
@.str.2 = [22 x i8] c"error writing stdout\0A\00"
@.str.3 = [27 x i8] c"invalid compression level\0A\00"
@.str.4 = [36 x i8] c"invalid or incomplete deflate data\0A\00"
@.str.5 = [15 x i8] c"out of memory\0A\00"
@.str.6 = [24 x i8] c"zlib version mismatch!\0A\00"
define void @zerr(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* @stderr
%4 = call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* %2
switch i32 %5, label %33 [
i32 -1, label %6
i32 -2, label %21
i32 -3, label %24
i32 -4, label %27
i32 -6, label %30
]
6: ; preds = %1
%7 = load i32, i32* @stdin
%8 = call i32 @ferror(i32 %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i32, i32* @stderr
%12 = call i32 @fputs(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %10, %6
%14 = load i32, i32* @stdout
%15 = call i32 @ferror(i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = call i32 @fputs(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %17, %13
br label %33
21: ; preds = %1
%22 = load i32, i32* @stderr
%23 = call i32 @fputs(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %33
24: ; preds = %1
%25 = load i32, i32* @stderr
%26 = call i32 @fputs(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %25)
br label %33
27: ; preds = %1
%28 = load i32, i32* @stderr
%29 = call i32 @fputs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %28)
br label %33
30: ; preds = %1
%31 = load i32, i32* @stderr
%32 = call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %1, %27, %24, %21, %20
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"zpipe: \00"
@stderr = global i32 0
@stdin = global i32 0
@.str.1 = [21 x i8] c"error reading stdin\0A\00"
@stdout = global i32 0
@.str.2 = [22 x i8] c"error writing stdout\0A\00"
@.str.3 = [27 x i8] c"invalid compression level\0A\00"
@.str.4 = [36 x i8] c"invalid or incomplete deflate data\0A\00"
@.str.5 = [15 x i8] c"out of memory\0A\00"
@.str.6 = [24 x i8] c"zlib version mismatch!\0A\00"
define void @zerr(i32 %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %2)
switch i32 %0, label %22 [
i32 -1, label %4
i32 -2, label %18
i32 -3, label %15
i32 -4, label %16
i32 -6, label %17
]
4: ; preds = %1
%5 = load i32, i32* @stdin
%6 = tail call i32 @ferror(i32 %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = load i32, i32* @stderr
%10 = tail call i32 @fputs(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %8, %4
%12 = load i32, i32* @stdout
%13 = tail call i32 @ferror(i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %22, label %18
15: ; preds = %1
br label %18
16: ; preds = %1
br label %18
17: ; preds = %1
br label %18
18: ; preds = %1, %11, %15, %16, %17
%19 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), %17 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), %16 ], [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), %15 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), %11 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), %1 ]
%20 = load i32, i32* @stderr
%21 = tail call i32 @fputs(i8* %19, i32 %20)
br label %22
22: ; preds = %18, %11, %1
ret void
}