#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 */
size_t Z_ERRNO;
int Z_FINISH;
int Z_NO_FLUSH;
void *Z_NULL;
int Z_OK;
int Z_STREAM_END;
int Z_STREAM_ERROR;
int /*<<< orphan*/ assert(int);
int deflate(TYPE_1__ *, int);
int /*<<< orphan*/ deflateEnd(TYPE_1__ *);
int deflateInit(TYPE_1__ *, int);
scalar_t__ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
scalar_t__ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
unsigned int fwrite(unsigned char *, int, unsigned int, int /*<<< orphan*/ *);
size_t defl(FILE *source, FILE *dest, int level) {
  int ret, flush;
  unsigned have;
  z_stream strm;
  size_t zsize;
  unsigned char in[16384];
  unsigned char out[16384];
  zsize = 0;
  strm.zalloc = Z_NULL;
  strm.zfree = Z_NULL;
  strm.opaque = Z_NULL;
  ret = deflateInit(&strm, level);
  if (ret != Z_OK)
    return ret;
  do {
    strm.avail_in = fread(in, 1, 16384, source);
    if (ferror(source)) {
      (void)deflateEnd(&strm);
      return Z_ERRNO;
    }
    flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
    strm.next_in = in;
    do {
      strm.avail_out = 16384;
      strm.next_out = out;
      ret = deflate(&strm, flush);
      assert(ret != Z_STREAM_ERROR);
      have = 16384 - strm.avail_out;
      if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
        (void)deflateEnd(&strm);
        return Z_ERRNO;
      }
      zsize += have;
    } while (strm.avail_out == 0);
    assert(strm.avail_in == 0);
  } while (flush != Z_FINISH);
  assert(ret == Z_STREAM_END);
  (void)deflateEnd(&strm);
  return zsize;
}


