#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
long fread(unsigned char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fwrite(unsigned char *, int, unsigned long,
                          int /*<<< orphan*/ *);
unsigned char *malloc(long);
unsigned long mmini_compress(unsigned char *, unsigned long, unsigned char *,
                             unsigned long, unsigned char *, unsigned long,
                             unsigned char *);
unsigned long mmini_decompress(unsigned char *, unsigned long, unsigned char *,
                               unsigned long, unsigned char *, unsigned long,
                               unsigned char *);
unsigned long mmini_huffman_compress(unsigned char *, unsigned long,
                                     unsigned char *, unsigned long,
                                     unsigned char *);
unsigned long mmini_huffman_decompress(unsigned char *, unsigned long,
                                       unsigned char *, unsigned long,
                                       unsigned char *);
unsigned long mmini_lzl_compress(unsigned char *, unsigned long,
                                 unsigned char *, unsigned long);
unsigned long mmini_lzl_decompress(unsigned char *, unsigned long,
                                   unsigned char *, unsigned long);
int /*<<< orphan*/ print_help(int, char **);
int /*<<< orphan*/ printf(char *, ...);
unsigned char *realloc(unsigned char *, long);
int main(int argc, char **argv) {
  unsigned long r;
  long n, inptr = 0, insize = 65536;
  unsigned char *in, *out, *tmp, *huffheap;
  FILE *inf, *outf;
  if (argc != 4) {
    print_help(argc, argv);
    return -1;
  }
  inf = fopen(argv[2], "r");
  if (!inf) {
    printf("Could not open %s for reading.\n", argv[2]);
    return -1;
  }
  outf = fopen(argv[3], "w");
  if (!outf) {
    fclose(inf);
    printf("Could not open %s for writing.\n", argv[3]);
    return -1;
  }
  in = malloc(insize);
  while ((n = fread(in + inptr, 1, insize - inptr, inf)) > 0) {
    inptr += n;
    if ((insize - inptr) <= 16384)
      in = realloc(in, insize *= 2);
  }
  huffheap = malloc(
      ((sizeof(double) * 257) +
       (((sizeof(void *) * 4) + sizeof(double) + sizeof(int)) * (257 * 3)) +
       ((sizeof(long) + sizeof(int)) * 257)));
  tmp = malloc(insize + 4096);
  out = malloc(insize + 4096);
  switch (*argv[1]) {
  case 'c':
    r = mmini_compress(in, (unsigned long)inptr, tmp,
                       (unsigned long)insize + 4096, out,
                       (unsigned long)insize + 4096, huffheap);
    if (!r) {
      printf("Compression failed!\n");
      return -1;
    } else
      fwrite(out, 1, r, outf);
    break;
  case 'd':
    r = mmini_decompress(in, (unsigned long)inptr, tmp,
                         (unsigned long)insize + 4096, out,
                         (unsigned long)insize + 4096, huffheap);
    if (!r) {
      printf("Decompression failed!\n");
      return -1;
    } else
      fwrite(out, 1, r, outf);
    break;
  case 'H':
    r = mmini_huffman_compress(in, (unsigned long)inptr, out,
                               (unsigned long)insize + 4096, huffheap);
    if (!r) {
      printf("Compression failed!\n");
      return -1;
    } else
      fwrite(out, 1, r, outf);
    break;
  case 'h':
    r = mmini_huffman_decompress(in, (unsigned long)inptr, out,
                                 (unsigned long)insize + 4096, huffheap);
    if (!r) {
      printf("Decompression failed!\n");
      return -1;
    } else
      fwrite(out, 1, r, outf);
    break;
  case 'L':
    r = mmini_lzl_compress(in, (unsigned long)inptr, out,
                           (unsigned long)insize + 4096);
    if (!r) {
      printf("Compression failed!\n");
      return -1;
    } else
      fwrite(out, 1, r, outf);
    break;
  case 'l':
    r = mmini_lzl_decompress(in, (unsigned long)inptr, out,
                             (unsigned long)insize + 4096);
    if (!r) {
      printf("Decompression failed!\n");
      return -1;
    } else
      fwrite(out, 1, r, outf);
    break;
  default:
    print_help(argc, argv);
    return -1;
  }
  fclose(inf);
  fclose(outf);
  free(out);
  free(tmp);
  free(huffheap);
  free(in);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x10000,-0x30(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1238 <main+0x48>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10f0 <print_help@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1674 <main+0x484>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe4d(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    127d <main+0x8d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1674 <main+0x484>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe2a(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    12cb <main+0xdb>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1674 <main+0x484>
mov    -0x30(%rbp),%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
add    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rdx
sub    -0x28(%rbp),%rdx
mov    -0x58(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jle    1342 <main+0x152>
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
cmp    $0x4000,%rax
jg     133d <main+0x14d>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
shl    $0x1,%rsi
mov    %rsi,-0x30(%rbp)
call   10d0 <realloc@plt>
mov    %rax,-0x38(%rbp)
jmp    12d8 <main+0xe8>
mov    $0x9898,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rdi
add    $0x1000,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
add    $0x1000,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
add    $0xffffffb8,%eax
mov    %eax,%ecx
mov    %rcx,-0x68(%rbp)
sub    $0x24,%eax
ja     161f <main+0x42f>
mov    -0x68(%rbp),%rax
lea    0xc60(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x30(%rbp),%rcx
add    $0x1000,%rcx
mov    -0x40(%rbp),%r8
mov    -0x30(%rbp),%r9
add    $0x1000,%r9
mov    -0x50(%rbp),%rax
mov    %rax,(%rsp)
call   1080 <mmini_compress@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1405 <main+0x215>
lea    0xce6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1674 <main+0x484>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
jmp    1637 <main+0x447>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x30(%rbp),%rcx
add    $0x1000,%rcx
mov    -0x40(%rbp),%r8
mov    -0x30(%rbp),%r9
add    $0x1000,%r9
mov    -0x50(%rbp),%rax
mov    %rax,(%rsp)
call   10c0 <mmini_decompress@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    147c <main+0x28c>
lea    0xc84(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1674 <main+0x484>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
jmp    1637 <main+0x447>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x30(%rbp),%rcx
add    $0x1000,%rcx
mov    -0x50(%rbp),%r8
call   10a0 <mmini_huffman_compress@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    14e0 <main+0x2f0>
lea    0xc0b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1674 <main+0x484>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
jmp    1637 <main+0x447>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x30(%rbp),%rcx
add    $0x1000,%rcx
mov    -0x50(%rbp),%r8
call   1110 <mmini_huffman_decompress@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1544 <main+0x354>
lea    0xbbc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1674 <main+0x484>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
jmp    1637 <main+0x447>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x30(%rbp),%rcx
add    $0x1000,%rcx
call   1060 <mmini_lzl_compress@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    15a4 <main+0x3b4>
lea    0xb47(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1674 <main+0x484>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
jmp    1637 <main+0x447>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x30(%rbp),%rcx
add    $0x1000,%rcx
call   1090 <mmini_lzl_decompress@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1604 <main+0x414>
lea    0xafc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1674 <main+0x484>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
jmp    1637 <main+0x447>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10f0 <print_help@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1674 <main+0x484>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x60(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@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    $0x28,%rsp
mov    %rsi,%r12
cmp    $0x4,%edi
jne    137f <main+0x17f>
mov    0x10(%r12),%rdi
lea    0xe6e(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     12d7 <main+0xd7>
mov    %rax,%r14
mov    0x18(%r12),%rdi
lea    0xe73(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     12e5 <main+0xe5>
mov    %rax,0x20(%rsp)
mov    $0x10000,%ebx
mov    $0x10000,%edi
call   10c0 <malloc@plt>
mov    %rax,%r13
mov    $0x10000,%edx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r14,%rcx
call   1050 <fread@plt>
test   %rax,%rax
jle    1305 <main+0x105>
mov    $0x10000,%ebx
xor    %r15d,%r15d
jmp    12a6 <main+0xa6>
lea    (%r15,%r13,1),%rdi
mov    $0x1,%esi
mov    %r14,%rcx
call   1050 <fread@plt>
test   %rax,%rax
jle    1308 <main+0x108>
mov    %r15,%rcx
mov    %rax,%r15
add    %rcx,%r15
mov    %rbx,%rdx
sub    %r15,%rdx
cmp    $0x4000,%rdx
jg     1290 <main+0x90>
add    %rbx,%rbx
mov    %r13,%rdi
mov    %rbx,%rsi
call   10e0 <realloc@plt>
mov    %rax,%r13
mov    %rbx,%rdx
sub    %r15,%rdx
jmp    1290 <main+0x90>
mov    0x10(%r12),%rsi
lea    0xdb3(%rip),%rdi
jmp    12f9 <main+0xf9>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    0x18(%r12),%rsi
lea    0xdbf(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1387 <main+0x187>
xor    %r15d,%r15d
mov    $0x9898,%edi
call   10c0 <malloc@plt>
mov    %rax,0x10(%rsp)
add    $0x1000,%rbx
mov    %rbx,%rdi
call   10c0 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    %rbx,%rdi
call   10c0 <malloc@plt>
mov    %rax,%rbp
mov    0x8(%r12),%rax
movsbl (%rax),%eax
add    $0xffffffb8,%eax
cmp    $0x24,%eax
ja     137a <main+0x17a>
lea    0xcb3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    0x10(%rsp),%r12
mov    %r12,%r8
call   10b0 <mmini_huffman_compress@plt>
test   %rax,%rax
jne    1435 <main+0x235>
jmp    13df <main+0x1df>
mov    $0x4,%edi
mov    %r12,%rsi
call   1100 <print_help@plt>
mov    $0xffffffff,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1070 <mmini_lzl_compress@plt>
test   %rax,%rax
mov    0x10(%rsp),%r12
jne    1435 <main+0x235>
jmp    13df <main+0x1df>
mov    0x10(%rsp),%r12
mov    %r12,(%rsp)
mov    %r13,%rdi
mov    %r15,%rsi
mov    0x18(%rsp),%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
mov    %rbx,%r9
call   1090 <mmini_compress@plt>
test   %rax,%rax
jne    1435 <main+0x235>
lea    0xd08(%rip),%rdi
jmp    14a8 <main+0x2a8>
mov    0x10(%rsp),%r12
mov    %r12,(%rsp)
mov    %r13,%rdi
mov    %r15,%rsi
mov    0x18(%rsp),%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
mov    %rbx,%r9
call   10d0 <mmini_decompress@plt>
test   %rax,%rax
jne    1435 <main+0x235>
jmp    14a1 <main+0x2a1>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    0x10(%rsp),%r12
mov    %r12,%r8
call   1120 <mmini_huffman_decompress@plt>
test   %rax,%rax
je     14a1 <main+0x2a1>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
mov    0x20(%rsp),%rbx
mov    %rbx,%rcx
call   1110 <fwrite@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    138c <main+0x18c>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   10a0 <mmini_lzl_decompress@plt>
test   %rax,%rax
mov    0x10(%rsp),%r12
jne    1435 <main+0x235>
lea    0xc30(%rip),%rdi
call   1040 <puts@plt>
jmp    1387 <main+0x187>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [32 x i8] c"Could not open %s for reading.\0A\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [32 x i8] c"Could not open %s for writing.\0A\00"
@.str.4 = [21 x i8] c"Compression failed!\0A\00"
@.str.5 = [23 x i8] c"Decompression failed!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32*
%15 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %8
store i64 65536, i64* %9
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 4
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i32 @print_help(i32 %19, i8** %20)
store i32 -1, i32* %3
br label %217
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %26, i32** %14
%27 = load i32*, i32** %14
%28 = icmp ne i32* %27, null
br i1 %28, label %34, label %29
29: ; preds = %22
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %32)
store i32 -1, i32* %3
br label %217
34: ; preds = %22
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %38, i32** %15
%39 = load i32*, i32** %15
%40 = icmp ne i32* %39, null
br i1 %40, label %48, label %41
41: ; preds = %34
%42 = load i32*, i32** %14
%43 = call i32 @fclose(i32* %42)
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 3
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %46)
store i32 -1, i32* %3
br label %217
48: ; preds = %34
%49 = load i64, i64* %9
%50 = call i8* @malloc(i64 %49)
store i8* %50, i8** %10
br label %51
51: ; preds = %74, %48
%52 = load i8*, i8** %10
%53 = load i64, i64* %8
%54 = getelementptr inbounds i8, i8* %52, i64 %53
%55 = load i64, i64* %9
%56 = load i64, i64* %8
%57 = sub nsw i64 %55, %56
%58 = load i32*, i32** %14
%59 = call i64 @fread(i8* %54, i32 1, i64 %57, i32* %58)
store i64 %59, i64* %7
%60 = icmp sgt i64 %59, 0
br i1 %60, label %61, label %75
61: ; preds = %51
%62 = load i64, i64* %7
%63 = load i64, i64* %8
%64 = add nsw i64 %63, %62
store i64 %64, i64* %8
%65 = load i64, i64* %9
%66 = load i64, i64* %8
%67 = sub nsw i64 %65, %66
%68 = icmp sle i64 %67, 16384
br i1 %68, label %69, label %74
69: ; preds = %61
%70 = load i8*, i8** %10
%71 = load i64, i64* %9
%72 = mul nsw i64 %71, 2
store i64 %72, i64* %9
%73 = call i8* @realloc(i8* %70, i64 %72)
store i8* %73, i8** %10
br label %74
74: ; preds = %69, %61
br label %51
75: ; preds = %51
%76 = call i8* @malloc(i64 39064)
store i8* %76, i8** %13
%77 = load i64, i64* %9
%78 = add nsw i64 %77, 4096
%79 = call i8* @malloc(i64 %78)
store i8* %79, i8** %12
%80 = load i64, i64* %9
%81 = add nsw i64 %80, 4096
%82 = call i8* @malloc(i64 %81)
store i8* %82, i8** %11
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 1
%85 = load i8*, i8** %84
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
switch i32 %87, label %200 [
i32 99, label %88
i32 100, label %109
i32 72, label %130
i32 104, label %148
i32 76, label %166
i32 108, label %183
]
88: ; preds = %75
%89 = load i8*, i8** %10
%90 = load i64, i64* %8
%91 = load i8*, i8** %12
%92 = load i64, i64* %9
%93 = add i64 %92, 4096
%94 = load i8*, i8** %11
%95 = load i64, i64* %9
%96 = add i64 %95, 4096
%97 = load i8*, i8** %13
%98 = call i64 @mmini_compress(i8* %89, i64 %90, i8* %91, i64 %93, i8* %94, i64 %96, i8* %97)
store i64 %98, i64* %6
%99 = load i64, i64* %6
%100 = icmp ne i64 %99, 0
br i1 %100, label %103, label %101
101: ; preds = %88
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %217
103: ; preds = %88
%104 = load i8*, i8** %11
%105 = load i64, i64* %6
%106 = load i32*, i32** %15
%107 = call i32 @fwrite(i8* %104, i32 1, i64 %105, i32* %106)
br label %108
108: ; preds = %103
br label %204
109: ; preds = %75
%110 = load i8*, i8** %10
%111 = load i64, i64* %8
%112 = load i8*, i8** %12
%113 = load i64, i64* %9
%114 = add i64 %113, 4096
%115 = load i8*, i8** %11
%116 = load i64, i64* %9
%117 = add i64 %116, 4096
%118 = load i8*, i8** %13
%119 = call i64 @mmini_decompress(i8* %110, i64 %111, i8* %112, i64 %114, i8* %115, i64 %117, i8* %118)
store i64 %119, i64* %6
%120 = load i64, i64* %6
%121 = icmp ne i64 %120, 0
br i1 %121, label %124, label %122
122: ; preds = %109
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %217
124: ; preds = %109
%125 = load i8*, i8** %11
%126 = load i64, i64* %6
%127 = load i32*, i32** %15
%128 = call i32 @fwrite(i8* %125, i32 1, i64 %126, i32* %127)
br label %129
129: ; preds = %124
br label %204
130: ; preds = %75
%131 = load i8*, i8** %10
%132 = load i64, i64* %8
%133 = load i8*, i8** %11
%134 = load i64, i64* %9
%135 = add i64 %134, 4096
%136 = load i8*, i8** %13
%137 = call i64 @mmini_huffman_compress(i8* %131, i64 %132, i8* %133, i64 %135, i8* %136)
store i64 %137, i64* %6
%138 = load i64, i64* %6
%139 = icmp ne i64 %138, 0
br i1 %139, label %142, label %140
140: ; preds = %130
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %217
142: ; preds = %130
%143 = load i8*, i8** %11
%144 = load i64, i64* %6
%145 = load i32*, i32** %15
%146 = call i32 @fwrite(i8* %143, i32 1, i64 %144, i32* %145)
br label %147
147: ; preds = %142
br label %204
148: ; preds = %75
%149 = load i8*, i8** %10
%150 = load i64, i64* %8
%151 = load i8*, i8** %11
%152 = load i64, i64* %9
%153 = add i64 %152, 4096
%154 = load i8*, i8** %13
%155 = call i64 @mmini_huffman_decompress(i8* %149, i64 %150, i8* %151, i64 %153, i8* %154)
store i64 %155, i64* %6
%156 = load i64, i64* %6
%157 = icmp ne i64 %156, 0
br i1 %157, label %160, label %158
158: ; preds = %148
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %217
160: ; preds = %148
%161 = load i8*, i8** %11
%162 = load i64, i64* %6
%163 = load i32*, i32** %15
%164 = call i32 @fwrite(i8* %161, i32 1, i64 %162, i32* %163)
br label %165
165: ; preds = %160
br label %204
166: ; preds = %75
%167 = load i8*, i8** %10
%168 = load i64, i64* %8
%169 = load i8*, i8** %11
%170 = load i64, i64* %9
%171 = add i64 %170, 4096
%172 = call i64 @mmini_lzl_compress(i8* %167, i64 %168, i8* %169, i64 %171)
store i64 %172, i64* %6
%173 = load i64, i64* %6
%174 = icmp ne i64 %173, 0
br i1 %174, label %177, label %175
175: ; preds = %166
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %217
177: ; preds = %166
%178 = load i8*, i8** %11
%179 = load i64, i64* %6
%180 = load i32*, i32** %15
%181 = call i32 @fwrite(i8* %178, i32 1, i64 %179, i32* %180)
br label %182
182: ; preds = %177
br label %204
183: ; preds = %75
%184 = load i8*, i8** %10
%185 = load i64, i64* %8
%186 = load i8*, i8** %11
%187 = load i64, i64* %9
%188 = add i64 %187, 4096
%189 = call i64 @mmini_lzl_decompress(i8* %184, i64 %185, i8* %186, i64 %188)
store i64 %189, i64* %6
%190 = load i64, i64* %6
%191 = icmp ne i64 %190, 0
br i1 %191, label %194, label %192
192: ; preds = %183
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %217
194: ; preds = %183
%195 = load i8*, i8** %11
%196 = load i64, i64* %6
%197 = load i32*, i32** %15
%198 = call i32 @fwrite(i8* %195, i32 1, i64 %196, i32* %197)
br label %199
199: ; preds = %194
br label %204
200: ; preds = %75
%201 = load i32, i32* %4
%202 = load i8**, i8*** %5
%203 = call i32 @print_help(i32 %201, i8** %202)
store i32 -1, i32* %3
br label %217
204: ; preds = %199, %182, %165, %147, %129, %108
%205 = load i32*, i32** %14
%206 = call i32 @fclose(i32* %205)
%207 = load i32*, i32** %15
%208 = call i32 @fclose(i32* %207)
%209 = load i8*, i8** %11
%210 = call i32 @free(i8* %209)
%211 = load i8*, i8** %12
%212 = call i32 @free(i8* %211)
%213 = load i8*, i8** %13
%214 = call i32 @free(i8* %213)
%215 = load i8*, i8** %10
%216 = call i32 @free(i8* %215)
store i32 0, i32* %3
br label %217
217: ; preds = %204, %200, %192, %175, %158, %140, %122, %101, %41, %29, %18
%218 = load i32, i32* %3
ret i32 %218
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [32 x i8] c"Could not open %s for reading.\0A\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [32 x i8] c"Could not open %s for writing.\0A\00"
@str.9 = [22 x i8] c"Decompression failed!\00"
@str.10 = [20 x i8] c"Compression failed!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @print_help(i32 %0, i8** %1)
br label %99
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %99
14: ; preds = %6
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = tail call i32 @fclose(i32* %9)
%21 = load i8*, i8** %15
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %21)
br label %99
23: ; preds = %14
%24 = tail call dereferenceable_or_null(65536) i8* @malloc(i64 65536)
%25 = tail call i64 @fread(i8* %24, i32 1, i64 65536, i32* %9)
%26 = icmp sgt i64 %25, 0
br i1 %26, label %27, label %46
27: ; preds = %23, %39
%28 = phi i64 [ %44, %39 ], [ %25, %23 ]
%29 = phi i64 [ %32, %39 ], [ 0, %23 ]
%30 = phi i64 [ %42, %39 ], [ 65536, %23 ]
%31 = phi i8* [ %41, %39 ], [ %24, %23 ]
%32 = add nsw i64 %28, %29
%33 = sub nsw i64 %30, %32
%34 = icmp slt i64 %33, 16385
br i1 %34, label %35, label %39
35: ; preds = %27
%36 = shl nsw i64 %30, 1
%37 = tail call i8* @realloc(i8* %31, i64 %36)
%38 = sub nsw i64 %36, %32
br label %39
39: ; preds = %35, %27
%40 = phi i64 [ %38, %35 ], [ %33, %27 ]
%41 = phi i8* [ %37, %35 ], [ %31, %27 ]
%42 = phi i64 [ %36, %35 ], [ %30, %27 ]
%43 = getelementptr inbounds i8, i8* %41, i64 %32
%44 = tail call i64 @fread(i8* %43, i32 1, i64 %40, i32* %9)
%45 = icmp sgt i64 %44, 0
br i1 %45, label %27, label %46
46: ; preds = %39, %23
%47 = phi i8* [ %24, %23 ], [ %41, %39 ]
%48 = phi i64 [ 65536, %23 ], [ %42, %39 ]
%49 = phi i64 [ 0, %23 ], [ %32, %39 ]
%50 = tail call dereferenceable_or_null(39064) i8* @malloc(i64 39064)
%51 = add nsw i64 %48, 4096
%52 = tail call i8* @malloc(i64 %51)
%53 = tail call i8* @malloc(i64 %51)
%54 = getelementptr inbounds i8*, i8** %1, i64 1
%55 = load i8*, i8** %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
switch i32 %57, label %88 [
i32 99, label %58
i32 100, label %63
i32 72, label %68
i32 104, label %73
i32 76, label %78
i32 108, label %83
]
58: ; preds = %46
%59 = tail call i64 @mmini_compress(i8* %47, i64 %49, i8* %52, i64 %51, i8* %53, i64 %51, i8* %50)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %90
61: ; preds = %58
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
br label %99
63: ; preds = %46
%64 = tail call i64 @mmini_decompress(i8* %47, i64 %49, i8* %52, i64 %51, i8* %53, i64 %51, i8* %50)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %90
66: ; preds = %63
%67 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
br label %99
68: ; preds = %46
%69 = tail call i64 @mmini_huffman_compress(i8* %47, i64 %49, i8* %53, i64 %51, i8* %50)
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %90
71: ; preds = %68
%72 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
br label %99
73: ; preds = %46
%74 = tail call i64 @mmini_huffman_decompress(i8* %47, i64 %49, i8* %53, i64 %51, i8* %50)
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %90
76: ; preds = %73
%77 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
br label %99
78: ; preds = %46
%79 = tail call i64 @mmini_lzl_compress(i8* %47, i64 %49, i8* %53, i64 %51)
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %90
81: ; preds = %78
%82 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
br label %99
83: ; preds = %46
%84 = tail call i64 @mmini_lzl_decompress(i8* %47, i64 %49, i8* %53, i64 %51)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %90
86: ; preds = %83
%87 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
br label %99
88: ; preds = %46
%89 = tail call i32 @print_help(i32 4, i8** %1)
br label %99
90: ; preds = %83, %78, %73, %68, %63, %58
%91 = phi i64 [ %59, %58 ], [ %64, %63 ], [ %69, %68 ], [ %74, %73 ], [ %79, %78 ], [ %84, %83 ]
%92 = tail call i32 @fwrite(i8* %53, i32 1, i64 %91, i32* %17)
%93 = tail call i32 @fclose(i32* %9)
%94 = tail call i32 @fclose(i32* %17)
%95 = tail call i32 @free(i8* %53)
%96 = tail call i32 @free(i8* %52)
%97 = tail call i32 @free(i8* %50)
%98 = tail call i32 @free(i8* %47)
br label %99
99: ; preds = %90, %88, %86, %81, %76, %71, %66, %61, %19, %11, %4
%100 = phi i32 [ -1, %4 ], [ -1, %88 ], [ 0, %90 ], [ -1, %86 ], [ -1, %81 ], [ -1, %76 ], [ -1, %71 ], [ -1, %66 ], [ -1, %61 ], [ -1, %19 ], [ -1, %11 ]
ret i32 %100
}