#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 */
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int avail_in;
  scalar_t__ avail_out;
  unsigned char *next_out;
  unsigned char *next_in;
  int /*<<< orphan*/ *opaque;
  int /*<<< orphan*/ *zfree;
  int /*<<< orphan*/ *zalloc;
};
typedef TYPE_1__ z_stream;
typedef int ssize_t;

/* Variables and functions */
int MAX_WBITS;
int /*<<< orphan*/ Z_FINISH;
scalar_t__ Z_OK;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ inflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ inflateEnd(TYPE_1__ *);
scalar_t__ inflateInit2(TYPE_1__ *, int);
int read(int /*<<< orphan*/, unsigned char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ write(int, unsigned char *, int);
int main(int argc, char *argv[]) {
  z_stream infstream;
  infstream.zalloc = NULL;
  infstream.zfree = NULL;
  infstream.opaque = NULL;
  infstream.avail_in = 0;
  infstream.avail_out = 0;
  if (inflateInit2(&infstream, MAX_WBITS | 32) != Z_OK) {
    fprintf(stderr, "%s: inflateInit2 failed\n", argv[0]);
    return 1;
  };
  while (1) {
    unsigned char buffer[4096];
    ssize_t sz = read(0, buffer, 4096);
    if (sz == 0) {
      infstream.avail_out = 0;
      while (infstream.avail_out == 0) {
        infstream.next_out = buffer;
        infstream.avail_out = 4096;
        inflate(&infstream, Z_FINISH);
        write(1, buffer, 4096 - infstream.avail_out);
      };
      inflateEnd(&infstream);
      return 0;
    };
    if (sz == -1) {
      fprintf(stderr, "%s: read error: %s\n", argv[0], strerror(errno));
      return 1;
    };
    infstream.next_in = buffer;
    infstream.avail_in = sz;
    infstream.avail_out = 0;
    unsigned char outbuf[4096];
    while (infstream.avail_out == 0 && infstream.avail_in != 0) {
      infstream.next_out = outbuf;
      infstream.avail_out = 4096;
      inflate(&infstream, 0);
      write(1, outbuf, 4096 - infstream.avail_out);
    };
  };
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2070,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
mov    0x2e29(%rip),%rax
mov    (%rax),%esi
or     $0x20,%esi
lea    -0x48(%rbp),%rdi
call   1050 <inflateInit2@plt>
mov    0x2e24(%rip),%rcx
cmp    (%rcx),%rax
je     11ff <main+0x8f>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe14(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    138d <main+0x21d>
jmp    1204 <main+0x94>
lea    -0x1050(%rbp),%rsi
xor    %edi,%edi
mov    $0x1000,%edx
call   1060 <read@plt>
mov    %eax,-0x1054(%rbp)
cmpl   $0x0,-0x1054(%rbp)
jne    1298 <main+0x128>
movq   $0x0,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1283 <main+0x113>
lea    -0x1050(%rbp),%rax
mov    %rax,-0x38(%rbp)
movq   $0x1000,-0x40(%rbp)
mov    0x2d69(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdi
call   1030 <inflate@plt>
lea    -0x1050(%rbp),%rsi
mov    $0x1000,%eax
sub    -0x40(%rbp),%rax
mov    %eax,%edx
mov    $0x1,%edi
call   1040 <write@plt>
jmp    1232 <main+0xc2>
lea    -0x48(%rbp),%rdi
call   1080 <inflateEnd@plt>
movl   $0x0,-0x4(%rbp)
jmp    138d <main+0x21d>
cmpl   $0xffffffff,-0x1054(%rbp)
jne    12fa <main+0x18a>
mov    0x2d24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x206c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x2068(%rbp)
mov    0x2cff(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x206c(%rbp),%edi
mov    -0x2068(%rbp),%rdx
mov    %rax,%rcx
lea    0xd32(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    138d <main+0x21d>
lea    -0x1050(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1054(%rbp),%eax
mov    %eax,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x40(%rbp)
mov    %al,-0x206d(%rbp)
jne    1336 <main+0x1c6>
cmpl   $0x0,-0x48(%rbp)
setne  %al
mov    %al,-0x206d(%rbp)
mov    -0x206d(%rbp),%al
test   $0x1,%al
jne    1349 <main+0x1d9>
jmp    1388 <main+0x218>
lea    -0x2060(%rbp),%rax
mov    %rax,-0x38(%rbp)
movq   $0x1000,-0x40(%rbp)
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
call   1030 <inflate@plt>
lea    -0x2060(%rbp),%rsi
mov    $0x1000,%eax
sub    -0x40(%rbp),%rax
mov    %eax,%edx
mov    $0x1,%edi
call   1040 <write@plt>
jmp    1316 <main+0x1a6>
jmp    1204 <main+0x94>
mov    -0x4(%rbp),%eax
add    $0x2070,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2048,%rsp
mov    %rsi,%r14
movl   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x28(%rsp)
movq   $0x0,0x38(%rsp)
mov    0x2e36(%rip),%rax
mov    (%rax),%esi
or     $0x20,%esi
lea    0x8(%rsp),%rdi
call   1050 <inflateInit2@plt>
mov    0x2e30(%rip),%rcx
cmp    (%rcx),%rax
jne    124f <main+0xdf>
lea    0x1040(%rsp),%r15
lea    0x40(%rsp),%rbx
lea    0x8(%rsp),%r12
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r15,%rsi
mov    $0x1000,%edx
call   1060 <read@plt>
cmp    $0xffffffff,%eax
je     126b <main+0xfb>
test   %eax,%eax
je     12a2 <main+0x132>
mov    %r15,0x20(%rsp)
mov    %eax,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,0x18(%rsp)
movq   $0x1000,0x10(%rsp)
mov    %r12,%rdi
xor    %esi,%esi
call   1030 <inflate@plt>
mov    $0x1000,%edx
sub    0x10(%rsp),%edx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1040 <write@plt>
cmpq   $0x0,0x10(%rsp)
jne    11e0 <main+0x70>
cmpl   $0x0,0x8(%rsp)
jne    1210 <main+0xa0>
jmp    11e0 <main+0x70>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd9e(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    129b <main+0x12b>
mov    0x2d5e(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%r14
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xd8d(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%eax
jmp    12f3 <main+0x183>
mov    0x2d17(%rip),%r14
lea    0x8(%rsp),%rbx
xchg   %ax,%ax
mov    %r15,0x18(%rsp)
movq   $0x1000,0x10(%rsp)
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <inflate@plt>
mov    $0x1000,%edx
sub    0x10(%rsp),%edx
mov    $0x1,%edi
mov    %r15,%rsi
call   1040 <write@plt>
cmpq   $0x0,0x10(%rsp)
je     12b0 <main+0x140>
lea    0x8(%rsp),%rdi
call   1080 <inflateEnd@plt>
xor    %eax,%eax
add    $0x2048,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, i64, i8*, i8*, i32*, i32*, i32* }
@MAX_WBITS = global i32 0
@Z_OK = global i64 0
@stderr = global i32 0
@.str = [25 x i8] c"%s: inflateInit2 failed\0A\00"
@Z_FINISH = global i32 0
@.str.1 = [20 x i8] c"%s: read error: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.TYPE_5__
%7 = alloca [4096 x i8]
%8 = alloca i32
%9 = alloca [4096 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 6
store i32* null, i32** %10
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 5
store i32* null, i32** %11
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 4
store i32* null, i32** %12
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 0
store i32 0, i32* %13
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 1
store i64 0, i64* %14
%15 = load i32, i32* @MAX_WBITS
%16 = or i32 %15, 32
%17 = call i64 @inflateInit2(%struct.TYPE_5__* %6, i32 %16)
%18 = load i64, i64* @Z_OK
%19 = icmp ne i64 %17, %18
br i1 %19, label %20, label %26
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %24)
store i32 1, i32* %3
br label %91
26: ; preds = %2
br label %27
27: ; preds = %26, %90
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%29 = call i32 @read(i32 0, i8* %28, i32 4096)
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %52
32: ; preds = %27
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 1
store i64 0, i64* %33
br label %34
34: ; preds = %38, %32
%35 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 1
%36 = load i64, i64* %35
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %50
38: ; preds = %34
%39 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%40 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 2
store i8* %39, i8** %40
%41 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 1
store i64 4096, i64* %41
%42 = load i32, i32* @Z_FINISH
%43 = call i32 @inflate(%struct.TYPE_5__* %6, i32 %42)
%44 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%45 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 1
%46 = load i64, i64* %45
%47 = sub nsw i64 4096, %46
%48 = trunc i64 %47 to i32
%49 = call i32 @write(i32 1, i8* %44, i32 %48)
br label %34
50: ; preds = %34
%51 = call i32 @inflateEnd(%struct.TYPE_5__* %6)
store i32 0, i32* %3
br label %91
52: ; preds = %27
%53 = load i32, i32* %8
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %63
55: ; preds = %52
%56 = load i32, i32* @stderr
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 0
%59 = load i8*, i8** %58
%60 = load i32, i32* @errno
%61 = call i8* @strerror(i32 %60)
%62 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %59, i8* %61)
store i32 1, i32* %3
br label %91
63: ; preds = %52
%64 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%65 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 3
store i8* %64, i8** %65
%66 = load i32, i32* %8
%67 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 0
store i32 %66, i32* %67
%68 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 1
store i64 0, i64* %68
br label %69
69: ; preds = %79, %63
%70 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 1
%71 = load i64, i64* %70
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %77
73: ; preds = %69
%74 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 0
%75 = load i32, i32* %74
%76 = icmp ne i32 %75, 0
br label %77
77: ; preds = %73, %69
%78 = phi i1 [ false, %69 ], [ %76, %73 ]
br i1 %78, label %79, label %90
79: ; preds = %77
%80 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%81 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 2
store i8* %80, i8** %81
%82 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 1
store i64 4096, i64* %82
%83 = call i32 @inflate(%struct.TYPE_5__* %6, i32 0)
%84 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%85 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 1
%86 = load i64, i64* %85
%87 = sub nsw i64 4096, %86
%88 = trunc i64 %87 to i32
%89 = call i32 @write(i32 1, i8* %84, i32 %88)
br label %69
90: ; preds = %77
br label %27
91: ; preds = %55, %50, %20
%92 = load i32, i32* %3
ret i32 %92
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i64, i8*, i8*, i32*, i32*, i32* }
@MAX_WBITS = global i32 0
@Z_OK = global i64 0
@stderr = global i32 0
@.str = [25 x i8] c"%s: inflateInit2 failed\0A\00"
@Z_FINISH = global i32 0
@.str.1 = [20 x i8] c"%s: read error: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.TYPE_5__
%4 = alloca [4096 x i8]
%5 = alloca [4096 x i8]
%6 = bitcast %struct.TYPE_5__* %3 to i8*
%7 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 4
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 0
store i32 0, i32* %8
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1
store i64 0, i64* %9
%10 = bitcast i32** %7 to i8*
%11 = load i32, i32* @MAX_WBITS
%12 = or i32 %11, 32
%13 = call i64 @inflateInit2(%struct.TYPE_5__* %3, i32 %12)
%14 = load i64, i64* @Z_OK
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%18 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 3
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 2
br label %25
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %1
%24 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %23)
br label %59
25: ; preds = %16, %58
%26 = call i32 @read(i32 0, i8* %17, i32 4096)
switch i32 %26, label %44 [
i32 0, label %27
i32 -1, label %38
]
27: ; preds = %25, %27
store i8* %17, i8** %20
store i64 4096, i64* %9
%28 = load i32, i32* @Z_FINISH
%29 = call i32 @inflate(%struct.TYPE_5__* %3, i32 %28)
%30 = load i64, i64* %9
%31 = trunc i64 %30 to i32
%32 = sub i32 4096, %31
%33 = call i32 @write(i32 1, i8* %17, i32 %32)
%34 = load i64, i64* %9
%35 = icmp eq i64 %34, 0
br i1 %35, label %27, label %36
36: ; preds = %27
%37 = call i32 @inflateEnd(%struct.TYPE_5__* %3)
br label %56
38: ; preds = %25
%39 = load i32, i32* @stderr
%40 = load i8*, i8** %1
%41 = load i32, i32* @errno
%42 = call i8* @strerror(i32 %41)
%43 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %40, i8* %42)
br label %56
44: ; preds = %25
store i8* %17, i8** %18
store i32 %26, i32* %8
br label %45
45: ; preds = %44, %45
store i8* %19, i8** %20
store i64 4096, i64* %9
%46 = call i32 @inflate(%struct.TYPE_5__* %3, i32 0)
%47 = load i64, i64* %9
%48 = trunc i64 %47 to i32
%49 = sub i32 4096, %48
%50 = call i32 @write(i32 1, i8* %19, i32 %49)
%51 = load i64, i64* %9
%52 = icmp eq i64 %51, 0
%53 = load i32, i32* %8
%54 = icmp ne i32 %53, 0
%55 = select i1 %52, i1 %54, i1 false
br i1 %55, label %45, label %58
56: ; preds = %38, %36
%57 = phi i32 [ 0, %36 ], [ 1, %38 ]
br label %59
58: ; preds = %45
br label %25
59: ; preds = %56, %21
%60 = phi i32 [ 1, %21 ], [ %57, %56 ]
ret i32 %60
}