#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__ {
  scalar_t__ avail_in;
  char *next_in;
  int avail_out;
  char *next_out;
  void *opaque;
  void *zfree;
  void *zalloc;
};
typedef TYPE_1__ z_stream;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
#define Z_DATA_ERROR 130
int Z_ERRNO;
#define Z_MEM_ERROR 129
#define Z_NEED_DICT 128
int /*<<< orphan*/ Z_NO_FLUSH;
void *Z_NULL;
int Z_OK;
int Z_STREAM_END;
int Z_STREAM_ERROR;
int /*<<< orphan*/ assert(int);
scalar_t__ ferror(int /*<<< orphan*/ *);
scalar_t__ fread(char *, int, int, int /*<<< orphan*/ *);
unsigned int fwrite(char *, int, unsigned int, int /*<<< orphan*/ *);
int inflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ inflateEnd(TYPE_1__ *);
int inflateInit(TYPE_1__ *);
int inf(FILE *source, FILE *dest) {
  int ret;
  unsigned have;
  z_stream strm;
  char in[16384];
  char out[16384];
  strm.zalloc = Z_NULL;
  strm.zfree = Z_NULL;
  strm.opaque = Z_NULL;
  strm.avail_in = 0;
  strm.next_in = Z_NULL;
  ret = inflateInit(&strm);
  if (ret != Z_OK)
    return ret;
  do {
    strm.avail_in = fread(in, 1, 16384, source);
    if (ferror(source)) {
      (void)inflateEnd(&strm);
      return Z_ERRNO;
    }
    if (strm.avail_in == 0)
      break;
    strm.next_in = in;
    do {
      strm.avail_out = 16384;
      strm.next_out = out;
      ret = inflate(&strm, Z_NO_FLUSH);
      assert(ret != Z_STREAM_ERROR);
      switch (ret) {
      case Z_NEED_DICT:
        ret = Z_DATA_ERROR;
      case Z_DATA_ERROR:
      case Z_MEM_ERROR:
        (void)inflateEnd(&strm);
        return ret;
      }
      have = 16384 - strm.avail_out;
      if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
        (void)inflateEnd(&strm);
        return Z_ERRNO;
      }
    } while (strm.avail_out == 0);
    assert(strm.avail_in == 0);
  } while (ret != Z_STREAM_END);
  (void)inflateEnd(&strm);
  return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}


