#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_6__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  scalar_t__ avail_in;
  char *next_in;
  int avail_out;
  char *next_out;
  int total_out;
};
typedef TYPE_1__ z_stream;
typedef int /*<<< orphan*/ strm;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ Z_DEFAULT_COMPRESSION;
int /*<<< orphan*/ Z_FINISH;
int /*<<< orphan*/ Z_NO_FLUSH;
int Z_OK;
int Z_STREAM_END;
int Z_STREAM_ERROR;
int /*<<< orphan*/ copydata(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *,
                            int, int);
int deflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ deflateEnd(TYPE_1__ *);
int deflateInit(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(TYPE_1__ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *tmpfile();
int compressOrNot(FILE *to, int off_to, FILE *from, int off_from, int len,
                  int forcecompress) {
  char in[(128 * 1024)];
  char out[(128 * 1024)];
  z_stream strm;
  int ret, err = 0;
  int amount;
  FILE *tmp;
  int uncompLen = len;
  if (len == 0)
    return (0);
  fseek(from, off_from, SEEK_SET);
  memset(&strm, 0, sizeof(strm));
  ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION);
  if (ret != Z_OK) {
    fprintf(stderr, "Compression initialization failed.\n");
    return (0);
  }
  tmp = tmpfile();
  do {
    if (len <= 0) {
      (void)deflateEnd(&strm);
      break;
    }
    amount = len;
    if (amount > (128 * 1024))
      amount = (128 * 1024);
    strm.avail_in = fread(in, 1, amount, from);
    len -= strm.avail_in;
    if (ferror(from)) {
      (void)deflateEnd(&strm);
      fprintf(stderr, "IO error.\n");
      break;
    }
    if (strm.avail_in == 0)
      break;
    strm.next_in = in;
    do {
      strm.avail_out = (128 * 1024);
      strm.next_out = out;
      ret = deflate(&strm, len == 0 ? Z_FINISH : Z_NO_FLUSH);
      if (ret == Z_STREAM_ERROR) {
        (void)deflateEnd(&strm);
        fprintf(stderr, "Compression failed somehow.\n");
        err = 1;
        break;
      }
      amount = (128 * 1024) - strm.avail_out;
      if (fwrite(out, 1, amount, tmp) != amount || ferror(tmp)) {
        (void)deflateEnd(&strm);
        fprintf(stderr, "IO Error.\n");
        err = 1;
        break;
      }
    } while (strm.avail_out == 0);
    if (err)
      break;
  } while (ret != Z_STREAM_END);
  (void)deflateEnd(&strm);
  if (strm.total_out >= uncompLen) {
    fclose(tmp);
    copydata(to, off_to, from, off_from, uncompLen);
    return (uncompLen);
  } else {
    copydata(to, off_to, tmp, 0, strm.total_out);
    fclose(tmp);
    return (strm.total_out);
  }
}


x86 assembly (clang, -O0):
<compressOrNot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40080,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movl   $0x0,-0x40060(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x40074(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    120a <compressOrNot+0x4a>
movl   $0x0,-0x4(%rbp)
jmp    1540 <compressOrNot+0x380>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2da8(%rip),%rax
mov    (%rax),%edx
call   10c0 <fseek@plt>
lea    -0x40058(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%esi
lea    -0x40058(%rbp),%rdi
call   10b0 <deflateInit@plt>
mov    %eax,-0x4005c(%rbp)
mov    -0x4005c(%rbp),%eax
mov    0x2d96(%rip),%rcx
cmp    (%rcx),%eax
je     1283 <compressOrNot+0xc3>
mov    0x2d67(%rip),%rax
mov    (%rax),%edi
lea    0xd8e(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1540 <compressOrNot+0x380>
mov    $0x0,%al
call   1080 <tmpfile@plt>
mov    %rax,-0x40070(%rbp)
cmpl   $0x0,-0x28(%rbp)
jg     12ac <compressOrNot+0xec>
lea    -0x40058(%rbp),%rdi
call   10d0 <deflateEnd@plt>
jmp    14bd <compressOrNot+0x2fd>
mov    -0x28(%rbp),%eax
mov    %eax,-0x40064(%rbp)
cmpl   $0x20000,-0x40064(%rbp)
jle    12cf <compressOrNot+0x10f>
movl   $0x20000,-0x40064(%rbp)
lea    -0x20030(%rbp),%rdi
mov    -0x40064(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x40058(%rbp)
mov    -0x40058(%rbp),%rcx
movslq -0x28(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     133b <compressOrNot+0x17b>
lea    -0x40058(%rbp),%rdi
call   10d0 <deflateEnd@plt>
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
lea    0xcf3(%rip),%rsi
call   1090 <fprintf@plt>
jmp    14bd <compressOrNot+0x2fd>
cmpq   $0x0,-0x40058(%rbp)
jne    134e <compressOrNot+0x18e>
jmp    14bd <compressOrNot+0x2fd>
lea    -0x20030(%rbp),%rax
mov    %rax,-0x40050(%rbp)
movl   $0x20000,-0x40048(%rbp)
lea    -0x40030(%rbp),%rax
mov    %rax,-0x40040(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    1392 <compressOrNot+0x1d2>
mov    0x2c23(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40078(%rbp)
jmp    13a1 <compressOrNot+0x1e1>
mov    0x2c1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40078(%rbp)
mov    -0x40078(%rbp),%esi
lea    -0x40058(%rbp),%rdi
call   1060 <deflate@plt>
mov    %eax,-0x4005c(%rbp)
mov    -0x4005c(%rbp),%eax
mov    0x2c02(%rip),%rcx
cmp    (%rcx),%eax
jne    13fe <compressOrNot+0x23e>
lea    -0x40058(%rbp),%rdi
call   10d0 <deflateEnd@plt>
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
lea    0xc45(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x40060(%rbp)
jmp    1491 <compressOrNot+0x2d1>
mov    $0x20000,%eax
sub    -0x40048(%rbp),%eax
mov    %eax,-0x40064(%rbp)
lea    -0x40030(%rbp),%rdi
mov    -0x40064(%rbp),%edx
mov    -0x40070(%rbp),%rcx
mov    $0x1,%esi
call   10e0 <fwrite@plt>
cmp    -0x40064(%rbp),%eax
jne    144f <compressOrNot+0x28f>
mov    -0x40070(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     147f <compressOrNot+0x2bf>
lea    -0x40058(%rbp),%rdi
call   10d0 <deflateEnd@plt>
mov    0x2b6e(%rip),%rax
mov    (%rax),%edi
lea    0xbe1(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x40060(%rbp)
jmp    1491 <compressOrNot+0x2d1>
jmp    1484 <compressOrNot+0x2c4>
cmpl   $0x0,-0x40048(%rbp)
je     135c <compressOrNot+0x19c>
cmpl   $0x0,-0x40060(%rbp)
je     14a3 <compressOrNot+0x2e3>
jmp    14bd <compressOrNot+0x2fd>
jmp    14a8 <compressOrNot+0x2e8>
mov    -0x4005c(%rbp),%eax
mov    0x2b2b(%rip),%rcx
cmp    (%rcx),%eax
jne    1291 <compressOrNot+0xd1>
lea    -0x40058(%rbp),%rdi
call   10d0 <deflateEnd@plt>
mov    -0x40038(%rbp),%eax
cmp    -0x40074(%rbp),%eax
jl     150f <compressOrNot+0x34f>
mov    -0x40070(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x40074(%rbp),%r8d
call   10a0 <copydata@plt>
mov    -0x40074(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1540 <compressOrNot+0x380>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x40070(%rbp),%rdx
mov    -0x40038(%rbp),%r8d
xor    %ecx,%ecx
call   10a0 <copydata@plt>
mov    -0x40070(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x40038(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40080,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compressOrNot>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40058,%rsp
test   %r8d,%r8d
je     1347 <compressOrNot+0x187>
mov    %r8d,%ebx
mov    %ecx,%r12d
mov    %rdx,%r13
mov    %esi,%r15d
mov    %rdi,0x20(%rsp)
mov    0x2dce(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %ecx,%esi
call   10c0 <fseek@plt>
lea    0x28(%rsp),%r14
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x2d95(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   10b0 <deflateInit@plt>
mov    0x2dc4(%rip),%rcx
cmp    (%rcx),%eax
jne    134e <compressOrNot+0x18e>
mov    %r13,0x18(%rsp)
mov    %r12d,0x10(%rsp)
mov    %r15d,0xc(%rsp)
xor    %eax,%eax
call   1080 <tmpfile@plt>
mov    %rax,%r12
lea    0x20050(%rsp),%r15
lea    0x50(%rsp),%r14
mov    %ebx,0x14(%rsp)
mov    %ebx,%r13d
test   %r13d,%r13d
jle    1412 <compressOrNot+0x252>
cmp    $0x20000,%r13d
mov    $0x20000,%edx
cmovb  %r13d,%edx
mov    %r15,%rdi
mov    $0x1,%esi
mov    0x18(%rsp),%rbp
mov    %rbp,%rcx
call   1040 <fread@plt>
mov    %rax,%rbx
mov    %rax,0x28(%rsp)
mov    %rbp,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    141e <compressOrNot+0x25e>
test   %rbx,%rbx
je     13a3 <compressOrNot+0x1e3>
sub    %ebx,%r13d
mov    %r15,%rbp
mov    %r15,0x30(%rsp)
nopl   0x0(%rax)
movl   $0x20000,0x38(%rsp)
mov    %r14,0x40(%rsp)
mov    0x2ce4(%rip),%rax
test   %r13d,%r13d
jne    12e0 <compressOrNot+0x120>
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
lea    0x28(%rsp),%rdi
call   1060 <deflate@plt>
mov    %eax,%r15d
mov    0x2cd2(%rip),%rax
cmp    (%rax),%r15d
je     1384 <compressOrNot+0x1c4>
mov    $0x20000,%ebx
sub    0x38(%rsp),%ebx
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
cmp    %ebx,%eax
jne    1368 <compressOrNot+0x1a8>
mov    %r12,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    1368 <compressOrNot+0x1a8>
cmpl   $0x0,0x38(%rsp)
je     12c0 <compressOrNot+0x100>
mov    0x2ca7(%rip),%rax
cmp    (%rax),%r15d
mov    %rbp,%r15
jne    1261 <compressOrNot+0xa1>
jmp    13a3 <compressOrNot+0x1e3>
xor    %ebp,%ebp
jmp    13fe <compressOrNot+0x23e>
mov    0x2c7b(%rip),%rax
mov    (%rax),%edi
lea    0xca2(%rip),%rsi
call   1090 <fprintf@plt>
jmp    13fe <compressOrNot+0x23e>
lea    0x28(%rsp),%rdi
call   10d0 <deflateEnd@plt>
mov    0x2c57(%rip),%rax
mov    (%rax),%edi
lea    0xcca(%rip),%rsi
jmp    139e <compressOrNot+0x1de>
lea    0x28(%rsp),%rdi
call   10d0 <deflateEnd@plt>
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
lea    0xc91(%rip),%rsi
call   1090 <fprintf@plt>
lea    0x28(%rsp),%rdi
call   10d0 <deflateEnd@plt>
mov    0x48(%rsp),%r8d
mov    0x14(%rsp),%ebp
cmp    %ebp,%r8d
jge    13dc <compressOrNot+0x21c>
mov    0x20(%rsp),%rdi
mov    0xc(%rsp),%esi
mov    %r12,%rdx
xor    %ecx,%ecx
call   10a0 <copydata@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x48(%rsp),%ebp
jmp    13fe <compressOrNot+0x23e>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x20(%rsp),%rdi
mov    0xc(%rsp),%esi
mov    0x18(%rsp),%rdx
mov    0x10(%rsp),%ecx
mov    %ebp,%r8d
call   10a0 <copydata@plt>
mov    %ebp,%eax
add    $0x40058,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x28(%rsp),%rdi
call   10d0 <deflateEnd@plt>
jmp    13a3 <compressOrNot+0x1e3>
lea    0x28(%rsp),%rdi
call   10d0 <deflateEnd@plt>
mov    0x2ba1(%rip),%rax
mov    (%rax),%edi
lea    0xbec(%rip),%rsi
jmp    139e <compressOrNot+0x1de>

LLVM IR (-O0):
%struct.TYPE_6__ = type { i64, i8*, i32, i8*, i32 }
@SEEK_SET = global i32 0
@Z_DEFAULT_COMPRESSION = global i32 0
@Z_OK = global i32 0
@stderr = global i32 0
@.str = [36 x i8] c"Compression initialization failed.\0A\00"
@.str.1 = [11 x i8] c"IO error.\0A\00"
@Z_FINISH = global i32 0
@Z_NO_FLUSH = global i32 0
@Z_STREAM_ERROR = global i32 0
@.str.2 = [29 x i8] c"Compression failed somehow.\0A\00"
@.str.3 = [11 x i8] c"IO Error.\0A\00"
@Z_STREAM_END = global i32 0
define i32 @compressOrNot(i32* %0, i32 %1, i32* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [131072 x i8]
%15 = alloca [131072 x i8]
%16 = alloca %struct.TYPE_6__
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32*
%21 = alloca i32
store i32* %0, i32** %8
store i32 %1, i32* %9
store i32* %2, i32** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 0, i32* %18
%22 = load i32, i32* %12
store i32 %22, i32* %21
%23 = load i32, i32* %12
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %6
store i32 0, i32* %7
br label %158
26: ; preds = %6
%27 = load i32*, i32** %10
%28 = load i32, i32* %11
%29 = load i32, i32* @SEEK_SET
%30 = call i32 @fseek(i32* %27, i32 %28, i32 %29)
%31 = call i32 @memset(%struct.TYPE_6__* %16, i32 0, i32 40)
%32 = load i32, i32* @Z_DEFAULT_COMPRESSION
%33 = call i32 @deflateInit(%struct.TYPE_6__* %16, i32 %32)
store i32 %33, i32* %17
%34 = load i32, i32* %17
%35 = load i32, i32* @Z_OK
%36 = icmp ne i32 %34, %35
br i1 %36, label %37, label %40
37: ; preds = %26
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %158
40: ; preds = %26
%41 = call i32* (...) @tmpfile()
store i32* %41, i32** %20
br label %42
42: ; preds = %127, %40
%43 = load i32, i32* %12
%44 = icmp sle i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 @deflateEnd(%struct.TYPE_6__* %16)
br label %131
47: ; preds = %42
%48 = load i32, i32* %12
store i32 %48, i32* %19
%49 = load i32, i32* %19
%50 = icmp sgt i32 %49, 131072
br i1 %50, label %51, label %52
51: ; preds = %47
store i32 131072, i32* %19
br label %52
52: ; preds = %51, %47
%53 = getelementptr inbounds [131072 x i8], [131072 x i8]* %14, i64 0, i64 0
%54 = load i32, i32* %19
%55 = load i32*, i32** %10
%56 = call i64 @fread(i8* %53, i32 1, i32 %54, i32* %55)
%57 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 0
store i64 %56, i64* %57
%58 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 0
%59 = load i64, i64* %58
%60 = load i32, i32* %12
%61 = sext i32 %60 to i64
%62 = sub nsw i64 %61, %59
%63 = trunc i64 %62 to i32
store i32 %63, i32* %12
%64 = load i32*, i32** %10
%65 = call i64 @ferror(i32* %64)
%66 = icmp ne i64 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %52
%68 = call i32 @deflateEnd(%struct.TYPE_6__* %16)
%69 = load i32, i32* @stderr
%70 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %131
71: ; preds = %52
%72 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 0
%73 = load i64, i64* %72
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %71
br label %131
76: ; preds = %71
%77 = getelementptr inbounds [131072 x i8], [131072 x i8]* %14, i64 0, i64 0
%78 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 1
store i8* %77, i8** %78
br label %79
79: ; preds = %118, %76
%80 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 2
store i32 131072, i32* %80
%81 = getelementptr inbounds [131072 x i8], [131072 x i8]* %15, i64 0, i64 0
%82 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 3
store i8* %81, i8** %82
%83 = load i32, i32* %12
%84 = icmp eq i32 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %79
%86 = load i32, i32* @Z_FINISH
br label %89
87: ; preds = %79
%88 = load i32, i32* @Z_NO_FLUSH
br label %89
89: ; preds = %87, %85
%90 = phi i32 [ %86, %85 ], [ %88, %87 ]
%91 = call i32 @deflate(%struct.TYPE_6__* %16, i32 %90)
store i32 %91, i32* %17
%92 = load i32, i32* %17
%93 = load i32, i32* @Z_STREAM_ERROR
%94 = icmp eq i32 %92, %93
br i1 %94, label %95, label %99
95: ; preds = %89
%96 = call i32 @deflateEnd(%struct.TYPE_6__* %16)
%97 = load i32, i32* @stderr
%98 = call i32 @fprintf(i32 %97, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %18
br label %122
99: ; preds = %89
%100 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 2
%101 = load i32, i32* %100
%102 = sub nsw i32 131072, %101
store i32 %102, i32* %19
%103 = getelementptr inbounds [131072 x i8], [131072 x i8]* %15, i64 0, i64 0
%104 = load i32, i32* %19
%105 = load i32*, i32** %20
%106 = call i32 @fwrite(i8* %103, i32 1, i32 %104, i32* %105)
%107 = load i32, i32* %19
%108 = icmp ne i32 %106, %107
br i1 %108, label %113, label %109
109: ; preds = %99
%110 = load i32*, i32** %20
%111 = call i64 @ferror(i32* %110)
%112 = icmp ne i64 %111, 0
br i1 %112, label %113, label %117
113: ; preds = %109, %99
%114 = call i32 @deflateEnd(%struct.TYPE_6__* %16)
%115 = load i32, i32* @stderr
%116 = call i32 @fprintf(i32 %115, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %18
br label %122
117: ; preds = %109
br label %118
118: ; preds = %117
%119 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 2
%120 = load i32, i32* %119
%121 = icmp eq i32 %120, 0
br i1 %121, label %79, label %122
122: ; preds = %118, %113, %95
%123 = load i32, i32* %18
%124 = icmp ne i32 %123, 0
br i1 %124, label %125, label %126
125: ; preds = %122
br label %131
126: ; preds = %122
br label %127
127: ; preds = %126
%128 = load i32, i32* %17
%129 = load i32, i32* @Z_STREAM_END
%130 = icmp ne i32 %128, %129
br i1 %130, label %42, label %131
131: ; preds = %127, %125, %75, %67, %45
%132 = call i32 @deflateEnd(%struct.TYPE_6__* %16)
%133 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 4
%134 = load i32, i32* %133
%135 = load i32, i32* %21
%136 = icmp sge i32 %134, %135
br i1 %136, label %137, label %147
137: ; preds = %131
%138 = load i32*, i32** %20
%139 = call i32 @fclose(i32* %138)
%140 = load i32*, i32** %8
%141 = load i32, i32* %9
%142 = load i32*, i32** %10
%143 = load i32, i32* %11
%144 = load i32, i32* %21
%145 = call i32 @copydata(i32* %140, i32 %141, i32* %142, i32 %143, i32 %144)
%146 = load i32, i32* %21
store i32 %146, i32* %7
br label %158
147: ; preds = %131
%148 = load i32*, i32** %8
%149 = load i32, i32* %9
%150 = load i32*, i32** %20
%151 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 4
%152 = load i32, i32* %151
%153 = call i32 @copydata(i32* %148, i32 %149, i32* %150, i32 0, i32 %152)
%154 = load i32*, i32** %20
%155 = call i32 @fclose(i32* %154)
%156 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 4
%157 = load i32, i32* %156
store i32 %157, i32* %7
br label %158
158: ; preds = %147, %137, %37, %25
%159 = load i32, i32* %7
ret i32 %159
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i64, i8*, i32, i8*, i32 }
@SEEK_SET = global i32 0
@Z_DEFAULT_COMPRESSION = global i32 0
@Z_OK = global i32 0
@stderr = global i32 0
@.str = [36 x i8] c"Compression initialization failed.\0A\00"
@.str.1 = [11 x i8] c"IO error.\0A\00"
@Z_FINISH = global i32 0
@Z_NO_FLUSH = global i32 0
@Z_STREAM_ERROR = global i32 0
@.str.2 = [29 x i8] c"Compression failed somehow.\0A\00"
@.str.3 = [11 x i8] c"IO Error.\0A\00"
@Z_STREAM_END = global i32 0
define i32 @compressOrNot(i32* %0, i32 %1, i32* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca [131072 x i8]
%8 = alloca [131072 x i8]
%9 = alloca %struct.TYPE_6__
%10 = getelementptr inbounds [131072 x i8], [131072 x i8]* %7, i64 0, i64 0
%11 = getelementptr inbounds [131072 x i8], [131072 x i8]* %8, i64 0, i64 0
%12 = bitcast %struct.TYPE_6__* %9 to i8*
%13 = icmp eq i32 %4, 0
br i1 %13, label %93, label %14
14: ; preds = %6
%15 = load i32, i32* @SEEK_SET
%16 = tail call i32 @fseek(i32* %2, i32 %3, i32 %15)
%17 = call i32 @memset(%struct.TYPE_6__* %9, i32 0, i32 40)
%18 = load i32, i32* @Z_DEFAULT_COMPRESSION
%19 = call i32 @deflateInit(%struct.TYPE_6__* %9, i32 %18)
%20 = load i32, i32* @Z_OK
%21 = icmp eq i32 %19, %20
br i1 %21, label %25, label %22
22: ; preds = %14
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %93
25: ; preds = %14
%26 = call i32* (...) @tmpfile()
%27 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %9, i64 0, i32 0
%28 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %9, i64 0, i32 1
%29 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %9, i64 0, i32 2
%30 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %9, i64 0, i32 3
br label %31
31: ; preds = %78, %25
%32 = phi i32 [ %4, %25 ], [ %41, %78 ]
%33 = icmp slt i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 @deflateEnd(%struct.TYPE_6__* %9)
br label %81
36: ; preds = %31
%37 = icmp ult i32 %32, 131072
%38 = select i1 %37, i32 %32, i32 131072
%39 = call i64 @fread(i8* %10, i32 1, i32 %38, i32* %2)
store i64 %39, i64* %27
%40 = trunc i64 %39 to i32
%41 = sub i32 %32, %40
%42 = call i64 @ferror(i32* %2)
%43 = icmp eq i64 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %36
%45 = call i32 @deflateEnd(%struct.TYPE_6__* %9)
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %81
48: ; preds = %36
%49 = icmp eq i64 %39, 0
br i1 %49, label %81, label %50
50: ; preds = %48
store i8* %10, i8** %28
%51 = icmp eq i32 %41, 0
br label %52
52: ; preds = %75, %50
store i32 131072, i32* %29
store i8* %11, i8** %30
%53 = load i32, i32* @Z_FINISH
%54 = load i32, i32* @Z_NO_FLUSH
%55 = select i1 %51, i32 %53, i32 %54
%56 = call i32 @deflate(%struct.TYPE_6__* %9, i32 %55)
%57 = load i32, i32* @Z_STREAM_ERROR
%58 = icmp eq i32 %56, %57
br i1 %58, label %59, label %63
59: ; preds = %52
%60 = call i32 @deflateEnd(%struct.TYPE_6__* %9)
%61 = load i32, i32* @stderr
%62 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %81
63: ; preds = %52
%64 = load i32, i32* %29
%65 = sub nsw i32 131072, %64
%66 = call i32 @fwrite(i8* %11, i32 1, i32 %65, i32* %26)
%67 = icmp eq i32 %66, %65
br i1 %67, label %68, label %71
68: ; preds = %63
%69 = call i64 @ferror(i32* %26)
%70 = icmp eq i64 %69, 0
br i1 %70, label %75, label %71
71: ; preds = %68, %63
%72 = call i32 @deflateEnd(%struct.TYPE_6__* %9)
%73 = load i32, i32* @stderr
%74 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %81
75: ; preds = %68
%76 = load i32, i32* %29
%77 = icmp eq i32 %76, 0
br i1 %77, label %52, label %78
78: ; preds = %75
%79 = load i32, i32* @Z_STREAM_END
%80 = icmp eq i32 %56, %79
br i1 %80, label %81, label %31
81: ; preds = %48, %78, %59, %71, %44, %34
%82 = call i32 @deflateEnd(%struct.TYPE_6__* %9)
%83 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %9, i64 0, i32 4
%84 = load i32, i32* %83
%85 = icmp slt i32 %84, %4
br i1 %85, label %89, label %86
86: ; preds = %81
%87 = call i32 @fclose(i32* %26)
%88 = call i32 @copydata(i32* %0, i32 %1, i32* %2, i32 %3, i32 %4)
br label %93
89: ; preds = %81
%90 = call i32 @copydata(i32* %0, i32 %1, i32* %26, i32 0, i32 %84)
%91 = call i32 @fclose(i32* %26)
%92 = load i32, i32* %83
br label %93
93: ; preds = %6, %89, %86, %22
%94 = phi i32 [ 0, %22 ], [ %4, %86 ], [ %92, %89 ], [ 0, %6 ]
ret i32 %94
}