#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__ {
  int avail_in;
  int avail_out;
  scalar_t__ total_out;
  int /*<<< orphan*/ *next_out;
  int /*<<< orphan*/ *next_in;
};
typedef TYPE_1__ z_stream;
typedef int u_char;
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ Bytef;

/* Variables and functions */
int /*<<< orphan*/ MAX_WBITS;
int Z_BUF_ERROR;
int /*<<< orphan*/ Z_DEFAULT_STRATEGY;
#define Z_DEFLATED 128
int /*<<< orphan*/ Z_FINISH;
int Z_OK;
int Z_STREAM_END;
int Z_STREAM_ERROR;
int /*<<< orphan*/ Z_SYNC_FLUSH;
int /*<<< orphan*/ assert(int);
unsigned int crc32(unsigned int, int /*<<< orphan*/ *, int);
int deflate(TYPE_1__ *, int /*<<< orphan*/);
int deflateEnd(TYPE_1__ *);
int deflateInit2(TYPE_1__ *, int, int const, int /*<<< orphan*/, int,
                 int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fileRead(char *, long *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char *, long, int, int /*<<< orphan*/ *);
scalar_t__ malloc(long);
int /*<<< orphan*/ memcpy(char *, int *, int);
int /*<<< orphan*/ memset(TYPE_1__ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int main() {
  long length = 0, uoffset = 0, coffset = 0;
  unsigned checksum = 0;
  char *a = fileRead("./test.html", &length);
  z_stream c_strm;
  memset(&c_strm, 0, sizeof(z_stream));
  static u_char gzheader[10] = {0x1f, 0x8b, Z_DEFLATED, 0, 0, 0, 0, 0, 0, 3};
  if (deflateInit2(&c_strm, 9, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) !=
      Z_OK) {
    printf("init fail!!!\n");
    return 0;
  }
  char *b = (char *)malloc(length / 2);
  memcpy(b, gzheader, 10);
  coffset += 10;
  checksum = crc32(0, 0, 0);
  while (uoffset < length) {
    int size = 0;
    if (uoffset + 20480 < length)
      size = 20480;
    else
      size = length - uoffset;
    c_strm.avail_in = size;
    c_strm.next_in = (Bytef *)(a + uoffset);
    checksum = crc32(checksum, (Bytef *)(a + uoffset), size);
    c_strm.avail_out = size;
    c_strm.next_out = (Bytef *)(b + coffset);
    c_strm.total_out = 0;
    int rc = deflate(&c_strm, Z_SYNC_FLUSH);
    uoffset += size;
    assert(rc != Z_STREAM_ERROR);
    if (rc != Z_OK && rc != Z_STREAM_END && rc != Z_BUF_ERROR) {
      (void)deflateEnd(&c_strm);
      printf("deflate fail!!!\n");
      return 0;
    }
    coffset += c_strm.total_out;
  }
  c_strm.total_out = 0;
  int rc = deflate(&c_strm, Z_FINISH);
  rc = deflateEnd(&c_strm);
  coffset += c_strm.total_out;
  b[coffset++] = (char)checksum & 0xff;
  checksum >>= 8;
  b[coffset++] = (char)checksum & 0xff;
  checksum >>= 8;
  b[coffset++] = (char)checksum & 0xff;
  checksum >>= 8;
  b[coffset++] = (char)checksum & 0xff;
  b[coffset++] = (char)length & 0xff;
  length >>= 8;
  b[coffset++] = (char)length & 0xff;
  length >>= 8;
  b[coffset++] = (char)length & 0xff;
  length >>= 8;
  b[coffset++] = (char)length & 0xff;
  FILE *file = fopen("compressed", "w");
  fwrite(b, coffset, 1, file);
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xdfb(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <fileRead@plt>
mov    %rax,-0x30(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
xor    %ecx,%ecx
mov    0x2d9d(%rip),%rax
sub    (%rax),%ecx
mov    0x2d6c(%rip),%rax
mov    (%rax),%r9d
lea    -0x50(%rbp),%rdi
mov    $0x9,%esi
mov    $0x80,%edx
mov    $0x8,%r8d
call   10f0 <deflateInit2@plt>
mov    0x2d99(%rip),%rcx
cmp    (%rcx),%eax
je     1277 <main+0xa7>
lea    0xda6(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15b3 <main+0x3e3>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
lea    0x2df4(%rip),%rsi
mov    $0xa,%edx
call   10a0 <memcpy@plt>
mov    -0x20(%rbp),%rax
add    $0xa,%rax
mov    %rax,-0x20(%rbp)
xor    %edx,%edx
xor    %eax,%eax
mov    %eax,%esi
mov    %edx,%edi
call   1030 <crc32@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    13e6 <main+0x216>
movl   $0x0,-0x5c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x5000,%rax
cmp    -0x10(%rbp),%rax
jge    12f7 <main+0x127>
movl   $0x5000,-0x5c(%rbp)
jmp    1302 <main+0x132>
mov    -0x10(%rbp),%rax
sub    -0x18(%rbp),%rax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
add    -0x18(%rbp),%rsi
mov    -0x5c(%rbp),%edx
call   1030 <crc32@plt>
mov    %eax,-0x24(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x58(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    0x2c8d(%rip),%rax
mov    (%rax),%esi
lea    -0x50(%rbp),%rdi
call   1070 <deflate@plt>
mov    %eax,-0x60(%rbp)
movslq -0x5c(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x60(%rbp),%eax
mov    0x2c49(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x60(%rbp),%eax
mov    0x2c68(%rip),%rcx
cmp    (%rcx),%eax
je     13d5 <main+0x205>
mov    -0x60(%rbp),%eax
mov    0x2c46(%rip),%rcx
cmp    (%rcx),%eax
je     13d5 <main+0x205>
mov    -0x60(%rbp),%eax
mov    0x2c24(%rip),%rcx
cmp    (%rcx),%eax
je     13d5 <main+0x205>
lea    -0x50(%rbp),%rdi
call   10c0 <deflateEnd@plt>
lea    0xc56(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15b3 <main+0x3e3>
mov    -0x48(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    12c2 <main+0xf2>
movq   $0x0,-0x48(%rbp)
mov    0x2bbb(%rip),%rax
mov    (%rax),%esi
lea    -0x50(%rbp),%rdi
call   1070 <deflate@plt>
mov    %eax,-0x64(%rbp)
lea    -0x50(%rbp),%rdi
call   10c0 <deflateEnd@plt>
mov    %eax,-0x64(%rbp)
mov    -0x48(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x58(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x20(%rbp)
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
shr    $0x8,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x58(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x20(%rbp)
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
shr    $0x8,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x58(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x20(%rbp)
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
shr    $0x8,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x58(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x20(%rbp)
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x58(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x20(%rbp)
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
sar    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x58(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x20(%rbp)
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
sar    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x58(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x20(%rbp)
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
sar    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x58(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x20(%rbp)
mov    %dl,(%rax,%rcx,1)
lea    0xaae(%rip),%rdi
lea    0xab2(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x70(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x70(%rbp),%rcx
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    -0x70(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movq   $0x0,0x8(%rsp)
lea    0xe12(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <fileRead@plt>
mov    %rax,0x30(%rsp)
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
mov    0x2dae(%rip),%rax
sub    (%rax),%ebp
mov    0x2d7d(%rip),%rax
mov    (%rax),%r9d
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x80,%edx
mov    %ebp,%ecx
mov    $0x8,%r8d
call   10f0 <deflateInit2@plt>
mov    0x2da9(%rip),%rcx
cmp    (%rcx),%eax
jne    1386 <main+0x1b6>
mov    0x8(%rsp),%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
add    %rax,%rdi
sar    %rdi
call   10b0 <malloc@plt>
mov    %rax,%r12
lea    0x2e20(%rip),%rsi
mov    %rax,%rdi
mov    $0xa,%edx
call   10a0 <memcpy@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <crc32@plt>
mov    %eax,%r13d
mov    0x8(%rsp),%rax
mov    $0xa,%r15d
test   %rax,%rax
jle    1397 <main+0x1c7>
xor    %r14d,%r14d
jmp    12c9 <main+0xf9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %ebx,%rax
add    %rax,%r14
add    0x18(%rsp),%r15
mov    0x8(%rsp),%rax
cmp    %r14,%rax
jle    1397 <main+0x1c7>
lea    0x5000(%r14),%rcx
mov    %eax,%ebx
sub    %r14d,%ebx
cmp    %rax,%rcx
mov    $0x5000,%eax
cmovl  %eax,%ebx
mov    %ebx,0x10(%rsp)
mov    0x30(%rsp),%rax
lea    (%rax,%r14,1),%rsi
mov    %rsi,0x28(%rsp)
mov    %r13d,%edi
mov    %ebx,%edx
call   1040 <crc32@plt>
mov    %eax,%r13d
mov    %ebx,0x14(%rsp)
lea    (%r12,%r15,1),%rax
mov    %rax,0x20(%rsp)
movq   $0x0,0x18(%rsp)
mov    0x2cbc(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdi
call   1070 <deflate@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    0x2c85(%rip),%rax
cmp    (%rax),%ebp
setne  %dil
call   1090 <assert@plt>
mov    0x2cab(%rip),%rax
cmp    (%rax),%ebp
je     12b0 <main+0xe0>
mov    0x2c8c(%rip),%rax
cmp    (%rax),%ebp
je     12b0 <main+0xe0>
mov    0x2c6d(%rip),%rax
cmp    (%rax),%ebp
je     12b0 <main+0xe0>
lea    0x10(%rsp),%rdi
call   10c0 <deflateEnd@plt>
lea    0xc9d(%rip),%rdi
call   1030 <puts@plt>
jmp    1446 <main+0x276>
lea    0xc9c(%rip),%rdi
call   1030 <puts@plt>
jmp    1446 <main+0x276>
movq   $0x0,0x18(%rsp)
mov    0x2c09(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <deflate@plt>
mov    %rbx,%rdi
call   10c0 <deflateEnd@plt>
mov    0x18(%rsp),%rax
lea    (%rax,%r15,1),%rcx
mov    %r13d,(%r12,%rcx,1)
mov    0x8(%rsp),%dl
mov    %dl,0x4(%r12,%rcx,1)
mov    0x8(%rsp),%rdx
sar    $0x8,%rdx
mov    %rdx,0x8(%rsp)
mov    %dl,0x5(%r12,%rcx,1)
mov    0x8(%rsp),%rdx
sar    $0x8,%rdx
mov    %rdx,0x8(%rsp)
mov    %dl,0x6(%r12,%rcx,1)
mov    0x8(%rsp),%rdx
sar    $0x8,%rdx
mov    %rdx,0x8(%rsp)
lea    (%rax,%r15,1),%rbx
add    $0x8,%rbx
mov    %dl,0x7(%r12,%rcx,1)
lea    0xbf0(%rip),%rdi
lea    0xbf4(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbp
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %rax,%rcx
call   10e0 <fwrite@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i32, i32, i64, i32*, i32* }
@.str = [12 x i8] c"./test.html\00"
@main.gzheader = internal global [10 x i32] [i32 31, i32 139, i32 128, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 3]
@MAX_WBITS = global i32 0
@Z_DEFAULT_STRATEGY = global i32 0
@Z_OK = global i32 0
@.str.1 = [14 x i8] c"init fail!!!\0A\00"
@Z_SYNC_FLUSH = global i32 0
@Z_STREAM_ERROR = global i32 0
@Z_STREAM_END = global i32 0
@Z_BUF_ERROR = global i32 0
@.str.2 = [17 x i8] c"deflate fail!!!\0A\00"
@Z_FINISH = global i32 0
@.str.3 = [11 x i8] c"compressed\00"
@.str.4 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.TYPE_6__
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
store i32 0, i32* %1
store i64 0, i64* %2
store i64 0, i64* %3
store i64 0, i64* %4
store i32 0, i32* %5
%13 = call i8* @fileRead(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64* %2)
store i8* %13, i8** %6
%14 = call i32 @memset(%struct.TYPE_6__* %7, i32 0, i32 32)
%15 = load i32, i32* @MAX_WBITS
%16 = sub nsw i32 0, %15
%17 = load i32, i32* @Z_DEFAULT_STRATEGY
%18 = call i32 @deflateInit2(%struct.TYPE_6__* %7, i32 9, i32 128, i32 %16, i32 8, i32 %17)
%19 = load i32, i32* @Z_OK
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %0
%22 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %201
23: ; preds = %0
%24 = load i64, i64* %2
%25 = sdiv i64 %24, 2
%26 = call i64 @malloc(i64 %25)
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %8
%28 = load i8*, i8** %8
%29 = call i32 @memcpy(i8* %28, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @main.gzheader, i64 0, i64 0), i32 10)
%30 = load i64, i64* %4
%31 = add nsw i64 %30, 10
store i64 %31, i64* %4
%32 = call i32 @crc32(i32 0, i32* null, i32 0)
store i32 %32, i32* %5
br label %33
33: ; preds = %96, %23
%34 = load i64, i64* %3
%35 = load i64, i64* %2
%36 = icmp slt i64 %34, %35
br i1 %36, label %37, label %101
37: ; preds = %33
store i32 0, i32* %9
%38 = load i64, i64* %3
%39 = add nsw i64 %38, 20480
%40 = load i64, i64* %2
%41 = icmp slt i64 %39, %40
br i1 %41, label %42, label %43
42: ; preds = %37
store i32 20480, i32* %9
br label %48
43: ; preds = %37
%44 = load i64, i64* %2
%45 = load i64, i64* %3
%46 = sub nsw i64 %44, %45
%47 = trunc i64 %46 to i32
store i32 %47, i32* %9
br label %48
48: ; preds = %43, %42
%49 = load i32, i32* %9
%50 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i32 0, i32 0
store i32 %49, i32* %50
%51 = load i8*, i8** %6
%52 = load i64, i64* %3
%53 = getelementptr inbounds i8, i8* %51, i64 %52
%54 = bitcast i8* %53 to i32*
%55 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i32 0, i32 4
store i32* %54, i32** %55
%56 = load i32, i32* %5
%57 = load i8*, i8** %6
%58 = load i64, i64* %3
%59 = getelementptr inbounds i8, i8* %57, i64 %58
%60 = bitcast i8* %59 to i32*
%61 = load i32, i32* %9
%62 = call i32 @crc32(i32 %56, i32* %60, i32 %61)
store i32 %62, i32* %5
%63 = load i32, i32* %9
%64 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i32 0, i32 1
store i32 %63, i32* %64
%65 = load i8*, i8** %8
%66 = load i64, i64* %4
%67 = getelementptr inbounds i8, i8* %65, i64 %66
%68 = bitcast i8* %67 to i32*
%69 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i32 0, i32 3
store i32* %68, i32** %69
%70 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i32 0, i32 2
store i64 0, i64* %70
%71 = load i32, i32* @Z_SYNC_FLUSH
%72 = call i32 @deflate(%struct.TYPE_6__* %7, i32 %71)
store i32 %72, i32* %10
%73 = load i32, i32* %9
%74 = sext i32 %73 to i64
%75 = load i64, i64* %3
%76 = add nsw i64 %75, %74
store i64 %76, i64* %3
%77 = load i32, i32* %10
%78 = load i32, i32* @Z_STREAM_ERROR
%79 = icmp ne i32 %77, %78
%80 = zext i1 %79 to i32
%81 = call i32 @assert(i32 %80)
%82 = load i32, i32* %10
%83 = load i32, i32* @Z_OK
%84 = icmp ne i32 %82, %83
br i1 %84, label %85, label %96
85: ; preds = %48
%86 = load i32, i32* %10
%87 = load i32, i32* @Z_STREAM_END
%88 = icmp ne i32 %86, %87
br i1 %88, label %89, label %96
89: ; preds = %85
%90 = load i32, i32* %10
%91 = load i32, i32* @Z_BUF_ERROR
%92 = icmp ne i32 %90, %91
br i1 %92, label %93, label %96
93: ; preds = %89
%94 = call i32 @deflateEnd(%struct.TYPE_6__* %7)
%95 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %201
96: ; preds = %89, %85, %48
%97 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i32 0, i32 2
%98 = load i64, i64* %97
%99 = load i64, i64* %4
%100 = add nsw i64 %99, %98
store i64 %100, i64* %4
br label %33
101: ; preds = %33
%102 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i32 0, i32 2
store i64 0, i64* %102
%103 = load i32, i32* @Z_FINISH
%104 = call i32 @deflate(%struct.TYPE_6__* %7, i32 %103)
store i32 %104, i32* %11
%105 = call i32 @deflateEnd(%struct.TYPE_6__* %7)
store i32 %105, i32* %11
%106 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i32 0, i32 2
%107 = load i64, i64* %106
%108 = load i64, i64* %4
%109 = add nsw i64 %108, %107
store i64 %109, i64* %4
%110 = load i32, i32* %5
%111 = trunc i32 %110 to i8
%112 = sext i8 %111 to i32
%113 = and i32 %112, 255
%114 = trunc i32 %113 to i8
%115 = load i8*, i8** %8
%116 = load i64, i64* %4
%117 = add nsw i64 %116, 1
store i64 %117, i64* %4
%118 = getelementptr inbounds i8, i8* %115, i64 %116
store i8 %114, i8* %118
%119 = load i32, i32* %5
%120 = lshr i32 %119, 8
store i32 %120, i32* %5
%121 = load i32, i32* %5
%122 = trunc i32 %121 to i8
%123 = sext i8 %122 to i32
%124 = and i32 %123, 255
%125 = trunc i32 %124 to i8
%126 = load i8*, i8** %8
%127 = load i64, i64* %4
%128 = add nsw i64 %127, 1
store i64 %128, i64* %4
%129 = getelementptr inbounds i8, i8* %126, i64 %127
store i8 %125, i8* %129
%130 = load i32, i32* %5
%131 = lshr i32 %130, 8
store i32 %131, i32* %5
%132 = load i32, i32* %5
%133 = trunc i32 %132 to i8
%134 = sext i8 %133 to i32
%135 = and i32 %134, 255
%136 = trunc i32 %135 to i8
%137 = load i8*, i8** %8
%138 = load i64, i64* %4
%139 = add nsw i64 %138, 1
store i64 %139, i64* %4
%140 = getelementptr inbounds i8, i8* %137, i64 %138
store i8 %136, i8* %140
%141 = load i32, i32* %5
%142 = lshr i32 %141, 8
store i32 %142, i32* %5
%143 = load i32, i32* %5
%144 = trunc i32 %143 to i8
%145 = sext i8 %144 to i32
%146 = and i32 %145, 255
%147 = trunc i32 %146 to i8
%148 = load i8*, i8** %8
%149 = load i64, i64* %4
%150 = add nsw i64 %149, 1
store i64 %150, i64* %4
%151 = getelementptr inbounds i8, i8* %148, i64 %149
store i8 %147, i8* %151
%152 = load i64, i64* %2
%153 = trunc i64 %152 to i8
%154 = sext i8 %153 to i32
%155 = and i32 %154, 255
%156 = trunc i32 %155 to i8
%157 = load i8*, i8** %8
%158 = load i64, i64* %4
%159 = add nsw i64 %158, 1
store i64 %159, i64* %4
%160 = getelementptr inbounds i8, i8* %157, i64 %158
store i8 %156, i8* %160
%161 = load i64, i64* %2
%162 = ashr i64 %161, 8
store i64 %162, i64* %2
%163 = load i64, i64* %2
%164 = trunc i64 %163 to i8
%165 = sext i8 %164 to i32
%166 = and i32 %165, 255
%167 = trunc i32 %166 to i8
%168 = load i8*, i8** %8
%169 = load i64, i64* %4
%170 = add nsw i64 %169, 1
store i64 %170, i64* %4
%171 = getelementptr inbounds i8, i8* %168, i64 %169
store i8 %167, i8* %171
%172 = load i64, i64* %2
%173 = ashr i64 %172, 8
store i64 %173, i64* %2
%174 = load i64, i64* %2
%175 = trunc i64 %174 to i8
%176 = sext i8 %175 to i32
%177 = and i32 %176, 255
%178 = trunc i32 %177 to i8
%179 = load i8*, i8** %8
%180 = load i64, i64* %4
%181 = add nsw i64 %180, 1
store i64 %181, i64* %4
%182 = getelementptr inbounds i8, i8* %179, i64 %180
store i8 %178, i8* %182
%183 = load i64, i64* %2
%184 = ashr i64 %183, 8
store i64 %184, i64* %2
%185 = load i64, i64* %2
%186 = trunc i64 %185 to i8
%187 = sext i8 %186 to i32
%188 = and i32 %187, 255
%189 = trunc i32 %188 to i8
%190 = load i8*, i8** %8
%191 = load i64, i64* %4
%192 = add nsw i64 %191, 1
store i64 %192, i64* %4
%193 = getelementptr inbounds i8, i8* %190, i64 %191
store i8 %189, i8* %193
%194 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %194, i32** %12
%195 = load i8*, i8** %8
%196 = load i64, i64* %4
%197 = load i32*, i32** %12
%198 = call i32 @fwrite(i8* %195, i64 %196, i32 1, i32* %197)
%199 = load i32*, i32** %12
%200 = call i32 @fclose(i32* %199)
store i32 0, i32* %1
br label %201
201: ; preds = %101, %93, %21
%202 = load i32, i32* %1
ret i32 %202
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i32, i32, i64, i32*, i32* }
@.str = [12 x i8] c"./test.html\00"
@main.gzheader = internal global [10 x i32] [i32 31, i32 139, i32 128, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 3]
@MAX_WBITS = global i32 0
@Z_DEFAULT_STRATEGY = global i32 0
@Z_OK = global i32 0
@Z_SYNC_FLUSH = global i32 0
@Z_STREAM_ERROR = global i32 0
@Z_STREAM_END = global i32 0
@Z_BUF_ERROR = global i32 0
@Z_FINISH = global i32 0
@.str.3 = [11 x i8] c"compressed\00"
@.str.4 = [2 x i8] c"w\00"
@str = [16 x i8] c"deflate fail!!!\00"
@str.5 = [13 x i8] c"init fail!!!\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca %struct.TYPE_6__
%3 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%4 = call i8* @fileRead(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64* %1)
%5 = bitcast %struct.TYPE_6__* %2 to i8*
%6 = call i32 @memset(%struct.TYPE_6__* %2, i32 0, i32 32)
%7 = load i32, i32* @MAX_WBITS
%8 = sub nsw i32 0, %7
%9 = load i32, i32* @Z_DEFAULT_STRATEGY
%10 = call i32 @deflateInit2(%struct.TYPE_6__* %2, i32 9, i32 128, i32 %8, i32 8, i32 %9)
%11 = load i32, i32* @Z_OK
%12 = icmp eq i32 %10, %11
br i1 %12, label %15, label %13
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0))
br label %116
15: ; preds = %0
%16 = load i64, i64* %1
%17 = sdiv i64 %16, 2
%18 = call i64 @malloc(i64 %17)
%19 = inttoptr i64 %18 to i8*
%20 = call i32 @memcpy(i8* %19, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @main.gzheader, i64 0, i64 0), i32 10)
%21 = call i32 @crc32(i32 0, i32* null, i32 0)
%22 = load i64, i64* %1
%23 = icmp sgt i64 %22, 0
br i1 %23, label %24, label %70
24: ; preds = %15
%25 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %2, i64 0, i32 0
%26 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %2, i64 0, i32 4
%27 = bitcast i32** %26 to i8**
%28 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %2, i64 0, i32 1
%29 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %2, i64 0, i32 3
%30 = bitcast i32** %29 to i8**
%31 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %2, i64 0, i32 2
br label %32
32: ; preds = %24, %63
%33 = phi i64 [ %22, %24 ], [ %68, %63 ]
%34 = phi i64 [ 0, %24 ], [ %65, %63 ]
%35 = phi i64 [ 10, %24 ], [ %67, %63 ]
%36 = phi i32 [ %21, %24 ], [ %44, %63 ]
%37 = add nsw i64 %34, 20480
%38 = icmp slt i64 %37, %33
%39 = sub nsw i64 %33, %34
%40 = trunc i64 %39 to i32
%41 = select i1 %38, i32 20480, i32 %40
store i32 %41, i32* %25
%42 = getelementptr inbounds i8, i8* %4, i64 %34
%43 = bitcast i8* %42 to i32*
store i8* %42, i8** %27
%44 = call i32 @crc32(i32 %36, i32* %43, i32 %41)
store i32 %41, i32* %28
%45 = getelementptr inbounds i8, i8* %19, i64 %35
store i8* %45, i8** %30
store i64 0, i64* %31
%46 = load i32, i32* @Z_SYNC_FLUSH
%47 = call i32 @deflate(%struct.TYPE_6__* %2, i32 %46)
%48 = load i32, i32* @Z_STREAM_ERROR
%49 = icmp ne i32 %47, %48
%50 = zext i1 %49 to i32
%51 = call i32 @assert(i32 %50)
%52 = load i32, i32* @Z_OK
%53 = icmp eq i32 %47, %52
%54 = load i32, i32* @Z_STREAM_END
%55 = icmp eq i32 %47, %54
%56 = select i1 %53, i1 true, i1 %55
%57 = load i32, i32* @Z_BUF_ERROR
%58 = icmp eq i32 %47, %57
%59 = select i1 %56, i1 true, i1 %58
br i1 %59, label %63, label %60
60: ; preds = %32
%61 = call i32 @deflateEnd(%struct.TYPE_6__* %2)
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %116
63: ; preds = %32
%64 = sext i32 %41 to i64
%65 = add nsw i64 %34, %64
%66 = load i64, i64* %31
%67 = add nsw i64 %66, %35
%68 = load i64, i64* %1
%69 = icmp sgt i64 %68, %65
br i1 %69, label %32, label %70
70: ; preds = %63, %15
%71 = phi i32 [ %21, %15 ], [ %44, %63 ]
%72 = phi i64 [ 10, %15 ], [ %67, %63 ]
%73 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %2, i64 0, i32 2
store i64 0, i64* %73
%74 = load i32, i32* @Z_FINISH
%75 = call i32 @deflate(%struct.TYPE_6__* %2, i32 %74)
%76 = call i32 @deflateEnd(%struct.TYPE_6__* %2)
%77 = load i64, i64* %73
%78 = add nsw i64 %77, %72
%79 = trunc i32 %71 to i8
%80 = add nsw i64 %78, 1
%81 = getelementptr inbounds i8, i8* %19, i64 %78
store i8 %79, i8* %81
%82 = lshr i32 %71, 8
%83 = trunc i32 %82 to i8
%84 = add nsw i64 %78, 2
%85 = getelementptr inbounds i8, i8* %19, i64 %80
store i8 %83, i8* %85
%86 = lshr i32 %71, 16
%87 = trunc i32 %86 to i8
%88 = add nsw i64 %78, 3
%89 = getelementptr inbounds i8, i8* %19, i64 %84
store i8 %87, i8* %89
%90 = lshr i32 %71, 24
%91 = trunc i32 %90 to i8
%92 = add nsw i64 %78, 4
%93 = getelementptr inbounds i8, i8* %19, i64 %88
store i8 %91, i8* %93
%94 = load i64, i64* %1
%95 = trunc i64 %94 to i8
%96 = add nsw i64 %78, 5
%97 = getelementptr inbounds i8, i8* %19, i64 %92
store i8 %95, i8* %97
%98 = load i64, i64* %1
%99 = ashr i64 %98, 8
store i64 %99, i64* %1
%100 = trunc i64 %99 to i8
%101 = add nsw i64 %78, 6
%102 = getelementptr inbounds i8, i8* %19, i64 %96
store i8 %100, i8* %102
%103 = load i64, i64* %1
%104 = ashr i64 %103, 8
store i64 %104, i64* %1
%105 = trunc i64 %104 to i8
%106 = add nsw i64 %78, 7
%107 = getelementptr inbounds i8, i8* %19, i64 %101
store i8 %105, i8* %107
%108 = load i64, i64* %1
%109 = ashr i64 %108, 8
store i64 %109, i64* %1
%110 = trunc i64 %109 to i8
%111 = add nsw i64 %78, 8
%112 = getelementptr inbounds i8, i8* %19, i64 %106
store i8 %110, i8* %112
%113 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%114 = call i32 @fwrite(i8* %19, i64 %111, i32 1, i32* %113)
%115 = call i32 @fclose(i32* %113)
br label %116
116: ; preds = %60, %70, %13
ret i32 0
}