#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*/ Z_DEFAULT_COMPRESSION;
int Z_OK;
int def(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int inf(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ zerr(int);
int main(int argc, char **argv) {
  int ret;
  if (argc == 1) {
    ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION);
    if (ret != Z_OK)
      zerr(ret);
    return ret;
  } else if (argc == 2 && strcmp(argv[1], "-d") == 0) {
    ret = inf(stdin, stdout);
    if (ret != Z_OK)
      zerr(ret);
    return ret;
  } else {
    fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr);
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11b8 <main+0x68>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    0x2e40(%rip),%rax
mov    (%rax),%esi
mov    0x2e3f(%rip),%rax
mov    (%rax),%edx
call   1070 <def@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e53(%rip),%rcx
cmp    (%rcx),%eax
je     11ad <main+0x5d>
mov    -0x14(%rbp),%edi
call   1030 <zerr@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    123b <main+0xeb>
cmpl   $0x2,-0x8(%rbp)
jne    121f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    121f <main+0xcf>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    0x2dd0(%rip),%rax
mov    (%rax),%esi
call   1060 <inf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2dec(%rip),%rcx
cmp    (%rcx),%eax
je     1214 <main+0xc4>
mov    -0x14(%rbp),%edi
call   1030 <zerr@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    123b <main+0xeb>
mov    0x2daa(%rip),%rax
mov    (%rax),%esi
lea    0xdd4(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
je     117d <main+0x2d>
cmp    $0x1,%edi
jne    1192 <main+0x42>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
mov    0x2e55(%rip),%rax
mov    (%rax),%esi
mov    0x2e54(%rip),%rax
mov    (%rax),%edx
call   1070 <def@plt>
jmp    11c5 <main+0x75>
mov    0x8(%rsi),%rdi
lea    0xe78(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ae <main+0x5e>
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
lea    0xe61(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x1,%ebx
jmp    11d9 <main+0x89>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    0x2e02(%rip),%rax
mov    (%rax),%esi
call   1060 <inf@plt>
mov    %eax,%ebx
mov    0x2e22(%rip),%rax
cmp    (%rax),%ebx
je     11d9 <main+0x89>
mov    %ebx,%edi
call   1030 <zerr@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@Z_DEFAULT_COMPRESSION = global i32 0
@Z_OK = global i32 0
@.str = [3 x i8] c"-d\00"
@.str.1 = [41 x i8] c"zpipe usage: zpipe [-d] < source > dest\0A\00"
@stderr = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %22
9: ; preds = %2
%10 = load i32, i32* @stdin
%11 = load i32, i32* @stdout
%12 = load i32, i32* @Z_DEFAULT_COMPRESSION
%13 = call i32 @def(i32 %10, i32 %11, i32 %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = load i32, i32* @Z_OK
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %9
%18 = load i32, i32* %6
%19 = call i32 @zerr(i32 %18)
br label %20
20: ; preds = %17, %9
%21 = load i32, i32* %6
store i32 %21, i32* %3
br label %46
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %43
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %43
31: ; preds = %25
%32 = load i32, i32* @stdin
%33 = load i32, i32* @stdout
%34 = call i32 @inf(i32 %32, i32 %33)
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = load i32, i32* @Z_OK
%37 = icmp ne i32 %35, %36
br i1 %37, label %38, label %41
38: ; preds = %31
%39 = load i32, i32* %6
%40 = call i32 @zerr(i32 %39)
br label %41
41: ; preds = %38, %31
%42 = load i32, i32* %6
store i32 %42, i32* %3
br label %46
43: ; preds = %25, %22
%44 = load i32, i32* @stderr
%45 = call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %44)
store i32 1, i32* %3
br label %46
46: ; preds = %43, %41, %20
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@Z_DEFAULT_COMPRESSION = global i32 0
@Z_OK = global i32 0
@.str = [3 x i8] c"-d\00"
@.str.1 = [41 x i8] c"zpipe usage: zpipe [-d] < source > dest\0A\00"
@stderr = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %25 [
i32 1, label %3
i32 2, label %12
]
3: ; preds = %2
%4 = load i32, i32* @stdin
%5 = load i32, i32* @stdout
%6 = load i32, i32* @Z_DEFAULT_COMPRESSION
%7 = tail call i32 @def(i32 %4, i32 %5, i32 %6)
%8 = load i32, i32* @Z_OK
%9 = icmp eq i32 %7, %8
br i1 %9, label %28, label %10
10: ; preds = %3
%11 = tail call i32 @zerr(i32 %7)
br label %28
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %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 %25
17: ; preds = %12
%18 = load i32, i32* @stdin
%19 = load i32, i32* @stdout
%20 = tail call i32 @inf(i32 %18, i32 %19)
%21 = load i32, i32* @Z_OK
%22 = icmp eq i32 %20, %21
br i1 %22, label %28, label %23
23: ; preds = %17
%24 = tail call i32 @zerr(i32 %20)
br label %28
25: ; preds = %2, %12
%26 = load i32, i32* @stderr
%27 = tail call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %17, %23, %3, %10, %25
%29 = phi i32 [ 1, %25 ], [ %7, %10 ], [ %7, %3 ], [ %20, %23 ], [ %20, %17 ]
ret i32 %29
}