#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 */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ DeleteNode(int, int *, int *, int *);
int EOF;
int /*<<< orphan*/ InitTree(int *, int *, int *);
int /*<<< orphan*/ InsertNode(int, int *, int *, int *, int *, int *,
                              unsigned char *);
int /*<<< orphan*/ printf(char *, double);
void Encode(int upper, int part, int offset, char *str_in, char *str_out[],
            int sizes[]) {
  int i, c, len, r, s, last_match_length, code_buf_ptr;
  int match_position, match_length;
  int lson[4096 + 1], rson[4096 + 257], dad[4096 + 1];
  unsigned char text_buf[4096 + 18 - 1];
  unsigned char code_buf[17], mask;
  unsigned long int textsize = 0, textcount = 0, codesize = 0, printcount = 0;
  InitTree(lson, rson, dad);
  code_buf[0] = 0;
  code_buf_ptr = mask = 1;
  s = 0;
  r = 4096 - 18;
  for (i = s; i < r; i++)
    text_buf[i] = ' ';
  for (len = 0; len < 18 && (c = str_in[textcount + offset]) != EOF &&
                ++textcount <= upper;
       len++)
    text_buf[r + len] = c;
  if ((textsize = len) == 0) {
    sizes[part] = 0;
    return;
  }
  for (i = 1; i <= 18; i++)
    InsertNode(r - i, lson, rson, dad, &match_position, &match_length,
               text_buf);
  InsertNode(r, lson, rson, dad, &match_position, &match_length, text_buf);
  do {
    if (match_length > len)
      match_length = len;
    if (match_length <= 2) {
      match_length = 1;
      code_buf[0] |= mask;
      code_buf[code_buf_ptr++] = text_buf[r];
    } else {
      code_buf[code_buf_ptr++] = (unsigned char)match_position + offset;
      code_buf[code_buf_ptr++] =
          (unsigned char)(((match_position + offset >> 4) & 0xf0) |
                          (match_length - (2 + 1)));
    }
    if ((mask <<= 1) == 0) {
      for (i = 0; i < code_buf_ptr; i++)
        str_out[part][codesize + i] = code_buf[i];
      codesize += code_buf_ptr;
      code_buf[0] = 0;
      code_buf_ptr = mask = 1;
    }
    last_match_length = match_length;
    for (i = 0; i < last_match_length &&
                (c = str_in[textcount + offset]) != EOF && ++textcount <= upper;
         i++) {
      DeleteNode(s, lson, rson, dad);
      text_buf[s] = c;
      if (s < 18 - 1)
        text_buf[s + 4096] = c;
      s = (s + 1) & (4096 - 1);
      r = (r + 1) & (4096 - 1);
      InsertNode(r, lson, rson, dad, &match_position, &match_length, text_buf);
    }
    if ((textsize += i) > printcount) {
      printcount += 1024;
    }
    while (i++ < last_match_length) {
      DeleteNode(s, lson, rson, dad);
      s = (s + 1) & (4096 - 1);
      r = (r + 1) & (4096 - 1);
      if (--len)
        InsertNode(r, lson, rson, dad, &match_position, &match_length,
                   text_buf);
    }
  } while (len > 0);
  if (code_buf_ptr > 1) {
    for (i = 0; i < code_buf_ptr; i++)
      str_out[part][codesize + i] = code_buf[i];
    codesize += code_buf_ptr;
  }
  printf("In : %ld bytes\n", textsize);
  printf("Out: %ld bytes\n", codesize);
  printf("Out/In: %.3f\n", (double)codesize / textsize);
  sizes[part] = codesize;
}