x86 assembly (clang, -O0):
<defl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8080,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movq   $0x0,-0x68(%rbp)
mov    0x2e13(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e05(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2df7(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x1c(%rbp),%esi
lea    -0x60(%rbp),%rdi
call   1080 <deflateInit@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2e0f(%rip),%rcx
cmp    (%rcx),%eax
je     11f6 <defl+0x76>
movslq -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    138a <defl+0x20a>
jmp    11fb <defl+0x7b>
lea    -0x4070(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4000,%edx
call   1040 <fread@plt>
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     1248 <defl+0xc8>
lea    -0x60(%rbp),%rdi
call   1090 <deflateEnd@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    138a <defl+0x20a>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
je     126f <defl+0xef>
mov    0x2d4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8074(%rbp)
jmp    127e <defl+0xfe>
mov    0x2d4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8074(%rbp)
mov    -0x8074(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0x4070(%rbp),%rax
mov    %rax,-0x58(%rbp)
movl   $0x4000,-0x50(%rbp)
lea    -0x8070(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%esi
lea    -0x60(%rbp),%rdi
call   1050 <deflate@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2d0b(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x4000,%eax
sub    -0x50(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x8070(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
cmp    -0x28(%rbp),%eax
jne    130b <defl+0x18b>
mov    -0x18(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     1327 <defl+0x1a7>
lea    -0x60(%rbp),%rdi
call   1090 <deflateEnd@plt>
mov    0x2cbd(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    138a <defl+0x20a>
mov    -0x28(%rbp),%eax
add    -0x68(%rbp),%rax
mov    %rax,-0x68(%rbp)
cmpl   $0x0,-0x50(%rbp)
je     1292 <defl+0x112>
cmpq   $0x0,-0x60(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x24(%rbp),%eax
mov    0x2c58(%rip),%rcx
cmp    (%rcx),%eax
jne    11fb <defl+0x7b>
mov    -0x20(%rbp),%eax
mov    0x2c76(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x60(%rbp),%rdi
call   1090 <deflateEnd@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8080,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<defl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8048,%rsp
mov    %rsi,%r14
mov    %rdi,%rbp
mov    0x2e1a(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x30(%rsp)
mov    %rax,0x28(%rsp)
mov    %rax,0x20(%rsp)
mov    %rsp,%rdi
mov    %edx,%esi
call   1080 <deflateInit@plt>
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%eax
jne    12e1 <defl+0x161>
xor    %ebx,%ebx
lea    0x40(%rsp),%r12
lea    0x4040(%rsp),%r13
mov    %rbp,0x38(%rsp)
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4000,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
mov    %rax,(%rsp)
mov    %rbp,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    12e6 <defl+0x166>
mov    %rbp,%rdi
mov    %r12,%rbp
call   1070 <feof@plt>
mov    0x2d97(%rip),%rcx
test   %rax,%rax
jne    1225 <defl+0xa5>
mov    0x2d9b(%rip),%rcx
mov    (%rcx),%r12d
mov    %rbp,0x8(%rsp)
nopl   (%rax)
movl   $0x4000,0x10(%rsp)
mov    %r13,0x18(%rsp)
mov    %rsp,%rdi
mov    %r12d,%esi
call   1050 <deflate@plt>
mov    %eax,%r15d
xor    %edi,%edi
mov    0x2d74(%rip),%rax
cmp    (%rax),%r15d
setne  %dil
call   1060 <assert@plt>
mov    $0x4000,%ebp
sub    0x10(%rsp),%ebp
mov    %r13,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
cmp    %ebp,%eax
jne    12e6 <defl+0x166>
mov    %r14,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    12e6 <defl+0x166>
mov    %ebp,%eax
add    %rax,%rbx
cmpl   $0x0,0x10(%rsp)
je     1230 <defl+0xb0>
xor    %edi,%edi
cmpq   $0x0,(%rsp)
sete   %dil
call   1060 <assert@plt>
mov    0x2d01(%rip),%rax
cmp    (%rax),%r12d
mov    0x38(%rsp),%rbp
lea    0x40(%rsp),%r12
jne    11dd <defl+0x5d>
mov    0x2d17(%rip),%rax
xor    %edi,%edi
cmp    (%rax),%r15d
sete   %dil
call   1060 <assert@plt>
mov    %rsp,%rdi
call   1090 <deflateEnd@plt>
jmp    12f8 <defl+0x178>
movslq %eax,%rbx
jmp    12f8 <defl+0x178>
mov    %rsp,%rdi
call   1090 <deflateEnd@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rax
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 i64 0
@Z_FINISH = global i32 0
@Z_NO_FLUSH = global i32 0
@Z_STREAM_ERROR = global i32 0
@Z_STREAM_END = global i32 0
define i64 @defl(i32* %0, i32* %1, i32 %2) {
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.TYPE_5__
%12 = alloca i64
%13 = alloca [16384 x i8]
%14 = alloca [16384 x i8]
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i64 0, i64* %12
%15 = load i8*, i8** @Z_NULL
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 6
store i8* %15, i8** %16
%17 = load i8*, i8** @Z_NULL
%18 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 5
store i8* %17, i8** %18
%19 = load i8*, i8** @Z_NULL
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 4
store i8* %19, i8** %20
%21 = load i32, i32* %7
%22 = call i32 @deflateInit(%struct.TYPE_5__* %11, i32 %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = load i32, i32* @Z_OK
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %3
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
store i64 %28, i64* %4
br label %107
29: ; preds = %3
br label %30
30: ; preds = %95, %29
%31 = getelementptr inbounds [16384 x i8], [16384 x i8]* %13, i64 0, i64 0
%32 = load i32*, i32** %5
%33 = call i64 @fread(i8* %31, i32 1, i32 16384, i32* %32)
%34 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 0
store i64 %33, i64* %34
%35 = load i32*, i32** %5
%36 = call i64 @ferror(i32* %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %30
%39 = call i32 @deflateEnd(%struct.TYPE_5__* %11)
%40 = load i64, i64* @Z_ERRNO
store i64 %40, i64* %4
br label %107
41: ; preds = %30
%42 = load i32*, i32** %5
%43 = call i64 @feof(i32* %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = load i32, i32* @Z_FINISH
br label %49
47: ; preds = %41
%48 = load i32, i32* @Z_NO_FLUSH
br label %49
49: ; preds = %47, %45
%50 = phi i32 [ %46, %45 ], [ %48, %47 ]
store i32 %50, i32* %9
%51 = getelementptr inbounds [16384 x i8], [16384 x i8]* %13, i64 0, i64 0
%52 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 1
store i8* %51, i8** %52
br label %53
53: ; preds = %85, %49
%54 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 2
store i32 16384, i32* %54
%55 = getelementptr inbounds [16384 x i8], [16384 x i8]* %14, i64 0, i64 0
%56 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 3
store i8* %55, i8** %56
%57 = load i32, i32* %9
%58 = call i32 @deflate(%struct.TYPE_5__* %11, i32 %57)
store i32 %58, i32* %8
%59 = load i32, i32* %8
%60 = load i32, i32* @Z_STREAM_ERROR
%61 = icmp ne i32 %59, %60
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
%64 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 2
%65 = load i32, i32* %64
%66 = sub nsw i32 16384, %65
store i32 %66, i32* %10
%67 = getelementptr inbounds [16384 x i8], [16384 x i8]* %14, i64 0, i64 0
%68 = load i32, i32* %10
%69 = load i32*, i32** %6
%70 = call i32 @fwrite(i8* %67, i32 1, i32 %68, i32* %69)
%71 = load i32, i32* %10
%72 = icmp ne i32 %70, %71
br i1 %72, label %77, label %73
73: ; preds = %53
%74 = load i32*, i32** %6
%75 = call i64 @ferror(i32* %74)
%76 = icmp ne i64 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %73, %53
%78 = call i32 @deflateEnd(%struct.TYPE_5__* %11)
%79 = load i64, i64* @Z_ERRNO
store i64 %79, i64* %4
br label %107
80: ; preds = %73
%81 = load i32, i32* %10
%82 = zext i32 %81 to i64
%83 = load i64, i64* %12
%84 = add i64 %83, %82
store i64 %84, i64* %12
br label %85
85: ; preds = %80
%86 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 2
%87 = load i32, i32* %86
%88 = icmp eq i32 %87, 0
br i1 %88, label %53, label %89
89: ; preds = %85
%90 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 0
%91 = load i64, i64* %90
%92 = icmp eq i64 %91, 0
%93 = zext i1 %92 to i32
%94 = call i32 @assert(i32 %93)
br label %95
95: ; preds = %89
%96 = load i32, i32* %9
%97 = load i32, i32* @Z_FINISH
%98 = icmp ne i32 %96, %97
br i1 %98, label %30, label %99
99: ; preds = %95
%100 = load i32, i32* %8
%101 = load i32, i32* @Z_STREAM_END
%102 = icmp eq i32 %100, %101
%103 = zext i1 %102 to i32
%104 = call i32 @assert(i32 %103)
%105 = call i32 @deflateEnd(%struct.TYPE_5__* %11)
%106 = load i64, i64* %12
store i64 %106, i64* %4
br label %107
107: ; preds = %99, %77, %38, %26
%108 = load i64, i64* %4
ret i64 %108
}

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