#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;
  unsigned char *next_in;
  int avail_out;
  unsigned 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;
scalar_t__ ferror(int /*<<< orphan*/ *);
scalar_t__ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int inflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ inflateEnd(TYPE_1__ *);
int inflateInit(TYPE_1__ *);
int inf(FILE *source) {
  int ret;
  unsigned have;
  z_stream strm;
  static unsigned char in[32768];
  static unsigned char out[32768];
  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, 32768, source);
    if (ferror(source)) {
      (void)inflateEnd(&strm);
      return Z_ERRNO;
    }
    if (strm.avail_in == 0)
      break;
    strm.next_in = in;
    do {
      strm.avail_out = 32768;
      strm.next_out = out;
      ret = inflate(&strm, Z_NO_FLUSH);
      switch (ret) {
      case Z_NEED_DICT:
        ret = Z_DATA_ERROR;
      case Z_DATA_ERROR:
      case Z_MEM_ERROR:
        (void)inflateEnd(&strm);
        return ret;
      }
    } while (strm.avail_out == 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    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e5d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e4f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e41(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x50(%rbp)
mov    0x2e2b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
lea    -0x50(%rbp),%rdi
call   1060 <inflateInit@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e3e(%rip),%rcx
cmp    (%rcx),%eax
je     11c5 <inf+0x75>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1303 <inf+0x1b3>
jmp    11ca <inf+0x7a>
mov    -0x10(%rbp),%rcx
lea    0x2e8b(%rip),%rdi
mov    $0x1,%esi
mov    $0x8000,%edx
call   1050 <fread@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     1215 <inf+0xc5>
lea    -0x50(%rbp),%rdi
call   1070 <inflateEnd@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1303 <inf+0x1b3>
cmpq   $0x0,-0x50(%rbp)
jne    1225 <inf+0xd5>
jmp    12c4 <inf+0x174>
lea    0x2e34(%rip),%rax
mov    %rax,-0x48(%rbp)
movl   $0x8000,-0x40(%rbp)
lea    0xae22(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2d7f(%rip),%rax
mov    (%rax),%esi
lea    -0x50(%rbp),%rdi
call   1030 <inflate@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x80,%eax
je     1283 <inf+0x133>
jmp    126d <inf+0x11d>
mov    -0x54(%rbp),%eax
add    $0xffffff7f,%eax
sub    $0x2,%eax
jb     128a <inf+0x13a>
jmp    129e <inf+0x14e>
movl   $0x82,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
call   1070 <inflateEnd@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1303 <inf+0x1b3>
jmp    12a3 <inf+0x153>
cmpl   $0x0,-0x40(%rbp)
je     1230 <inf+0xe0>
jmp    12b2 <inf+0x162>
mov    -0x14(%rbp),%eax
mov    0x2d24(%rip),%rcx
cmp    (%rcx),%eax
jne    11ca <inf+0x7a>
lea    -0x50(%rbp),%rdi
call   1070 <inflateEnd@plt>
mov    -0x14(%rbp),%eax
mov    0x2d09(%rip),%rcx
cmp    (%rcx),%eax
jne    12f0 <inf+0x1a0>
mov    0x2d0a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
jmp    12fd <inf+0x1ad>
mov    $0x82,%eax
mov    %eax,-0x58(%rbp)
jmp    12fd <inf+0x1ad>
mov    -0x58(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbp
mov    0x2e58(%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    0x2e58(%rip),%rax
cmp    (%rax),%ebx
jne    1269 <inf+0x119>
lea    0x2eb9(%rip),%r13
lea    0xaeb2(%rip),%r14
mov    0x2e13(%rip),%r15
mov    %rsp,%r12
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x8000,%edx
mov    %rbp,%rcx
call   1050 <fread@plt>
mov    %rax,%r13
mov    %rax,(%rsp)
mov    %rbp,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    127a <inf+0x12a>
test   %r13,%r13
lea    0x2e71(%rip),%r13
je     1234 <inf+0xe4>
mov    %r13,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
movl   $0x8000,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    (%r15),%esi
mov    %r12,%rdi
call   1030 <inflate@plt>
mov    %eax,%ebx
lea    -0x80(%rbx),%eax
cmp    $0x2,%eax
jbe    1255 <inf+0x105>
cmpl   $0x0,0x10(%rsp)
je     1200 <inf+0xb0>
mov    0x2db0(%rip),%rax
cmp    (%rax),%ebx
jne    11b8 <inf+0x68>
mov    %rsp,%rdi
call   1070 <inflateEnd@plt>
mov    0x2d9d(%rip),%rax
cmp    (%rax),%ebx
mov    $0x82,%ebx
jne    1269 <inf+0x119>
mov    0x2d9d(%rip),%rax
jmp    1289 <inf+0x139>
cltq
lea    0xda2(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
mov    %rsp,%rdi
call   1070 <inflateEnd@plt>
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%rdi
call   1070 <inflateEnd@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%ebx
jmp    1269 <inf+0x119>

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

LLVM IR (-O2):
%struct.TYPE_5__ = type { i64, i8*, i32, i8*, i8*, i8*, i8* }
@inf.in = internal global [32768 x i8] zeroinitializer
@inf.out = internal global [32768 x i8] zeroinitializer
@Z_NULL = global i8* null
@Z_OK = global i32 0
@Z_ERRNO = global i32 0
@Z_NO_FLUSH = 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) {
%2 = alloca %struct.TYPE_5__
%3 = bitcast %struct.TYPE_5__* %2 to i8*
%4 = load i8*, i8** @Z_NULL
%5 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 6
store i8* %4, i8** %5
%6 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 5
store i8* %4, i8** %6
%7 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 4
store i8* %4, i8** %7
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 0
store i64 0, i64* %8
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 1
store i8* %4, i8** %9
%10 = call i32 @inflateInit(%struct.TYPE_5__* %2)
%11 = load i32, i32* @Z_OK
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %50
13: ; preds = %1
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 2
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 3
br label %16
16: ; preds = %13, %40
%17 = phi i32 [ %29, %40 ], [ %10, %13 ]
%18 = call i64 @fread(i8* getelementptr inbounds ([32768 x i8], [32768 x i8]* @inf.in, i64 0, i64 0), i32 1, i32 32768, i32* %0)
store i64 %18, i64* %8
%19 = call i64 @ferror(i32* %0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %16
%22 = call i32 @inflateEnd(%struct.TYPE_5__* %2)
%23 = load i32, i32* @Z_ERRNO
br label %50
24: ; preds = %16
%25 = icmp eq i64 %18, 0
br i1 %25, label %43, label %26
26: ; preds = %24
store i8* getelementptr inbounds ([32768 x i8], [32768 x i8]* @inf.in, i64 0, i64 0), i8** %9
br label %27
27: ; preds = %37, %26
store i32 32768, i32* %14
store i8* getelementptr inbounds ([32768 x i8], [32768 x i8]* @inf.out, i64 0, i64 0), i8** %15
%28 = load i32, i32* @Z_NO_FLUSH
%29 = call i32 @inflate(%struct.TYPE_5__* %2, i32 %28)
%30 = add i32 %29, -128
%31 = icmp ult i32 %30, 3
br i1 %31, label %32, label %37
32: ; preds = %27
%33 = sext i32 %30 to i64
%34 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.inf, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = call i32 @inflateEnd(%struct.TYPE_5__* %2)
br label %50
37: ; preds = %27
%38 = load i32, i32* %14
%39 = icmp eq i32 %38, 0
br i1 %39, label %27, label %40
40: ; preds = %37
%41 = load i32, i32* @Z_STREAM_END
%42 = icmp eq i32 %29, %41
br i1 %42, label %43, label %16
43: ; preds = %24, %40
%44 = phi i32 [ %17, %24 ], [ %29, %40 ]
%45 = call i32 @inflateEnd(%struct.TYPE_5__* %2)
%46 = load i32, i32* @Z_STREAM_END
%47 = icmp eq i32 %44, %46
%48 = load i32, i32* @Z_OK
%49 = select i1 %47, i32 %48, i32 130
br label %50
50: ; preds = %1, %43, %32, %21
%51 = phi i32 [ %23, %21 ], [ %49, %43 ], [ %35, %32 ], [ %10, %1 ]
ret i32 %51
}