x86 assembly (clang, -O0):
<Encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd510,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movq   $0x0,-0xd4c0(%rbp)
movq   $0x0,-0xd4c8(%rbp)
movq   $0x0,-0xd4d0(%rbp)
movq   $0x0,-0xd4d8(%rbp)
lea    -0x4050(%rbp),%rdi
lea    -0x8460(%rbp),%rsi
lea    -0xc470(%rbp),%rdx
call   1040 <InitTree@plt>
movb   $0x0,-0xd4b0(%rbp)
movb   $0x1,-0xd4b1(%rbp)
movl   $0x1,-0x44(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0xfee,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    11f5 <Encode+0xb5>
movslq -0x2c(%rbp),%rax
movb   $0x20,-0xd490(%rbp,%rax,1)
20
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11cf <Encode+0x8f>
movl   $0x0,-0x34(%rbp)
xor    %eax,%eax
cmpl   $0x12,-0x34(%rbp)
mov    %al,-0xd4d9(%rbp)
jge    1260 <Encode+0x120>
mov    -0x18(%rbp),%rax
mov    -0xd4c8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
add    %rdx,%rcx
movsbl (%rax,%rcx,1),%ecx
mov    %ecx,-0x30(%rbp)
xor    %eax,%eax
mov    0x2db8(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0xd4d9(%rbp)
je     1260 <Encode+0x120>
mov    -0xd4c8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xd4c8(%rbp)
movslq -0x4(%rbp),%rcx
cmp    %rcx,%rax
setbe  %al
mov    %al,-0xd4d9(%rbp)
mov    -0xd4d9(%rbp),%al
test   $0x1,%al
jne    1273 <Encode+0x133>
jmp    1295 <Encode+0x155>
mov    -0x30(%rbp),%eax
mov    %al,%cl
mov    -0x38(%rbp),%eax
add    -0x34(%rbp),%eax
cltq
mov    %cl,-0xd490(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11fc <Encode+0xbc>
movslq -0x34(%rbp),%rax
mov    %rax,-0xd4c0(%rbp)
cmp    $0x0,%rax
jne    12be <Encode+0x17e>
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    17c2 <Encode+0x682>
movl   $0x1,-0x2c(%rbp)
cmpl   $0x12,-0x2c(%rbp)
jg     1310 <Encode+0x1d0>
mov    -0x38(%rbp),%edi
sub    -0x2c(%rbp),%edi
lea    -0x4050(%rbp),%rsi
lea    -0x8460(%rbp),%rdx
lea    -0xc470(%rbp),%rcx
lea    -0xd490(%rbp),%rax
lea    -0x48(%rbp),%r8
lea    -0x4c(%rbp),%r9
mov    %rax,(%rsp)
call   1030 <InsertNode@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12c5 <Encode+0x185>
mov    -0x38(%rbp),%edi
lea    -0x4050(%rbp),%rsi
lea    -0x8460(%rbp),%rdx
lea    -0xc470(%rbp),%rcx
lea    -0xd490(%rbp),%rax
lea    -0x48(%rbp),%r8
lea    -0x4c(%rbp),%r9
mov    %rax,(%rsp)
call   1030 <InsertNode@plt>
mov    -0x4c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jle    1352 <Encode+0x212>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x2,-0x4c(%rbp)
jg     139d <Encode+0x25d>
movl   $0x1,-0x4c(%rbp)
movzbl -0xd4b1(%rbp),%ecx
movzbl -0xd4b0(%rbp),%eax
or     %ecx,%eax
mov    %al,-0xd4b0(%rbp)
movslq -0x38(%rbp),%rax
mov    -0xd490(%rbp,%rax,1),%cl
mov    -0x44(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x44(%rbp)
cltq
mov    %cl,-0xd4b0(%rbp,%rax,1)
jmp    13e8 <Encode+0x2a8>
mov    -0x48(%rbp),%eax
movzbl %al,%eax
add    -0xc(%rbp),%eax
mov    %al,%cl
mov    -0x44(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x44(%rbp)
cltq
mov    %cl,-0xd4b0(%rbp,%rax,1)
mov    -0x48(%rbp),%eax
add    -0xc(%rbp),%eax
sar    $0x4,%eax
and    $0xf0,%eax
mov    -0x4c(%rbp),%ecx
sub    $0x3,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x44(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x44(%rbp)
cltq
mov    %cl,-0xd4b0(%rbp,%rax,1)
movzbl -0xd4b1(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0xd4b1(%rbp)
movzbl %al,%eax
cmp    $0x0,%eax
jne    1474 <Encode+0x334>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    144d <Encode+0x30d>
movslq -0x2c(%rbp),%rax
mov    -0xd4b0(%rbp,%rax,1),%dl
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0xd4d0(%rbp),%rcx
movslq -0x2c(%rbp),%rsi
add    %rsi,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    140b <Encode+0x2cb>
movslq -0x44(%rbp),%rax
add    -0xd4d0(%rbp),%rax
mov    %rax,-0xd4d0(%rbp)
movb   $0x0,-0xd4b0(%rbp)
movb   $0x1,-0xd4b1(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x40(%rbp),%ecx
mov    %al,-0xd4da(%rbp)
jge    14e7 <Encode+0x3a7>
mov    -0x18(%rbp),%rax
mov    -0xd4c8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
add    %rdx,%rcx
movsbl (%rax,%rcx,1),%ecx
mov    %ecx,-0x30(%rbp)
xor    %eax,%eax
mov    0x2b31(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0xd4da(%rbp)
je     14e7 <Encode+0x3a7>
mov    -0xd4c8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xd4c8(%rbp)
movslq -0x4(%rbp),%rcx
cmp    %rcx,%rax
setbe  %al
mov    %al,-0xd4da(%rbp)
mov    -0xd4da(%rbp),%al
test   $0x1,%al
jne    14fa <Encode+0x3ba>
jmp    15a1 <Encode+0x461>
mov    -0x3c(%rbp),%edi
lea    -0x4050(%rbp),%rsi
lea    -0x8460(%rbp),%rdx
lea    -0xc470(%rbp),%rcx
call   1060 <DeleteNode@plt>
mov    -0x30(%rbp),%eax
mov    %al,%cl
movslq -0x3c(%rbp),%rax
mov    %cl,-0xd490(%rbp,%rax,1)
cmpl   $0x11,-0x3c(%rbp)
jge    1547 <Encode+0x407>
mov    -0x30(%rbp),%eax
mov    %al,%cl
mov    -0x3c(%rbp),%eax
add    $0x1000,%eax
cltq
mov    %cl,-0xd490(%rbp,%rax,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
and    $0xfff,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
and    $0xfff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
lea    -0x4050(%rbp),%rsi
lea    -0x8460(%rbp),%rdx
lea    -0xc470(%rbp),%rcx
lea    -0xd490(%rbp),%rax
lea    -0x48(%rbp),%r8
lea    -0x4c(%rbp),%r9
mov    %rax,(%rsp)
call   1030 <InsertNode@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1481 <Encode+0x341>
movslq -0x2c(%rbp),%rax
add    -0xd4c0(%rbp),%rax
mov    %rax,-0xd4c0(%rbp)
cmp    -0xd4d8(%rbp),%rax
jbe    15d4 <Encode+0x494>
mov    -0xd4d8(%rbp),%rax
add    $0x400,%rax
mov    %rax,-0xd4d8(%rbp)
jmp    15d9 <Encode+0x499>
mov    -0x2c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x2c(%rbp)
cmp    -0x40(%rbp),%eax
jge    166d <Encode+0x52d>
mov    -0x3c(%rbp),%edi
lea    -0x4050(%rbp),%rsi
lea    -0x8460(%rbp),%rdx
lea    -0xc470(%rbp),%rcx
call   1060 <DeleteNode@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
and    $0xfff,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
and    $0xfff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
je     1668 <Encode+0x528>
mov    -0x38(%rbp),%edi
lea    -0x4050(%rbp),%rsi
lea    -0x8460(%rbp),%rdx
lea    -0xc470(%rbp),%rcx
lea    -0xd490(%rbp),%rax
lea    -0x48(%rbp),%r8
lea    -0x4c(%rbp),%r9
mov    %rax,(%rsp)
call   1030 <InsertNode@plt>
jmp    15d9 <Encode+0x499>
jmp    1672 <Encode+0x532>
cmpl   $0x0,-0x34(%rbp)
jg     1340 <Encode+0x200>
cmpl   $0x1,-0x44(%rbp)
jle    16e1 <Encode+0x5a1>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    16cf <Encode+0x58f>
movslq -0x2c(%rbp),%rax
mov    -0xd4b0(%rbp,%rax,1),%dl
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0xd4d0(%rbp),%rcx
movslq -0x2c(%rbp),%rsi
add    %rsi,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    168d <Encode+0x54d>
movslq -0x44(%rbp),%rax
add    -0xd4d0(%rbp),%rax
mov    %rax,-0xd4d0(%rbp)
movq   -0xd4c0(%rbp),%xmm0
ff
movaps 0x910(%rip),%xmm1
movaps %xmm1,-0xd500(%rbp)
punpckldq %xmm1,%xmm0
movapd 0x90d(%rip),%xmm1
movaps %xmm1,-0xd4f0(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0x900(%rip),%rdi
call   1050 <printf@plt>
movaps -0xd500(%rbp),%xmm2
movaps -0xd4f0(%rbp),%xmm1
movq   -0xd4d0(%rbp),%xmm0
ff
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0x8db(%rip),%rdi
call   1050 <printf@plt>
movaps -0xd500(%rbp),%xmm3
movaps -0xd4f0(%rbp),%xmm2
movq   -0xd4d0(%rbp),%xmm0
ff
punpckldq %xmm3,%xmm0
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movq   -0xd4c0(%rbp),%xmm1
ff
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
lea    0x897(%rip),%rdi
call   1050 <printf@plt>
mov    -0xd4d0(%rbp),%rax
mov    %eax,%edx
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
add    $0xd510,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Encode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd4f8,%rsp
mov    %r9,%r14
mov    %r8,0x40(%rsp)
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %esi,%r12d
mov    %edi,%r15d
lea    0x50e0(%rsp),%rdi
lea    0x90f0(%rsp),%rsi
lea    0x10d0(%rsp),%rdx
call   1040 <InitTree@plt>
movb   $0x0,0x50(%rsp)
lea    0xb0(%rsp),%rdi
mov    $0xfee,%edx
mov    $0x20,%esi
call   1060 <memset@plt>
mov    %ebp,0x68(%rsp)
movslq %ebp,%r8
mov    0x2e2d(%rip),%rax
mov    (%rax),%ecx
movslq %r15d,%rax
mov    %rax,0x70(%rsp)
mov    %rbx,0x90(%rsp)
lea    (%r8,%rbx,1),%rdx
add    $0x1,%rdx
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movsbl -0x1(%rdx,%rax,1),%esi
cmp    %esi,%ecx
je     1259 <Encode+0x109>
lea    0x1(%rax),%rbp
cmp    0x70(%rsp),%rax
jae    125e <Encode+0x10e>
mov    %rax,%rdi
or     $0x1,%rdi
mov    %sil,0x109e(%rsp,%rax,1)
movsbl (%rdx,%rax,1),%esi
cmp    %esi,%ecx
je     1263 <Encode+0x113>
cmp    0x70(%rsp),%rbp
jae    1268 <Encode+0x118>
mov    %sil,0x109f(%rsp,%rax,1)
add    $0x2,%rax
cmp    $0x12,%rax
jne    11e0 <Encode+0x90>
mov    %r12d,0x18(%rsp)
mov    %r14,0x88(%rsp)
mov    $0x12,%eax
mov    %rax,0x28(%rsp)
mov    $0x12,%eax
mov    %rax,0x20(%rsp)
mov    $0x12,%eax
mov    %rax,0x48(%rsp)
lea    0xb0(%rsp),%rcx
jmp    129d <Encode+0x14d>
mov    %rax,%rdi
jmp    126c <Encode+0x11c>
mov    %rax,%rdi
jmp    126f <Encode+0x11f>
mov    %rdi,%rbp
jmp    126f <Encode+0x11f>
add    $0x2,%rax
mov    %rax,%rbp
lea    0xb0(%rsp),%rcx
test   %edi,%edi
je     1773 <Encode+0x623>
mov    %r12d,0x18(%rsp)
mov    %rbp,0x48(%rsp)
mov    %r14,0x88(%rsp)
mov    %rdi,0x28(%rsp)
mov    %edi,%eax
mov    %rax,0x20(%rsp)
mov    %r8,0x38(%rsp)
mov    $0xfed,%ebp
lea    0x50e0(%rsp),%r15
lea    0x90f0(%rsp),%rbx
lea    0x10d0(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%r14
nopl   0x0(%rax)
mov    %rcx,(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %r14,%r9
call   1030 <InsertNode@plt>
lea    0xb0(%rsp),%rcx
add    $0xffffffff,%ebp
cmp    $0xfdb,%ebp
jne    12d0 <Encode+0x180>
mov    %rcx,(%rsp)
mov    $0xfee,%r15d
lea    0x50e0(%rsp),%rsi
lea    0x90f0(%rsp),%rdx
lea    0x10d0(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
mov    $0xfee,%edi
call   1030 <InsertNode@plt>
movslq 0x18(%rsp),%rax
mov    %rax,0x30(%rsp)
mov    0x38(%rsp),%rax
add    %rax,0x90(%rsp)
mov    $0x1,%bl
mov    $0x1,%r10d
xor    %r13d,%r13d
xor    %eax,%eax
mov    %rax,0x10(%rsp)
mov    0x20(%rsp),%r9
mov    0x28(%rsp),%rbp
mov    0x48(%rsp),%r11
jmp    139e <Encode+0x24e>
nopl   (%rax)
mov    0x6c(%rsp),%eax
sub    0xa8(%rsp),%eax
mov    %eax,%ebp
mov    0x48(%rsp),%r11
mov    0x20(%rsp),%r9
mov    %r14d,%eax
add    %rax,%r9
test   %ebp,%ebp
mov    0x18(%rsp),%r10
mov    0x38(%rsp),%bl
jle    1740 <Encode+0x5f0>
mov    0x8(%rsp),%r12d
cmp    %ebp,%r12d
jle    13af <Encode+0x25f>
mov    %ebp,0x8(%rsp)
mov    %ebp,%r12d
cmp    $0x2,%r12d
jg     13e0 <Encode+0x290>
movl   $0x1,0x8(%rsp)
or     %bl,0x50(%rsp)
movslq %r15d,%rax
mov    0xb0(%rsp,%rax,1),%cl
mov    $0x1,%edx
mov    %r10d,%eax
mov    $0x1,%r12d
jmp    140b <Encode+0x2bb>
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edx
add    0x68(%rsp),%edx
lea    0x1(%r10),%eax
movslq %r10d,%rcx
mov    %dl,0x50(%rsp,%rcx,1)
shr    $0x4,%edx
and    $0xf0,%edx
lea    0xfd(%r12),%ecx
or     %edx,%ecx
mov    $0x2,%edx
add    %edx,%r10d
cltq
mov    %cl,0x50(%rsp,%rax,1)
add    %bl,%bl
mov    %r9,0x20(%rsp)
mov    %rbp,0x28(%rsp)
je     1510 <Encode+0x3c0>
mov    %bl,0x38(%rsp)
mov    %r10,0x18(%rsp)
xor    %r14d,%r14d
jmp    1494 <Encode+0x344>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r13d
and    $0xfff,%r13d
add    $0x1,%r15d
and    $0xfff,%r15d
mov    %rcx,(%rsp)
mov    %r15d,%edi
lea    0x50e0(%rsp),%rsi
lea    0x90f0(%rsp),%rdx
lea    0x10d0(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
call   1030 <InsertNode@plt>
add    $0x1,%r14d
mov    %rbx,%r11
cmp    %r14d,%r12d
je     1560 <Encode+0x410>
mov    0x90(%rsp),%rax
movsbl (%rax,%r11,1),%ebp
mov    0x2b40(%rip),%rax
cmp    %ebp,(%rax)
je     1680 <Encode+0x530>
lea    0x1(%r11),%rbx
cmp    0x70(%rsp),%rbx
ja     1550 <Encode+0x400>
mov    %r13d,%edi
lea    0x50e0(%rsp),%rsi
lea    0x90f0(%rsp),%rdx
lea    0x10d0(%rsp),%rcx
call   1070 <DeleteNode@plt>
movslq %r13d,%rax
mov    %bpl,0xb0(%rsp,%rax,1)
cmp    $0x10,%eax
lea    0xb0(%rsp),%rcx
jg     1440 <Encode+0x2f0>
mov    %bpl,0x1000(%rax,%rcx,1)
jmp    1440 <Encode+0x2f0>
nopl   0x0(%rax,%rax,1)
test   %r10d,%r10d
jle    1575 <Encode+0x425>
mov    %r10d,%r14d
lea    -0x1(%r14),%rdx
mov    %r14d,%r8d
and    $0x3,%r8d
cmp    $0x3,%rdx
jae    1596 <Encode+0x446>
xor    %edx,%edx
mov    0x30(%rsp),%rax
mov    0x10(%rsp),%r9
mov    0x40(%rsp),%rcx
test   %r8,%r8
jne    1608 <Encode+0x4b8>
jmp    1637 <Encode+0x4e7>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r11
jmp    1680 <Encode+0x530>
nopl   0x0(%rax)
mov    %r12d,%r14d
mov    %rbx,%r11
mov    0x20(%rsp),%r9
mov    0x28(%rsp),%rbp
jmp    1387 <Encode+0x237>
movslq %r10d,%rax
add    %rax,0x10(%rsp)
movb   $0x0,0x50(%rsp)
mov    $0x1,%eax
mov    %rax,0x18(%rsp)
movb   $0x1,0x38(%rsp)
jmp    142f <Encode+0x2df>
and    $0xfffffffc,%r14d
neg    %r14
xor    %edx,%edx
mov    0x10(%rsp),%r9
mov    %r9,%rsi
lea    0x53(%rsp),%rdi
mov    0x30(%rsp),%rax
mov    0x40(%rsp),%rcx
cs nopw 0x0(%rax,%rax,1)
movzbl -0x3(%rdi),%ebx
mov    (%rcx,%rax,8),%rbp
mov    %bl,0x0(%rbp,%rsi,1)
movzbl -0x2(%rdi),%ebx
mov    (%rcx,%rax,8),%rbp
mov    %bl,0x1(%rbp,%rsi,1)
movzbl -0x1(%rdi),%ebx
mov    (%rcx,%rax,8),%rbp
mov    %bl,0x2(%rbp,%rsi,1)
movzbl (%rdi),%ebx
mov    (%rcx,%rax,8),%rbp
mov    %bl,0x3(%rbp,%rsi,1)
add    $0x4,%rdi
add    $0x4,%rsi
add    $0xfffffffffffffffc,%rdx
cmp    %rdx,%r14
jne    15c0 <Encode+0x470>
neg    %rdx
test   %r8,%r8
je     1637 <Encode+0x4e7>
lea    (%r9,%rdx,1),%rbp
add    %rsp,%rdx
add    $0x50,%rdx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rdx,%rsi,1),%ebx
mov    (%rcx,%rax,8),%rdi
add    %rbp,%rdi
mov    %bl,(%rsi,%rdi,1)
add    $0x1,%rsi
cmp    %rsi,%r8
jne    1620 <Encode+0x4d0>
mov    0x8(%rsp),%r12d
movslq %r10d,%rax
add    %rax,%r9
movb   $0x0,0x50(%rsp)
test   %r12d,%r12d
mov    %r9,0x10(%rsp)
jle    1665 <Encode+0x515>
movb   $0x1,0x38(%rsp)
mov    $0x1,%eax
mov    %rax,0x18(%rsp)
jmp    142f <Encode+0x2df>
movb   $0x1,0x38(%rsp)
mov    $0x1,%eax
mov    %rax,0x18(%rsp)
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    0x20(%rsp),%r9
mov    0x28(%rsp),%rbp
cmp    %r12d,%r14d
jge    1387 <Encode+0x237>
mov    %r11,0x48(%rsp)
lea    (%r14,%rbp,1),%eax
mov    %eax,0x6c(%rsp)
mov    %r12,0xa8(%rsp)
mov    %r12d,%ebx
sub    %r14d,%ebx
add    $0xffffffff,%ebp
xor    %r12d,%r12d
jmp    16d4 <Encode+0x584>
cs nopw 0x0(%rax,%rax,1)
and    $0xfff,%r13d
add    $0x1,%r12d
cmp    %r12d,%ebx
je     1370 <Encode+0x220>
mov    %r13d,%edi
lea    0x50e0(%rsp),%rsi
lea    0x90f0(%rsp),%rdx
lea    0x10d0(%rsp),%rcx
call   1070 <DeleteNode@plt>
add    $0x1,%r13d
add    $0x1,%r15d
and    $0xfff,%r15d
cmp    %r12d,%ebp
je     16c0 <Encode+0x570>
lea    0xb0(%rsp),%rax
mov    %rax,(%rsp)
mov    %r15d,%edi
lea    0x50e0(%rsp),%rsi
lea    0x90f0(%rsp),%rdx
lea    0x10d0(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
call   1030 <InsertNode@plt>
jmp    16c0 <Encode+0x570>
cmp    $0x2,%r10d
mov    0x88(%rsp),%r14
jl     1769 <Encode+0x619>
mov    %r10d,%r10d
lea    -0x1(%r10),%rcx
mov    %r10d,%r8d
and    $0x3,%r8d
cmp    $0x3,%rcx
jae    1782 <Encode+0x632>
xor    %ecx,%ecx
jmp    17e3 <Encode+0x693>
mov    0x10(%rsp),%rbx
jmp    1835 <Encode+0x6e5>
movslq %r12d,%rax
mov    %rax,0x30(%rsp)
xor    %ebx,%ebx
jmp    18b9 <Encode+0x769>
and    $0xfffffffc,%r10d
neg    %r10
xor    %ecx,%ecx
mov    0x10(%rsp),%rsi
mov    0x30(%rsp),%rax
lea    0x53(%rsp),%rbp
mov    0x40(%rsp),%rdx
nop
movzbl -0x3(%rbp),%ebx
mov    (%rdx,%rax,8),%rdi
mov    %bl,(%rdi,%rsi,1)
movzbl -0x2(%rbp),%ebx
mov    (%rdx,%rax,8),%rdi
mov    %bl,0x1(%rdi,%rsi,1)
movzbl -0x1(%rbp),%ebx
mov    (%rdx,%rax,8),%rdi
mov    %bl,0x2(%rdi,%rsi,1)
movzbl 0x0(%rbp),%ebx
mov    (%rdx,%rax,8),%rdi
mov    %bl,0x3(%rdi,%rsi,1)
add    $0x4,%rbp
add    $0x4,%rsi
add    $0xfffffffffffffffc,%rcx
cmp    %rcx,%r10
jne    17a0 <Encode+0x650>
neg    %rcx
test   %r8,%r8
mov    0x30(%rsp),%rax
mov    0x40(%rsp),%rbp
je     1828 <Encode+0x6d8>
lea    (%rsp,%rcx,1),%rdx
add    $0x50,%rdx
add    0x10(%rsp),%rcx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rdx,%rsi,1),%ebx
mov    0x0(%rbp,%rax,8),%rdi
add    %rcx,%rdi
mov    %bl,(%rsi,%rdi,1)
add    $0x1,%rsi
cmp    %rsi,%r8
jne    1810 <Encode+0x6c0>
movslq 0x18(%rsp),%rax
mov    0x10(%rsp),%rbx
add    %rax,%rbx
movq   %r9,%xmm1
punpckldq 0x7be(%rip),%xmm1
subpd  0x7c6(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,0x70(%rsp)
lea    0x7bd(%rip),%rdi
call   1050 <printf@plt>
movq   %rbx,%xmm1
punpckldq 0x78b(%rip),%xmm1
subpd  0x793(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,0x90(%rsp)
lea    0x797(%rip),%rdi
call   1050 <printf@plt>
movapd 0x90(%rsp),%xmm0
divsd  0x70(%rsp),%xmm0
lea    0x78c(%rip),%rdi
call   1050 <printf@plt>
mov    0x30(%rsp),%rax
mov    %ebx,(%r14,%rax,4)
add    $0xd4f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [16 x i8] c"In : %ld bytes\0A\00"
@.str.1 = [16 x i8] c"Out: %ld bytes\0A\00"
@.str.2 = [14 x i8] c"Out/In: %.3f\0A\00"
define void @Encode(i32 %0, i32 %1, i32 %2, i8* %3, i8** %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8**
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca [4097 x i32]
%23 = alloca [4353 x i32]
%24 = alloca [4097 x i32]
%25 = alloca [4113 x i8]
%26 = alloca [17 x i8]
%27 = alloca i8
%28 = alloca i64
%29 = alloca i64
%30 = alloca i64
%31 = alloca i64
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i8** %4, i8*** %11
store i32* %5, i32** %12
store i64 0, i64* %28
store i64 0, i64* %29
store i64 0, i64* %30
store i64 0, i64* %31
%32 = getelementptr inbounds [4097 x i32], [4097 x i32]* %22, i64 0, i64 0
%33 = getelementptr inbounds [4353 x i32], [4353 x i32]* %23, i64 0, i64 0
%34 = getelementptr inbounds [4097 x i32], [4097 x i32]* %24, i64 0, i64 0
%35 = call i32 @InitTree(i32* %32, i32* %33, i32* %34)
%36 = getelementptr inbounds [17 x i8], [17 x i8]* %26, i64 0, i64 0
store i8 0, i8* %36
store i8 1, i8* %27
store i32 1, i32* %19
store i32 0, i32* %17
store i32 4078, i32* %16
%37 = load i32, i32* %17
store i32 %37, i32* %13
br label %38
38: ; preds = %46, %6
%39 = load i32, i32* %13
%40 = load i32, i32* %16
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %49
42: ; preds = %38
%43 = load i32, i32* %13
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [4113 x i8], [4113 x i8]* %25, i64 0, i64 %44
store i8 32, i8* %45
br label %46
46: ; preds = %42
%47 = load i32, i32* %13
%48 = add nsw i32 %47, 1
store i32 %48, i32* %13
br label %38
49: ; preds = %38
store i32 0, i32* %15
br label %50
50: ; preds = %80, %49
%51 = load i32, i32* %15
%52 = icmp slt i32 %51, 18
br i1 %52, label %53, label %70
53: ; preds = %50
%54 = load i8*, i8** %10
%55 = load i64, i64* %29
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = add i64 %55, %57
%59 = getelementptr inbounds i8, i8* %54, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
store i32 %61, i32* %14
%62 = load i32, i32* @EOF
%63 = icmp ne i32 %61, %62
br i1 %63, label %64, label %70
64: ; preds = %53
%65 = load i64, i64* %29
%66 = add i64 %65, 1
store i64 %66, i64* %29
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = icmp ule i64 %66, %68
br label %70
70: ; preds = %64, %53, %50
%71 = phi i1 [ false, %53 ], [ false, %50 ], [ %69, %64 ]
br i1 %71, label %72, label %83
72: ; preds = %70
%73 = load i32, i32* %14
%74 = trunc i32 %73 to i8
%75 = load i32, i32* %16
%76 = load i32, i32* %15
%77 = add nsw i32 %75, %76
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [4113 x i8], [4113 x i8]* %25, i64 0, i64 %78
store i8 %74, i8* %79
br label %80
80: ; preds = %72
%81 = load i32, i32* %15
%82 = add nsw i32 %81, 1
store i32 %82, i32* %15
br label %50
83: ; preds = %70
%84 = load i32, i32* %15
%85 = sext i32 %84 to i64
store i64 %85, i64* %28
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %92
87: ; preds = %83
%88 = load i32*, i32** %12
%89 = load i32, i32* %8
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i32, i32* %88, i64 %90
store i32 0, i32* %91
br label %354
92: ; preds = %83
store i32 1, i32* %13
br label %93
93: ; preds = %105, %92
%94 = load i32, i32* %13
%95 = icmp sle i32 %94, 18
br i1 %95, label %96, label %108
96: ; preds = %93
%97 = load i32, i32* %16
%98 = load i32, i32* %13
%99 = sub nsw i32 %97, %98
%100 = getelementptr inbounds [4097 x i32], [4097 x i32]* %22, i64 0, i64 0
%101 = getelementptr inbounds [4353 x i32], [4353 x i32]* %23, i64 0, i64 0
%102 = getelementptr inbounds [4097 x i32], [4097 x i32]* %24, i64 0, i64 0
%103 = getelementptr inbounds [4113 x i8], [4113 x i8]* %25, i64 0, i64 0
%104 = call i32 @InsertNode(i32 %99, i32* %100, i32* %101, i32* %102, i32* %20, i32* %21, i8* %103)
br label %105
105: ; preds = %96
%106 = load i32, i32* %13
%107 = add nsw i32 %106, 1
store i32 %107, i32* %13
br label %93
108: ; preds = %93
%109 = load i32, i32* %16
%110 = getelementptr inbounds [4097 x i32], [4097 x i32]* %22, i64 0, i64 0
%111 = getelementptr inbounds [4353 x i32], [4353 x i32]* %23, i64 0, i64 0
%112 = getelementptr inbounds [4097 x i32], [4097 x i32]* %24, i64 0, i64 0
%113 = getelementptr inbounds [4113 x i8], [4113 x i8]* %25, i64 0, i64 0
%114 = call i32 @InsertNode(i32 %109, i32* %110, i32* %111, i32* %112, i32* %20, i32* %21, i8* %113)
br label %115
115: ; preds = %301, %108
%116 = load i32, i32* %21
%117 = load i32, i32* %15
%118 = icmp sgt i32 %116, %117
br i1 %118, label %119, label %121
119: ; preds = %115
%120 = load i32, i32* %15
store i32 %120, i32* %21
br label %121
121: ; preds = %119, %115
%122 = load i32, i32* %21
%123 = icmp sle i32 %122, 2
br i1 %123, label %124, label %140
124: ; preds = %121
store i32 1, i32* %21
%125 = load i8, i8* %27
%126 = zext i8 %125 to i32
%127 = getelementptr inbounds [17 x i8], [17 x i8]* %26, i64 0, i64 0
%128 = load i8, i8* %127
%129 = zext i8 %128 to i32
%130 = or i32 %129, %126
%131 = trunc i32 %130 to i8
store i8 %131, i8* %127
%132 = load i32, i32* %16
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds [4113 x i8], [4113 x i8]* %25, i64 0, i64 %133
%135 = load i8, i8* %134
%136 = load i32, i32* %19
%137 = add nsw i32 %136, 1
store i32 %137, i32* %19
%138 = sext i32 %136 to i64
%139 = getelementptr inbounds [17 x i8], [17 x i8]* %26, i64 0, i64 %138
store i8 %135, i8* %139
br label %164
140: ; preds = %121
%141 = load i32, i32* %20
%142 = trunc i32 %141 to i8
%143 = zext i8 %142 to i32
%144 = load i32, i32* %9
%145 = add nsw i32 %143, %144
%146 = trunc i32 %145 to i8
%147 = load i32, i32* %19
%148 = add nsw i32 %147, 1
store i32 %148, i32* %19
%149 = sext i32 %147 to i64
%150 = getelementptr inbounds [17 x i8], [17 x i8]* %26, i64 0, i64 %149
store i8 %146, i8* %150
%151 = load i32, i32* %20
%152 = load i32, i32* %9
%153 = add nsw i32 %151, %152
%154 = ashr i32 %153, 4
%155 = and i32 %154, 240
%156 = load i32, i32* %21
%157 = sub nsw i32 %156, 3
%158 = or i32 %155, %157
%159 = trunc i32 %158 to i8
%160 = load i32, i32* %19
%161 = add nsw i32 %160, 1
store i32 %161, i32* %19
%162 = sext i32 %160 to i64
%163 = getelementptr inbounds [17 x i8], [17 x i8]* %26, i64 0, i64 %162
store i8 %159, i8* %163
br label %164
164: ; preds = %140, %124
%165 = load i8, i8* %27
%166 = zext i8 %165 to i32
%167 = shl i32 %166, 1
%168 = trunc i32 %167 to i8
store i8 %168, i8* %27
%169 = zext i8 %168 to i32
%170 = icmp eq i32 %169, 0
br i1 %170, label %171, label %200
171: ; preds = %164
store i32 0, i32* %13
br label %172
172: ; preds = %191, %171
%173 = load i32, i32* %13
%174 = load i32, i32* %19
%175 = icmp slt i32 %173, %174
br i1 %175, label %176, label %194
176: ; preds = %172
%177 = load i32, i32* %13
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds [17 x i8], [17 x i8]* %26, i64 0, i64 %178
%180 = load i8, i8* %179
%181 = load i8**, i8*** %11
%182 = load i32, i32* %8
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds i8*, i8** %181, i64 %183
%185 = load i8*, i8** %184
%186 = load i64, i64* %30
%187 = load i32, i32* %13
%188 = sext i32 %187 to i64
%189 = add i64 %186, %188
%190 = getelementptr inbounds i8, i8* %185, i64 %189
store i8 %180, i8* %190
br label %191
191: ; preds = %176
%192 = load i32, i32* %13
%193 = add nsw i32 %192, 1
store i32 %193, i32* %13
br label %172
194: ; preds = %172
%195 = load i32, i32* %19
%196 = sext i32 %195 to i64
%197 = load i64, i64* %30
%198 = add i64 %197, %196
store i64 %198, i64* %30
%199 = getelementptr inbounds [17 x i8], [17 x i8]* %26, i64 0, i64 0
store i8 0, i8* %199
store i8 1, i8* %27
store i32 1, i32* %19
br label %200
200: ; preds = %194, %164
%201 = load i32, i32* %21
store i32 %201, i32* %18
store i32 0, i32* %13
br label %202
202: ; preds = %258, %200
%203 = load i32, i32* %13
%204 = load i32, i32* %18
%205 = icmp slt i32 %203, %204
br i1 %205, label %206, label %223
206: ; preds = %202
%207 = load i8*, i8** %10
%208 = load i64, i64* %29
%209 = load i32, i32* %9
%210 = sext i32 %209 to i64
%211 = add i64 %208, %210
%212 = getelementptr inbounds i8, i8* %207, i64 %211
%213 = load i8, i8* %212
%214 = sext i8 %213 to i32
store i32 %214, i32* %14
%215 = load i32, i32* @EOF
%216 = icmp ne i32 %214, %215
br i1 %216, label %217, label %223
217: ; preds = %206
%218 = load i64, i64* %29
%219 = add i64 %218, 1
store i64 %219, i64* %29
%220 = load i32, i32* %7
%221 = sext i32 %220 to i64
%222 = icmp ule i64 %219, %221
br label %223
223: ; preds = %217, %206, %202
%224 = phi i1 [ false, %206 ], [ false, %202 ], [ %222, %217 ]
br i1 %224, label %225, label %261
225: ; preds = %223
%226 = load i32, i32* %17
%227 = getelementptr inbounds [4097 x i32], [4097 x i32]* %22, i64 0, i64 0
%228 = getelementptr inbounds [4353 x i32], [4353 x i32]* %23, i64 0, i64 0
%229 = getelementptr inbounds [4097 x i32], [4097 x i32]* %24, i64 0, i64 0
%230 = call i32 @DeleteNode(i32 %226, i32* %227, i32* %228, i32* %229)
%231 = load i32, i32* %14
%232 = trunc i32 %231 to i8
%233 = load i32, i32* %17
%234 = sext i32 %233 to i64
%235 = getelementptr inbounds [4113 x i8], [4113 x i8]* %25, i64 0, i64 %234
store i8 %232, i8* %235
%236 = load i32, i32* %17
%237 = icmp slt i32 %236, 17
br i1 %237, label %238, label %245
238: ; preds = %225
%239 = load i32, i32* %14
%240 = trunc i32 %239 to i8
%241 = load i32, i32* %17
%242 = add nsw i32 %241, 4096
%243 = sext i32 %242 to i64
%244 = getelementptr inbounds [4113 x i8], [4113 x i8]* %25, i64 0, i64 %243
store i8 %240, i8* %244
br label %245
245: ; preds = %238, %225
%246 = load i32, i32* %17
%247 = add nsw i32 %246, 1
%248 = and i32 %247, 4095
store i32 %248, i32* %17
%249 = load i32, i32* %16
%250 = add nsw i32 %249, 1
%251 = and i32 %250, 4095
store i32 %251, i32* %16
%252 = load i32, i32* %16
%253 = getelementptr inbounds [4097 x i32], [4097 x i32]* %22, i64 0, i64 0
%254 = getelementptr inbounds [4353 x i32], [4353 x i32]* %23, i64 0, i64 0
%255 = getelementptr inbounds [4097 x i32], [4097 x i32]* %24, i64 0, i64 0
%256 = getelementptr inbounds [4113 x i8], [4113 x i8]* %25, i64 0, i64 0
%257 = call i32 @InsertNode(i32 %252, i32* %253, i32* %254, i32* %255, i32* %20, i32* %21, i8* %256)
br label %258
258: ; preds = %245
%259 = load i32, i32* %13
%260 = add nsw i32 %259, 1
store i32 %260, i32* %13
br label %202
261: ; preds = %223
%262 = load i32, i32* %13
%263 = sext i32 %262 to i64
%264 = load i64, i64* %28
%265 = add i64 %264, %263
store i64 %265, i64* %28
%266 = load i64, i64* %31
%267 = icmp ugt i64 %265, %266
br i1 %267, label %268, label %271
268: ; preds = %261
%269 = load i64, i64* %31
%270 = add i64 %269, 1024
store i64 %270, i64* %31
br label %271
271: ; preds = %268, %261
br label %272
272: ; preds = %299, %271
%273 = load i32, i32* %13
%274 = add nsw i32 %273, 1
store i32 %274, i32* %13
%275 = load i32, i32* %18
%276 = icmp slt i32 %273, %275
br i1 %276, label %277, label %300
277: ; preds = %272
%278 = load i32, i32* %17
%279 = getelementptr inbounds [4097 x i32], [4097 x i32]* %22, i64 0, i64 0
%280 = getelementptr inbounds [4353 x i32], [4353 x i32]* %23, i64 0, i64 0
%281 = getelementptr inbounds [4097 x i32], [4097 x i32]* %24, i64 0, i64 0
%282 = call i32 @DeleteNode(i32 %278, i32* %279, i32* %280, i32* %281)
%283 = load i32, i32* %17
%284 = add nsw i32 %283, 1
%285 = and i32 %284, 4095
store i32 %285, i32* %17
%286 = load i32, i32* %16
%287 = add nsw i32 %286, 1
%288 = and i32 %287, 4095
store i32 %288, i32* %16
%289 = load i32, i32* %15
%290 = add nsw i32 %289, -1
store i32 %290, i32* %15
%291 = icmp ne i32 %290, 0
br i1 %291, label %292, label %299
292: ; preds = %277
%293 = load i32, i32* %16
%294 = getelementptr inbounds [4097 x i32], [4097 x i32]* %22, i64 0, i64 0
%295 = getelementptr inbounds [4353 x i32], [4353 x i32]* %23, i64 0, i64 0
%296 = getelementptr inbounds [4097 x i32], [4097 x i32]* %24, i64 0, i64 0
%297 = getelementptr inbounds [4113 x i8], [4113 x i8]* %25, i64 0, i64 0
%298 = call i32 @InsertNode(i32 %293, i32* %294, i32* %295, i32* %296, i32* %20, i32* %21, i8* %297)
br label %299
299: ; preds = %292, %277
br label %272
300: ; preds = %272
br label %301
301: ; preds = %300
%302 = load i32, i32* %15
%303 = icmp sgt i32 %302, 0
br i1 %303, label %115, label %304
304: ; preds = %301
%305 = load i32, i32* %19
%306 = icmp sgt i32 %305, 1
br i1 %306, label %307, label %335
307: ; preds = %304
store i32 0, i32* %13
br label %308
308: ; preds = %327, %307
%309 = load i32, i32* %13
%310 = load i32, i32* %19
%311 = icmp slt i32 %309, %310
br i1 %311, label %312, label %330
312: ; preds = %308
%313 = load i32, i32* %13
%314 = sext i32 %313 to i64
%315 = getelementptr inbounds [17 x i8], [17 x i8]* %26, i64 0, i64 %314
%316 = load i8, i8* %315
%317 = load i8**, i8*** %11
%318 = load i32, i32* %8
%319 = sext i32 %318 to i64
%320 = getelementptr inbounds i8*, i8** %317, i64 %319
%321 = load i8*, i8** %320
%322 = load i64, i64* %30
%323 = load i32, i32* %13
%324 = sext i32 %323 to i64
%325 = add i64 %322, %324
%326 = getelementptr inbounds i8, i8* %321, i64 %325
store i8 %316, i8* %326
br label %327
327: ; preds = %312
%328 = load i32, i32* %13
%329 = add nsw i32 %328, 1
store i32 %329, i32* %13
br label %308
330: ; preds = %308
%331 = load i32, i32* %19
%332 = sext i32 %331 to i64
%333 = load i64, i64* %30
%334 = add i64 %333, %332
store i64 %334, i64* %30
br label %335
335: ; preds = %330, %304
%336 = load i64, i64* %28
%337 = uitofp i64 %336 to double
%338 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %337)
%339 = load i64, i64* %30
%340 = uitofp i64 %339 to double
%341 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %340)
%342 = load i64, i64* %30
%343 = uitofp i64 %342 to double
%344 = load i64, i64* %28
%345 = uitofp i64 %344 to double
%346 = fdiv double %343, %345
%347 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %346)
%348 = load i64, i64* %30
%349 = trunc i64 %348 to i32
%350 = load i32*, i32** %12
%351 = load i32, i32* %8
%352 = sext i32 %351 to i64
%353 = getelementptr inbounds i32, i32* %350, i64 %352
store i32 %349, i32* %353
br label %354
354: ; preds = %335, %87
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [16 x i8] c"In : %ld bytes\0A\00"
@.str.1 = [16 x i8] c"Out: %ld bytes\0A\00"
@.str.2 = [14 x i8] c"Out/In: %.3f\0A\00"
define void @Encode(i32 %0, i32 %1, i32 %2, i8* nocapture %3, i8** nocapture %4, i32* nocapture writeonly %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca [4097 x i32]
%10 = alloca [4353 x i32]
%11 = alloca [4097 x i32]
%12 = alloca [4113 x i8]
%13 = getelementptr inbounds [4113 x i8], [4113 x i8]* %12, i64 0, i64 0
%14 = alloca [17 x i8]
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast [4097 x i32]* %9 to i8*
%18 = bitcast [4353 x i32]* %10 to i8*
%19 = bitcast [4097 x i32]* %11 to i8*
%20 = getelementptr inbounds [4113 x i8], [4113 x i8]* %12, i64 0, i64 0
%21 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 0
%22 = getelementptr inbounds [4097 x i32], [4097 x i32]* %9, i64 0, i64 0
%23 = getelementptr inbounds [4353 x i32], [4353 x i32]* %10, i64 0, i64 0
%24 = getelementptr inbounds [4097 x i32], [4097 x i32]* %11, i64 0, i64 0
%25 = call i32 @InitTree(i32* %22, i32* %23, i32* %24)
store i8 0, i8* %21
%26 = sext i32 %2 to i64
%27 = load i32, i32* @EOF
%28 = sext i32 %0 to i64
br label %29
29: ; preds = %50, %6
%30 = phi i64 [ 0, %6 ], [ %48, %50 ]
%31 = add nsw i64 %30, %26
%32 = getelementptr inbounds i8, i8* %3, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %27, %34
br i1 %35, label %54, label %36
36: ; preds = %29
%37 = or i64 %30, 1
%38 = icmp ult i64 %30, %28
br i1 %38, label %39, label %54
39: ; preds = %36
%40 = add nuw nsw i64 %30, 4078
%41 = getelementptr inbounds [4113 x i8], [4113 x i8]* %12, i64 0, i64 %40
store i8 %33, i8* %41
%42 = add nsw i64 %37, %26
%43 = getelementptr inbounds i8, i8* %3, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %27, %45
br i1 %46, label %54, label %47
47: ; preds = %39
%48 = add nuw nsw i64 %30, 2
%49 = icmp ult i64 %37, %28
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = add nuw i64 %30, 4079
%52 = getelementptr inbounds [4113 x i8], [4113 x i8]* %12, i64 0, i64 %51
store i8 %44, i8* %52
%53 = icmp eq i64 %48, 18
br i1 %53, label %60, label %29
54: ; preds = %47, %39, %29, %36
%55 = phi i64 [ %30, %29 ], [ %30, %36 ], [ %37, %39 ], [ %37, %47 ]
%56 = phi i64 [ %30, %29 ], [ %37, %36 ], [ %37, %39 ], [ %48, %47 ]
%57 = trunc i64 %55 to i32
%58 = and i64 %55, 4294967295
%59 = icmp eq i32 %57, 0
br i1 %59, label %64, label %60
60: ; preds = %50, %54
%61 = phi i64 [ %58, %54 ], [ 18, %50 ]
%62 = phi i64 [ %56, %54 ], [ 18, %50 ]
%63 = phi i32 [ %57, %54 ], [ 18, %50 ]
br label %66
64: ; preds = %54
%65 = sext i32 %1 to i64
br label %322
66: ; preds = %60, %66
%67 = phi i32 [ %70, %66 ], [ 1, %60 ]
%68 = sub nuw nsw i32 4078, %67
%69 = call i32 @InsertNode(i32 %68, i32* %22, i32* %23, i32* %24, i32* %7, i32* %8, i8* %20)
%70 = add nuw nsw i32 %67, 1
%71 = icmp eq i32 %70, 19
br i1 %71, label %72, label %66
72: ; preds = %66
%73 = call i32 @InsertNode(i32 4078, i32* %22, i32* %23, i32* %24, i32* %7, i32* %8, i8* %20)
%74 = sext i32 %1 to i64
%75 = getelementptr inbounds i8*, i8** %4, i64 %74
br label %76
76: ; preds = %246, %72
%77 = phi i32 [ %63, %72 ], [ %252, %246 ]
%78 = phi i32 [ 4078, %72 ], [ %253, %246 ]
%79 = phi i32 [ 0, %72 ], [ %254, %246 ]
%80 = phi i32 [ 1, %72 ], [ %249, %246 ]
%81 = phi i8 [ 1, %72 ], [ %250, %246 ]
%82 = phi i64 [ %61, %72 ], [ %256, %246 ]
%83 = phi i64 [ %62, %72 ], [ %248, %246 ]
%84 = phi i64 [ 0, %72 ], [ %251, %246 ]
%85 = load i32, i32* %8
%86 = icmp sgt i32 %85, %77
br i1 %86, label %87, label %88
87: ; preds = %76
store i32 %77, i32* %8
br label %88
88: ; preds = %87, %76
%89 = phi i32 [ %77, %87 ], [ %85, %76 ]
%90 = icmp slt i32 %89, 3
br i1 %90, label %91, label %97
91: ; preds = %88
store i32 1, i32* %8
%92 = load i8, i8* %21
%93 = or i8 %92, %81
store i8 %93, i8* %21
%94 = sext i32 %78 to i64
%95 = getelementptr inbounds [4113 x i8], [4113 x i8]* %12, i64 0, i64 %94
%96 = load i8, i8* %95
br label %109
97: ; preds = %88
%98 = load i32, i32* %7
%99 = add i32 %98, %2
%100 = trunc i32 %99 to i8
%101 = add nsw i32 %80, 1
%102 = sext i32 %80 to i64
%103 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 %102
store i8 %100, i8* %103
%104 = lshr i32 %99, 4
%105 = and i32 %104, 240
%106 = add nuw i32 %89, 253
%107 = or i32 %105, %106
%108 = trunc i32 %107 to i8
br label %109
109: ; preds = %97, %91
%110 = phi i32 [ 2, %97 ], [ 1, %91 ]
%111 = phi i32 [ %101, %97 ], [ %80, %91 ]
%112 = phi i8 [ %108, %97 ], [ %96, %91 ]
%113 = phi i32 [ %89, %97 ], [ 1, %91 ]
%114 = add nsw i32 %80, %110
%115 = sext i32 %111 to i64
%116 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 %115
store i8 %112, i8* %116
%117 = shl i8 %81, 1
%118 = icmp eq i8 %117, 0
br i1 %118, label %119, label %179
119: ; preds = %109
%120 = icmp sgt i32 %114, 0
br i1 %120, label %124, label %121
121: ; preds = %119
%122 = sext i32 %114 to i64
%123 = add i64 %84, %122
store i8 0, i8* %21
br label %179
124: ; preds = %119
%125 = zext i32 %114 to i64
%126 = add nsw i64 %125, -1
%127 = and i64 %125, 3
%128 = icmp ult i64 %126, 3
br i1 %128, label %160, label %129
129: ; preds = %124
%130 = and i64 %125, 4294967292
br label %131
131: ; preds = %131, %129
%132 = phi i64 [ 0, %129 ], [ %157, %131 ]
%133 = phi i64 [ 0, %129 ], [ %158, %131 ]
%134 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 %132
%135 = load i8, i8* %134
%136 = load i8*, i8** %75
%137 = add i64 %84, %132
%138 = getelementptr inbounds i8, i8* %136, i64 %137
store i8 %135, i8* %138
%139 = or i64 %132, 1
%140 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 %139
%141 = load i8, i8* %140
%142 = load i8*, i8** %75
%143 = add i64 %84, %139
%144 = getelementptr inbounds i8, i8* %142, i64 %143
store i8 %141, i8* %144
%145 = or i64 %132, 2
%146 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 %145
%147 = load i8, i8* %146
%148 = load i8*, i8** %75
%149 = add i64 %84, %145
%150 = getelementptr inbounds i8, i8* %148, i64 %149
store i8 %147, i8* %150
%151 = or i64 %132, 3
%152 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 %151
%153 = load i8, i8* %152
%154 = load i8*, i8** %75
%155 = add i64 %84, %151
%156 = getelementptr inbounds i8, i8* %154, i64 %155
store i8 %153, i8* %156
%157 = add nuw nsw i64 %132, 4
%158 = add i64 %133, 4
%159 = icmp eq i64 %158, %130
br i1 %159, label %160, label %131
160: ; preds = %131, %124
%161 = phi i64 [ 0, %124 ], [ %157, %131 ]
%162 = icmp eq i64 %127, 0
br i1 %162, label %174, label %163
163: ; preds = %160, %163
%164 = phi i64 [ %171, %163 ], [ %161, %160 ]
%165 = phi i64 [ %172, %163 ], [ 0, %160 ]
%166 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 %164
%167 = load i8, i8* %166
%168 = load i8*, i8** %75
%169 = add i64 %84, %164
%170 = getelementptr inbounds i8, i8* %168, i64 %169
store i8 %167, i8* %170
%171 = add nuw nsw i64 %164, 1
%172 = add i64 %165, 1
%173 = icmp eq i64 %172, %127
br i1 %173, label %174, label %163
174: ; preds = %163, %160
%175 = load i32, i32* %8
%176 = sext i32 %114 to i64
%177 = add i64 %84, %176
store i8 0, i8* %21
%178 = icmp sgt i32 %175, 0
br i1 %178, label %179, label %215
179: ; preds = %109, %121, %174
%180 = phi i64 [ %177, %174 ], [ %123, %121 ], [ %84, %109 ]
%181 = phi i8 [ 1, %174 ], [ 1, %121 ], [ %117, %109 ]
%182 = phi i32 [ 1, %174 ], [ 1, %121 ], [ %114, %109 ]
%183 = phi i32 [ %175, %174 ], [ %113, %121 ], [ %113, %109 ]
br label %184
184: ; preds = %179, %207
%185 = phi i64 [ %196, %207 ], [ %83, %179 ]
%186 = phi i32 [ %213, %207 ], [ 0, %179 ]
%187 = phi i32 [ %209, %207 ], [ %79, %179 ]
%188 = phi i32 [ %211, %207 ], [ %78, %179 ]
%189 = add i64 %185, %26
%190 = getelementptr inbounds i8, i8* %3, i64 %189
%191 = load i8, i8* %190
%192 = sext i8 %191 to i32
%193 = load i32, i32* @EOF
%194 = icmp eq i32 %193, %192
br i1 %194, label %215, label %195
195: ; preds = %184
%196 = add i64 %185, 1
%197 = icmp ugt i64 %196, %28
br i1 %197, label %215, label %198
198: ; preds = %195
%199 = call i32 @DeleteNode(i32 %187, i32* %22, i32* %23, i32* %24)
%200 = sext i32 %187 to i64
%201 = getelementptr inbounds [4113 x i8], [4113 x i8]* %12, i64 0, i64 %200
store i8 %191, i8* %201
%202 = icmp slt i32 %187, 17
br i1 %202, label %203, label %207
203: ; preds = %198
%204 = add nsw i32 %187, 4096
%205 = sext i32 %204 to i64
%206 = getelementptr inbounds [4113 x i8], [4113 x i8]* %12, i64 0, i64 %205
store i8 %191, i8* %206
br label %207
207: ; preds = %203, %198
%208 = add nsw i32 %187, 1
%209 = and i32 %208, 4095
%210 = add nsw i32 %188, 1
%211 = and i32 %210, 4095
%212 = call i32 @InsertNode(i32 %211, i32* %22, i32* %23, i32* %24, i32* %7, i32* %8, i8* %20)
%213 = add nuw nsw i32 %186, 1
%214 = icmp eq i32 %213, %183
br i1 %214, label %246, label %184
215: ; preds = %195, %184, %174
%216 = phi i64 [ %177, %174 ], [ %180, %184 ], [ %180, %195 ]
%217 = phi i8 [ 1, %174 ], [ %181, %184 ], [ %181, %195 ]
%218 = phi i32 [ 1, %174 ], [ %182, %184 ], [ %182, %195 ]
%219 = phi i32 [ %175, %174 ], [ %183, %184 ], [ %183, %195 ]
%220 = phi i32 [ %78, %174 ], [ %188, %184 ], [ %188, %195 ]
%221 = phi i32 [ %79, %174 ], [ %187, %184 ], [ %187, %195 ]
%222 = phi i32 [ 0, %174 ], [ %186, %184 ], [ %186, %195 ]
%223 = phi i64 [ %83, %174 ], [ %196, %195 ], [ %185, %184 ]
%224 = icmp slt i32 %222, %219
br i1 %224, label %225, label %246
225: ; preds = %215
%226 = add i32 %77, %222
br label %227
227: ; preds = %225, %242
%228 = phi i32 [ %232, %242 ], [ %222, %225 ]
%229 = phi i32 [ %235, %242 ], [ %221, %225 ]
%230 = phi i32 [ %237, %242 ], [ %220, %225 ]
%231 = phi i32 [ %238, %242 ], [ %77, %225 ]
%232 = add i32 %228, 1
%233 = call i32 @DeleteNode(i32 %229, i32* %22, i32* %23, i32* %24)
%234 = add nsw i32 %229, 1
%235 = and i32 %234, 4095
%236 = add nsw i32 %230, 1
%237 = and i32 %236, 4095
%238 = add nsw i32 %231, -1
%239 = icmp eq i32 %238, 0
br i1 %239, label %242, label %240
240: ; preds = %227
%241 = call i32 @InsertNode(i32 %237, i32* %22, i32* %23, i32* %24, i32* %7, i32* %8, i8* %20)
br label %242
242: ; preds = %240, %227
%243 = icmp eq i32 %232, %219
br i1 %243, label %244, label %227
244: ; preds = %242
%245 = sub i32 %226, %219
br label %246
246: ; preds = %207, %244, %215
%247 = phi i32 [ %222, %215 ], [ %222, %244 ], [ %183, %207 ]
%248 = phi i64 [ %223, %215 ], [ %223, %244 ], [ %196, %207 ]
%249 = phi i32 [ %218, %215 ], [ %218, %244 ], [ %182, %207 ]
%250 = phi i8 [ %217, %215 ], [ %217, %244 ], [ %181, %207 ]
%251 = phi i64 [ %216, %215 ], [ %216, %244 ], [ %180, %207 ]
%252 = phi i32 [ %77, %215 ], [ %245, %244 ], [ %77, %207 ]
%253 = phi i32 [ %220, %215 ], [ %237, %244 ], [ %211, %207 ]
%254 = phi i32 [ %221, %215 ], [ %235, %244 ], [ %209, %207 ]
%255 = zext i32 %247 to i64
%256 = add i64 %82, %255
%257 = icmp sgt i32 %252, 0
br i1 %257, label %76, label %258
258: ; preds = %246
%259 = icmp sgt i32 %249, 1
br i1 %259, label %260, label %313
260: ; preds = %258
%261 = zext i32 %249 to i64
%262 = add nsw i64 %261, -1
%263 = and i64 %261, 3
%264 = icmp ult i64 %262, 3
br i1 %264, label %296, label %265
265: ; preds = %260
%266 = and i64 %261, 4294967292
br label %267
267: ; preds = %267, %265
%268 = phi i64 [ 0, %265 ], [ %293, %267 ]
%269 = phi i64 [ 0, %265 ], [ %294, %267 ]
%270 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 %268
%271 = load i8, i8* %270
%272 = load i8*, i8** %75
%273 = add i64 %251, %268
%274 = getelementptr inbounds i8, i8* %272, i64 %273
store i8 %271, i8* %274
%275 = or i64 %268, 1
%276 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 %275
%277 = load i8, i8* %276
%278 = load i8*, i8** %75
%279 = add i64 %251, %275
%280 = getelementptr inbounds i8, i8* %278, i64 %279
store i8 %277, i8* %280
%281 = or i64 %268, 2
%282 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 %281
%283 = load i8, i8* %282
%284 = load i8*, i8** %75
%285 = add i64 %251, %281
%286 = getelementptr inbounds i8, i8* %284, i64 %285
store i8 %283, i8* %286
%287 = or i64 %268, 3
%288 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 %287
%289 = load i8, i8* %288
%290 = load i8*, i8** %75
%291 = add i64 %251, %287
%292 = getelementptr inbounds i8, i8* %290, i64 %291
store i8 %289, i8* %292
%293 = add nuw nsw i64 %268, 4
%294 = add i64 %269, 4
%295 = icmp eq i64 %294, %266
br i1 %295, label %296, label %267
296: ; preds = %267, %260
%297 = phi i64 [ 0, %260 ], [ %293, %267 ]
%298 = icmp eq i64 %263, 0
br i1 %298, label %310, label %299
299: ; preds = %296, %299
%300 = phi i64 [ %307, %299 ], [ %297, %296 ]
%301 = phi i64 [ %308, %299 ], [ 0, %296 ]
%302 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 %300
%303 = load i8, i8* %302
%304 = load i8*, i8** %75
%305 = add i64 %251, %300
%306 = getelementptr inbounds i8, i8* %304, i64 %305
store i8 %303, i8* %306
%307 = add nuw nsw i64 %300, 1
%308 = add i64 %301, 1
%309 = icmp eq i64 %308, %263
br i1 %309, label %310, label %299
310: ; preds = %299, %296
%311 = sext i32 %249 to i64
%312 = add i64 %251, %311
br label %313
313: ; preds = %310, %258
%314 = phi i64 [ %312, %310 ], [ %251, %258 ]
%315 = uitofp i64 %256 to double
%316 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %315)
%317 = uitofp i64 %314 to double
%318 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %317)
%319 = fdiv double %317, %315
%320 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %319)
%321 = trunc i64 %314 to i32
br label %322
322: ; preds = %313, %64
%323 = phi i64 [ %74, %313 ], [ %65, %64 ]
%324 = phi i32 [ %321, %313 ], [ 0, %64 ]
%325 = getelementptr inbounds i32, i32* %5, i64 %323
store i32 %324, i32* %325
ret void
}