x86 assembly (clang, -O0):
<inf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8070,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e2e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e20(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e12(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x58(%rbp)
mov    0x2dfc(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
lea    -0x58(%rbp),%rdi
call   1060 <inflateInit@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e17(%rip),%rcx
cmp    (%rcx),%eax
je     11ec <inf+0x7c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13b8 <inf+0x248>
jmp    11f1 <inf+0x81>
lea    -0x4060(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4000,%edx
call   1050 <fread@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     123c <inf+0xcc>
lea    -0x58(%rbp),%rdi
call   1080 <inflateEnd@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13b8 <inf+0x248>
cmpq   $0x0,-0x58(%rbp)
jne    124c <inf+0xdc>
jmp    1370 <inf+0x200>
lea    -0x4060(%rbp),%rax
mov    %rax,-0x50(%rbp)
movl   $0x4000,-0x48(%rbp)
lea    -0x8060(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x2d50(%rip),%rax
mov    (%rax),%esi
lea    -0x58(%rbp),%rdi
call   1030 <inflate@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d40(%rip),%rcx
mov    (%rcx),%ecx
sub    %ecx,%eax
setne  %al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x8064(%rbp)
sub    $0x80,%eax
je     12c9 <inf+0x159>
jmp    12b0 <inf+0x140>
mov    -0x8064(%rbp),%eax
add    $0xffffff7f,%eax
sub    $0x2,%eax
jb     12d0 <inf+0x160>
jmp    12e4 <inf+0x174>
movl   $0x82,-0x1c(%rbp)
lea    -0x58(%rbp),%rdi
call   1080 <inflateEnd@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13b8 <inf+0x248>
mov    $0x4000,%eax
sub    -0x48(%rbp),%eax
mov    %eax,-0x20(%rbp)
lea    -0x8060(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1090 <fwrite@plt>
cmp    -0x20(%rbp),%eax
jne    1323 <inf+0x1b3>
mov    -0x18(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     133d <inf+0x1cd>
lea    -0x58(%rbp),%rdi
call   1080 <inflateEnd@plt>
mov    0x2ca5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13b8 <inf+0x248>
jmp    1342 <inf+0x1d2>
cmpl   $0x0,-0x48(%rbp)
je     1257 <inf+0xe7>
cmpq   $0x0,-0x58(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x1c(%rbp),%eax
mov    0x2c78(%rip),%rcx
cmp    (%rcx),%eax
jne    11f1 <inf+0x81>
lea    -0x58(%rbp),%rdi
call   1080 <inflateEnd@plt>
mov    -0x1c(%rbp),%eax
mov    0x2c5d(%rip),%rcx
cmp    (%rcx),%eax
jne    139f <inf+0x22f>
mov    0x2c5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8068(%rbp)
jmp    13af <inf+0x23f>
mov    $0x82,%eax
mov    %eax,-0x8068(%rbp)
jmp    13af <inf+0x23f>
mov    -0x8068(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x8070,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8048,%rsp
mov    %rsi,%r14
mov    %rdi,0x38(%rsp)
mov    0x2e28(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x30(%rsp)
mov    %rax,0x28(%rsp)
mov    %rax,0x20(%rsp)
movq   $0x0,(%rsp)
mov    %rax,0x8(%rsp)
mov    %rsp,%rdi
call   1060 <inflateInit@plt>
mov    %eax,%ebx
mov    0x2e30(%rip),%rax
cmp    (%rax),%ebx
jne    1304 <inf+0x194>
lea    0x4040(%rsp),%r12
lea    0x40(%rsp),%r13
mov    %r12,%r15
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4000,%edx
mov    0x38(%rsp),%rbp
mov    %rbp,%rcx
call   1050 <fread@plt>
mov    %rax,%r12
mov    %rax,(%rsp)
mov    %rbp,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    12dd <inf+0x16d>
test   %r12,%r12
je     12bc <inf+0x14c>
mov    %r15,%r12
mov    %r15,0x8(%rsp)
mov    0x2d9e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movl   $0x4000,0x10(%rsp)
mov    %r13,0x18(%rsp)
mov    (%r15),%esi
mov    %rsp,%rdi
call   1030 <inflate@plt>
mov    %eax,%ebx
xor    %edi,%edi
mov    0x2d75(%rip),%rax
cmp    (%rax),%ebx
setne  %dil
call   1070 <assert@plt>
lea    -0x80(%rbx),%eax
cmp    $0x2,%eax
jbe    12f0 <inf+0x180>
mov    $0x4000,%ebp
sub    0x10(%rsp),%ebp
mov    %r13,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   1090 <fwrite@plt>
cmp    %ebp,%eax
jne    12dd <inf+0x16d>
mov    %r14,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    12dd <inf+0x16d>
cmpl   $0x0,0x10(%rsp)
je     1230 <inf+0xc0>
xor    %edi,%edi
cmpq   $0x0,(%rsp)
sete   %dil
call   1070 <assert@plt>
mov    0x2d2c(%rip),%rax
cmp    (%rax),%ebx
jne    11d5 <inf+0x65>
mov    %rsp,%rdi
call   1080 <inflateEnd@plt>
mov    0x2d15(%rip),%rax
cmp    (%rax),%ebx
mov    $0x82,%ebx
jne    1304 <inf+0x194>
mov    0x2d15(%rip),%rax
jmp    12ec <inf+0x17c>
mov    %rsp,%rdi
call   1080 <inflateEnd@plt>
mov    0x2cec(%rip),%rax
mov    (%rax),%ebx
jmp    1304 <inf+0x194>
cltq
lea    0xd07(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
mov    %rsp,%rdi
call   1080 <inflateEnd@plt>
mov    %ebx,%eax
add    $0x8048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i64, i8*, i32, i8*, i8*, i8*, i8* }
@Z_NULL = global i8* null
@Z_OK = global i32 0
@Z_ERRNO = global i32 0
@Z_NO_FLUSH = global i32 0
@Z_STREAM_ERROR = global i32 0
@Z_STREAM_END = global i32 0
define i32 @inf(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.TYPE_5__
%9 = alloca [16384 x i8]
%10 = alloca [16384 x i8]
store i32* %0, i32** %4
store i32* %1, i32** %5
%11 = load i8*, i8** @Z_NULL
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 6
store i8* %11, i8** %12
%13 = load i8*, i8** @Z_NULL
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 5
store i8* %13, i8** %14
%15 = load i8*, i8** @Z_NULL
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 4
store i8* %15, i8** %16
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 0
store i64 0, i64* %17
%18 = load i8*, i8** @Z_NULL
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 1
store i8* %18, i8** %19
%20 = call i32 @inflateInit(%struct.TYPE_5__* %8)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = load i32, i32* @Z_OK
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %2
%25 = load i32, i32* %6
store i32 %25, i32* %3
br label %104
26: ; preds = %2
br label %27
27: ; preds = %90, %26
%28 = getelementptr inbounds [16384 x i8], [16384 x i8]* %9, i64 0, i64 0
%29 = load i32*, i32** %4
%30 = call i64 @fread(i8* %28, i32 1, i32 16384, i32* %29)
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 0
store i64 %30, i64* %31
%32 = load i32*, i32** %4
%33 = call i64 @ferror(i32* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %27
%36 = call i32 @inflateEnd(%struct.TYPE_5__* %8)
%37 = load i32, i32* @Z_ERRNO
store i32 %37, i32* %3
br label %104
38: ; preds = %27
%39 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 0
%40 = load i64, i64* %39
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
br label %94
43: ; preds = %38
%44 = getelementptr inbounds [16384 x i8], [16384 x i8]* %9, i64 0, i64 0
%45 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 1
store i8* %44, i8** %45
br label %46
46: ; preds = %80, %43
%47 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 2
store i32 16384, i32* %47
%48 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%49 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 3
store i8* %48, i8** %49
%50 = load i32, i32* @Z_NO_FLUSH
%51 = call i32 @inflate(%struct.TYPE_5__* %8, i32 %50)
store i32 %51, i32* %6
%52 = load i32, i32* %6
%53 = load i32, i32* @Z_STREAM_ERROR
%54 = icmp ne i32 %52, %53
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = load i32, i32* %6
switch i32 %57, label %62 [
i32 128, label %58
i32 130, label %59
i32 129, label %59
]
58: ; preds = %46
store i32 130, i32* %6
br label %59
59: ; preds = %46, %46, %58
%60 = call i32 @inflateEnd(%struct.TYPE_5__* %8)
%61 = load i32, i32* %6
store i32 %61, i32* %3
br label %104
62: ; preds = %46
%63 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 2
%64 = load i32, i32* %63
%65 = sub nsw i32 16384, %64
store i32 %65, i32* %7
%66 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%67 = load i32, i32* %7
%68 = load i32*, i32** %5
%69 = call i32 @fwrite(i8* %66, i32 1, i32 %67, i32* %68)
%70 = load i32, i32* %7
%71 = icmp ne i32 %69, %70
br i1 %71, label %76, label %72
72: ; preds = %62
%73 = load i32*, i32** %5
%74 = call i64 @ferror(i32* %73)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %72, %62
%77 = call i32 @inflateEnd(%struct.TYPE_5__* %8)
%78 = load i32, i32* @Z_ERRNO
store i32 %78, i32* %3
br label %104
79: ; preds = %72
br label %80
80: ; preds = %79
%81 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 2
%82 = load i32, i32* %81
%83 = icmp eq i32 %82, 0
br i1 %83, label %46, label %84
84: ; preds = %80
%85 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 0
%86 = load i64, i64* %85
%87 = icmp eq i64 %86, 0
%88 = zext i1 %87 to i32
%89 = call i32 @assert(i32 %88)
br label %90
90: ; preds = %84
%91 = load i32, i32* %6
%92 = load i32, i32* @Z_STREAM_END
%93 = icmp ne i32 %91, %92
br i1 %93, label %27, label %94
94: ; preds = %90, %42
%95 = call i32 @inflateEnd(%struct.TYPE_5__* %8)
%96 = load i32, i32* %6
%97 = load i32, i32* @Z_STREAM_END
%98 = icmp eq i32 %96, %97
br i1 %98, label %99, label %101
99: ; preds = %94
%100 = load i32, i32* @Z_OK
br label %102
101: ; preds = %94
br label %102
102: ; preds = %101, %99
%103 = phi i32 [ %100, %99 ], [ 130, %101 ]
store i32 %103, i32* %3
br label %104
104: ; preds = %102, %76, %59, %35, %24
%105 = load i32, i32* %3
ret i32 %105
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i64, i8*, i32, i8*, i8*, i8*, i8* }
@Z_NULL = global i8* null
@Z_OK = global i32 0
@Z_ERRNO = global i32 0
@Z_NO_FLUSH = global i32 0
@Z_STREAM_ERROR = global i32 0
@Z_STREAM_END = global i32 0
@switch.table.inf = [3 x i32] [i32 130, i32 129, i32 130]
define i32 @inf(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca %struct.TYPE_5__
%4 = alloca [16384 x i8]
%5 = alloca [16384 x i8]
%6 = bitcast %struct.TYPE_5__* %3 to i8*
%7 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [16384 x i8], [16384 x i8]* %5, i64 0, i64 0
%9 = load i8*, i8** @Z_NULL
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 6
store i8* %9, i8** %10
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 5
store i8* %9, i8** %11
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 4
store i8* %9, i8** %12
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 0
store i64 0, i64* %13
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1
store i8* %9, i8** %14
%15 = call i32 @inflateInit(%struct.TYPE_5__* %3)
%16 = load i32, i32* @Z_OK
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %74
18: ; preds = %2
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 2
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 3
br label %21
21: ; preds = %18, %60
%22 = phi i32 [ %34, %60 ], [ %15, %18 ]
%23 = call i64 @fread(i8* %7, i32 1, i32 16384, i32* %0)
store i64 %23, i64* %13
%24 = call i64 @ferror(i32* %0)
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %21
%27 = call i32 @inflateEnd(%struct.TYPE_5__* %3)
%28 = load i32, i32* @Z_ERRNO
br label %74
29: ; preds = %21
%30 = icmp eq i64 %23, 0
br i1 %30, label %67, label %31
31: ; preds = %29
store i8* %7, i8** %14
br label %32
32: ; preds = %57, %31
store i32 16384, i32* %19
store i8* %8, i8** %20
%33 = load i32, i32* @Z_NO_FLUSH
%34 = call i32 @inflate(%struct.TYPE_5__* %3, i32 %33)
%35 = load i32, i32* @Z_STREAM_ERROR
%36 = icmp ne i32 %34, %35
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = add i32 %34, -128
%40 = icmp ult i32 %39, 3
br i1 %40, label %41, label %46
41: ; preds = %32
%42 = sext i32 %39 to i64
%43 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.inf, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = call i32 @inflateEnd(%struct.TYPE_5__* %3)
br label %74
46: ; preds = %32
%47 = load i32, i32* %19
%48 = sub nsw i32 16384, %47
%49 = call i32 @fwrite(i8* %8, i32 1, i32 %48, i32* %1)
%50 = icmp eq i32 %49, %48
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = call i64 @ferror(i32* %1)
%53 = icmp eq i64 %52, 0
br i1 %53, label %57, label %54
54: ; preds = %51, %46
%55 = call i32 @inflateEnd(%struct.TYPE_5__* %3)
%56 = load i32, i32* @Z_ERRNO
br label %74
57: ; preds = %51
%58 = load i32, i32* %19
%59 = icmp eq i32 %58, 0
br i1 %59, label %32, label %60
60: ; preds = %57
%61 = load i64, i64* %13
%62 = icmp eq i64 %61, 0
%63 = zext i1 %62 to i32
%64 = call i32 @assert(i32 %63)
%65 = load i32, i32* @Z_STREAM_END
%66 = icmp eq i32 %34, %65
br i1 %66, label %67, label %21
67: ; preds = %29, %60
%68 = phi i32 [ %22, %29 ], [ %34, %60 ]
%69 = call i32 @inflateEnd(%struct.TYPE_5__* %3)
%70 = load i32, i32* @Z_STREAM_END
%71 = icmp eq i32 %68, %70
%72 = load i32, i32* @Z_OK
%73 = select i1 %71, i32 %72, i32 130
br label %74
74: ; preds = %2, %67, %54, %41, %26
%75 = phi i32 [ %28, %26 ], [ %73, %67 ], [ %56, %54 ], [ %44, %41 ], [ %15, %2 ]
ret i32 %75
}