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

/* Variables and functions */
int /*<<< orphan*/ add_entry(unsigned char *, int);
int /*<<< orphan*/ assert(int);
unsigned char *calloc(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fwrite(short *, int, int, int /*<<< orphan*/ *);
int lookup_entry(unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  assert(argc == 2);
  FILE *fpIn = NULL;
  FILE *fpOut = NULL;
  fpIn = fopen(argv[1], "rb");
  char outputFile[256];
  strcpy(outputFile, argv[1]);
  strcat(outputFile, ".lzw");
  fpOut = fopen(outputFile, "wb");
  assert(fpIn != NULL);
  assert(fpOut != NULL);
  for (unsigned int i = 0; i < 256; i++) {
    unsigned char *temp = calloc(sizeof(*temp), 1);
    memcpy(temp, (unsigned char *)&i, 1);
    add_entry(temp, 1);
  }
  unsigned char *previous = NULL;
  unsigned char *current = NULL;
  int strLen = 1;
  previous = calloc(sizeof(*previous), strLen);
  current = calloc(sizeof(*current), 1);
  fread(previous, sizeof(*previous), strLen, fpIn);
  while (fread(current, sizeof(*current), 1, fpIn)) {
    unsigned char *temp = calloc(sizeof(*temp), strLen + 1);
    for (int i = 0; i < strLen; i++) {
      temp[i] = previous[i];
    }
    temp[strLen] = current[0];
    if (lookup_entry(temp, strLen + 1) == -1) {
      short int stringVal = lookup_entry(previous, strLen);
      fwrite(&stringVal, sizeof(stringVal), 1, fpOut);
      add_entry(temp, strLen + 1);
      free(previous);
      previous = NULL;
      strLen = 1;
      previous = calloc(sizeof(*previous), strLen);
      *previous = *current;
      assert(previous[0] == current[0]);
    } else {
      strLen++;
      free(previous);
      previous = temp;
    }
    current = calloc(sizeof(*current), 1);
  };
  short int stringVal = lookup_entry(previous, strLen);
  fwrite(&stringVal, sizeof(stringVal), 1, fpOut);
  fclose(fpIn);
  fclose(fpOut);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf7(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
lea    -0x120(%rbp),%rdi
lea    0xdcf(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x120(%rbp),%rdi
lea    0xdc1(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
movl   $0x0,-0x124(%rbp)
cmpl   $0x100,-0x124(%rbp)
jae    12de <main+0x11e>
mov    $0x1,%esi
mov    %esi,%edi
call   1070 <calloc@plt>
mov    %rax,-0x130(%rbp)
mov    -0x130(%rbp),%rdi
lea    -0x124(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <memcpy@plt>
mov    -0x130(%rbp),%rdi
mov    $0x1,%esi
call   1080 <add_entry@plt>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    127e <main+0xbe>
movq   $0x0,-0x138(%rbp)
movq   $0x0,-0x140(%rbp)
movl   $0x1,-0x144(%rbp)
mov    -0x144(%rbp),%esi
mov    $0x1,%edi
call   1070 <calloc@plt>
mov    %rax,-0x138(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1070 <calloc@plt>
mov    %rax,-0x140(%rbp)
mov    -0x138(%rbp),%rdi
mov    -0x144(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    -0x140(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1050 <fread@plt>
cmp    $0x0,%rax
je     1503 <main+0x343>
mov    -0x144(%rbp),%esi
add    $0x1,%esi
mov    $0x1,%edi
call   1070 <calloc@plt>
mov    %rax,-0x150(%rbp)
movl   $0x0,-0x154(%rbp)
mov    -0x154(%rbp),%eax
cmp    -0x144(%rbp),%eax
jge    13d0 <main+0x210>
mov    -0x138(%rbp),%rax
movslq -0x154(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x150(%rbp),%rax
movslq -0x154(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
jmp    1388 <main+0x1c8>
mov    -0x140(%rbp),%rax
mov    (%rax),%dl
mov    -0x150(%rbp),%rax
movslq -0x144(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x150(%rbp),%rdi
mov    -0x144(%rbp),%esi
add    $0x1,%esi
call   10b0 <lookup_entry@plt>
cmp    $0xffffffff,%eax
jne    14c2 <main+0x302>
mov    -0x138(%rbp),%rdi
mov    -0x144(%rbp),%esi
call   10b0 <lookup_entry@plt>
mov    %ax,-0x156(%rbp)
mov    -0x20(%rbp),%rcx
lea    -0x156(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    -0x150(%rbp),%rdi
mov    -0x144(%rbp),%esi
add    $0x1,%esi
call   1080 <add_entry@plt>
mov    -0x138(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x138(%rbp)
movl   $0x1,-0x144(%rbp)
mov    -0x144(%rbp),%esi
mov    $0x1,%edi
call   1070 <calloc@plt>
mov    %rax,-0x138(%rbp)
mov    -0x140(%rbp),%rax
mov    (%rax),%cl
mov    -0x138(%rbp),%rax
mov    %cl,(%rax)
mov    -0x138(%rbp),%rax
movzbl (%rax),%eax
mov    -0x140(%rbp),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
jmp    14eb <main+0x32b>
mov    -0x144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x144(%rbp)
mov    -0x138(%rbp),%rdi
call   1030 <free@plt>
mov    -0x150(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1070 <calloc@plt>
mov    %rax,-0x140(%rbp)
jmp    1343 <main+0x183>
mov    -0x138(%rbp),%rdi
mov    -0x144(%rbp),%esi
call   10b0 <lookup_entry@plt>
mov    %ax,-0x158(%rbp)
mov    -0x20(%rbp),%rcx
lea    -0x158(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rsi,%rbx
xor    %eax,%eax
cmp    $0x2,%edi
sete   %al
mov    %eax,%edi
call   1090 <assert@plt>
mov    0x8(%rbx),%rdi
lea    0xe12(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbp
mov    0x8(%rbx),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0xdf5(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
lea    0xdeb(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    %rbp,0x10(%rsp)
test   %rbp,%rbp
setne  %dil
call   1090 <assert@plt>
xor    %edi,%edi
mov    %rbx,0x18(%rsp)
test   %rbx,%rbx
setne  %dil
call   1090 <assert@plt>
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   10a0 <memcpy@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
call   1080 <add_entry@plt>
mov    0xc(%rsp),%eax
add    $0x1,%eax
mov    %eax,0xc(%rsp)
cmp    $0x100,%eax
jb     1260 <main+0xa0>
mov    $0x1,%r13d
mov    $0x1,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%r15
mov    $0x1,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    0x10(%rsp),%rbx
mov    %rbx,%rcx
call   1050 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
test   %rax,%rax
je     15a0 <main+0x3e0>
mov    $0x1,%r14d
jmp    136f <main+0x1af>
nopl   0x0(%rax,%rax,1)
mov    (%r12),%al
movslq %r14d,%rcx
mov    %al,0x0(%rbp,%rcx,1)
mov    %rbp,%rdi
mov    %r13d,%esi
call   10b0 <lookup_entry@plt>
cmp    $0xffffffff,%eax
je     1420 <main+0x260>
mov    %r15,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    0x10(%rsp),%rcx
call   1050 <fread@plt>
mov    %r13d,%r14d
mov    %rbp,%r15
test   %rax,%rax
je     15a3 <main+0x3e3>
lea    0x1(%r14),%r13d
mov    $0x1,%edi
mov    %r13d,%esi
call   1070 <calloc@plt>
mov    %rax,%rbp
test   %r14d,%r14d
jle    1310 <main+0x150>
mov    %r14d,%eax
cmp    $0x8,%r14d
jb     13ab <main+0x1eb>
lea    (%r15,%rax,1),%rcx
cmp    %rcx,%rbp
jae    148a <main+0x2ca>
lea    (%rax,%rbp,1),%rcx
cmp    %rcx,%r15
jae    148a <main+0x2ca>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
add    %rax,%rdx
mov    %rax,%rsi
and    $0x3,%rsi
je     13d3 <main+0x213>
nop
movzbl (%r15,%rcx,1),%ebx
mov    %bl,0x0(%rbp,%rcx,1)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    13c0 <main+0x200>
cmp    $0x3,%rdx
jb     1310 <main+0x150>
nopl   (%rax)
movzbl (%r15,%rcx,1),%edx
mov    %dl,0x0(%rbp,%rcx,1)
movzbl 0x1(%r15,%rcx,1),%edx
mov    %dl,0x1(%rbp,%rcx,1)
movzbl 0x2(%r15,%rcx,1),%edx
mov    %dl,0x2(%rbp,%rcx,1)
movzbl 0x3(%r15,%rcx,1),%edx
mov    %dl,0x3(%rbp,%rcx,1)
add    $0x4,%rcx
cmp    %rcx,%rax
jne    13e0 <main+0x220>
jmp    1310 <main+0x150>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %r14d,%esi
call   10b0 <lookup_entry@plt>
mov    %ax,0xc(%rsp)
lea    0xc(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    0x18(%rsp),%rcx
call   10e0 <fwrite@plt>
mov    %rbp,%rdi
mov    %r13d,%esi
call   1080 <add_entry@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%rbp
mov    (%r12),%al
mov    %al,0x0(%rbp)
mov    $0x1,%edi
call   1090 <assert@plt>
mov    $0x1,%r13d
jmp    1337 <main+0x177>
cmp    $0x20,%r14d
jae    1497 <main+0x2d7>
xor    %ecx,%ecx
jmp    156c <main+0x3ac>
mov    %eax,%ecx
and    $0xffffffe0,%ecx
lea    -0x20(%rcx),%rdi
mov    %rdi,%rsi
shr    $0x5,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x3,%edx
cmp    $0x60,%rdi
jae    14ba <main+0x2fa>
xor    %edi,%edi
jmp    1521 <main+0x361>
and    $0xfffffffffffffffc,%rsi
xor    %edi,%edi
movups (%r15,%rdi,1),%xmm0
movups 0x10(%r15,%rdi,1),%xmm1
movups %xmm0,0x0(%rbp,%rdi,1)
movups %xmm1,0x10(%rbp,%rdi,1)
movups 0x20(%r15,%rdi,1),%xmm0
movups 0x30(%r15,%rdi,1),%xmm1
movups %xmm0,0x20(%rbp,%rdi,1)
movups %xmm1,0x30(%rbp,%rdi,1)
movups 0x40(%r15,%rdi,1),%xmm0
movups 0x50(%r15,%rdi,1),%xmm1
movups %xmm0,0x40(%rbp,%rdi,1)
movups %xmm1,0x50(%rbp,%rdi,1)
movups 0x60(%r15,%rdi,1),%xmm0
movups 0x70(%r15,%rdi,1),%xmm1
movups %xmm0,0x60(%rbp,%rdi,1)
movups %xmm1,0x70(%rbp,%rdi,1)
sub    $0xffffffffffffff80,%rdi
add    $0xfffffffffffffffc,%rsi
jne    14c0 <main+0x300>
test   %rdx,%rdx
je     155b <main+0x39b>
lea    (%rdi,%rbp,1),%rsi
add    $0x10,%rsi
add    %r15,%rdi
add    $0x10,%rdi
shl    $0x5,%rdx
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movups -0x10(%rdi,%rbx,1),%xmm0
movups (%rdi,%rbx,1),%xmm1
movups %xmm0,-0x10(%rsi,%rbx,1)
movups %xmm1,(%rsi,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%rdx
jne    1540 <main+0x380>
cmp    %rax,%rcx
je     1310 <main+0x150>
test   $0x18,%al
je     13ad <main+0x1ed>
mov    %rcx,%rdx
mov    %eax,%ecx
and    $0xfffffff8,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%rdx,1),%rsi
mov    %rsi,0x0(%rbp,%rdx,1)
add    $0x8,%rdx
cmp    %rdx,%rcx
jne    1580 <main+0x3c0>
cmp    %rax,%rcx
je     1310 <main+0x150>
jmp    13ad <main+0x1ed>
mov    %r15,%rbp
mov    %rbp,%rdi
mov    %r13d,%esi
call   10b0 <lookup_entry@plt>
mov    %ax,0xc(%rsp)
lea    0xc(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    0x18(%rsp),%rbx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    0x10(%rsp),%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [5 x i8] c".lzw\00"
@.str.2 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [256 x i8]
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i16
%17 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 2
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
store i32* null, i32** %6
store i32* null, i32** %7
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %25, i32** %6
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @strcpy(i8* %26, i8* %29)
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%32 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %34, i32** %7
%35 = load i32*, i32** %6
%36 = icmp ne i32* %35, null
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i32*, i32** %7
%40 = icmp ne i32* %39, null
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
store i32 0, i32* %9
br label %43
43: ; preds = %53, %2
%44 = load i32, i32* %9
%45 = icmp ult i32 %44, 256
br i1 %45, label %46, label %56
46: ; preds = %43
%47 = call i8* @calloc(i32 1, i32 1)
store i8* %47, i8** %10
%48 = load i8*, i8** %10
%49 = bitcast i32* %9 to i8*
%50 = call i32 @memcpy(i8* %48, i8* %49, i32 1)
%51 = load i8*, i8** %10
%52 = call i32 @add_entry(i8* %51, i32 1)
br label %53
53: ; preds = %46
%54 = load i32, i32* %9
%55 = add i32 %54, 1
store i32 %55, i32* %9
br label %43
56: ; preds = %43
store i8* null, i8** %11
store i8* null, i8** %12
store i32 1, i32* %13
%57 = load i32, i32* %13
%58 = call i8* @calloc(i32 1, i32 %57)
store i8* %58, i8** %11
%59 = call i8* @calloc(i32 1, i32 1)
store i8* %59, i8** %12
%60 = load i8*, i8** %11
%61 = load i32, i32* %13
%62 = load i32*, i32** %6
%63 = call i64 @fread(i8* %60, i32 1, i32 %61, i32* %62)
br label %64
64: ; preds = %138, %56
%65 = load i8*, i8** %12
%66 = load i32*, i32** %6
%67 = call i64 @fread(i8* %65, i32 1, i32 1, i32* %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %140
69: ; preds = %64
%70 = load i32, i32* %13
%71 = add nsw i32 %70, 1
%72 = call i8* @calloc(i32 1, i32 %71)
store i8* %72, i8** %14
store i32 0, i32* %15
br label %73
73: ; preds = %87, %69
%74 = load i32, i32* %15
%75 = load i32, i32* %13
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %90
77: ; preds = %73
%78 = load i8*, i8** %11
%79 = load i32, i32* %15
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %78, i64 %80
%82 = load i8, i8* %81
%83 = load i8*, i8** %14
%84 = load i32, i32* %15
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
store i8 %82, i8* %86
br label %87
87: ; preds = %77
%88 = load i32, i32* %15
%89 = add nsw i32 %88, 1
store i32 %89, i32* %15
br label %73
90: ; preds = %73
%91 = load i8*, i8** %12
%92 = getelementptr inbounds i8, i8* %91, i64 0
%93 = load i8, i8* %92
%94 = load i8*, i8** %14
%95 = load i32, i32* %13
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
store i8 %93, i8* %97
%98 = load i8*, i8** %14
%99 = load i32, i32* %13
%100 = add nsw i32 %99, 1
%101 = call i32 @lookup_entry(i8* %98, i32 %100)
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %132
103: ; preds = %90
%104 = load i8*, i8** %11
%105 = load i32, i32* %13
%106 = call i32 @lookup_entry(i8* %104, i32 %105)
%107 = trunc i32 %106 to i16
store i16 %107, i16* %16
%108 = load i32*, i32** %7
%109 = call i32 @fwrite(i16* %16, i32 2, i32 1, i32* %108)
%110 = load i8*, i8** %14
%111 = load i32, i32* %13
%112 = add nsw i32 %111, 1
%113 = call i32 @add_entry(i8* %110, i32 %112)
%114 = load i8*, i8** %11
%115 = call i32 @free(i8* %114)
store i8* null, i8** %11
store i32 1, i32* %13
%116 = load i32, i32* %13
%117 = call i8* @calloc(i32 1, i32 %116)
store i8* %117, i8** %11
%118 = load i8*, i8** %12
%119 = load i8, i8* %118
%120 = load i8*, i8** %11
store i8 %119, i8* %120
%121 = load i8*, i8** %11
%122 = getelementptr inbounds i8, i8* %121, i64 0
%123 = load i8, i8* %122
%124 = zext i8 %123 to i32
%125 = load i8*, i8** %12
%126 = getelementptr inbounds i8, i8* %125, i64 0
%127 = load i8, i8* %126
%128 = zext i8 %127 to i32
%129 = icmp eq i32 %124, %128
%130 = zext i1 %129 to i32
%131 = call i32 @assert(i32 %130)
br label %138
132: ; preds = %90
%133 = load i32, i32* %13
%134 = add nsw i32 %133, 1
store i32 %134, i32* %13
%135 = load i8*, i8** %11
%136 = call i32 @free(i8* %135)
%137 = load i8*, i8** %14
store i8* %137, i8** %11
br label %138
138: ; preds = %132, %103
%139 = call i8* @calloc(i32 1, i32 1)
store i8* %139, i8** %12
br label %64
140: ; preds = %64
%141 = load i8*, i8** %11
%142 = load i32, i32* %13
%143 = call i32 @lookup_entry(i8* %141, i32 %142)
%144 = trunc i32 %143 to i16
store i16 %144, i16* %17
%145 = load i32*, i32** %7
%146 = call i32 @fwrite(i16* %17, i32 2, i32 1, i32* %145)
%147 = load i32*, i32** %6
%148 = call i32 @fclose(i32* %147)
%149 = load i32*, i32** %7
%150 = call i32 @fclose(i32* %149)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [5 x i8] c".lzw\00"
@.str.2 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca i16
%6 = alloca i16
%7 = icmp eq i32 %0, 2
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%14 = load i8*, i8** %10
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp ne i32* %12, null
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = icmp ne i32* %17, null
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = bitcast i32* %4 to i8*
store i32 0, i32* %4
br label %33
25: ; preds = %33
%26 = call dereferenceable_or_null(1) i8* @calloc(i32 1, i32 1)
%27 = call dereferenceable_or_null(1) i8* @calloc(i32 1, i32 1)
%28 = call i64 @fread(i8* %26, i32 1, i32 1, i32* %12)
%29 = call i64 @fread(i8* %27, i32 1, i32 1, i32* %12)
%30 = icmp eq i64 %29, 0
br i1 %30, label %215, label %31
31: ; preds = %25
%32 = bitcast i16* %5 to i8*
br label %40
33: ; preds = %2, %33
%34 = call dereferenceable_or_null(1) i8* @calloc(i32 1, i32 1)
%35 = call i32 @memcpy(i8* %34, i8* %24, i32 1)
%36 = call i32 @add_entry(i8* %34, i32 1)
%37 = load i32, i32* %4
%38 = add i32 %37, 1
store i32 %38, i32* %4
%39 = icmp ult i32 %38, 256
br i1 %39, label %33, label %25
40: ; preds = %31, %209
%41 = phi i32 [ 1, %31 ], [ %211, %209 ]
%42 = phi i8* [ %27, %31 ], [ %212, %209 ]
%43 = phi i8* [ %26, %31 ], [ %210, %209 ]
%44 = add nsw i32 %41, 1
%45 = call i8* @calloc(i32 1, i32 %44)
%46 = icmp sgt i32 %41, 0
br i1 %46, label %47, label %173
47: ; preds = %40
%48 = zext i32 %41 to i64
%49 = icmp ult i32 %41, 8
br i1 %49, label %155, label %50
50: ; preds = %47
%51 = getelementptr i8, i8* %45, i64 %48
%52 = getelementptr i8, i8* %43, i64 %48
%53 = icmp ult i8* %45, %52
%54 = icmp ult i8* %43, %51
%55 = and i1 %53, %54
br i1 %55, label %155, label %56
56: ; preds = %50
%57 = icmp ult i32 %41, 32
br i1 %57, label %140, label %58
58: ; preds = %56
%59 = and i64 %48, 4294967264
%60 = add nsw i64 %59, -32
%61 = lshr exact i64 %60, 5
%62 = add nuw nsw i64 %61, 1
%63 = and i64 %62, 3
%64 = icmp ult i64 %60, 96
br i1 %64, label %116, label %65
65: ; preds = %58
%66 = and i64 %62, 1152921504606846972
br label %67
67: ; preds = %67, %65
%68 = phi i64 [ 0, %65 ], [ %113, %67 ]
%69 = phi i64 [ 0, %65 ], [ %114, %67 ]
%70 = getelementptr inbounds i8, i8* %43, i64 %68
%71 = bitcast i8* %70 to <16 x i8>*
%72 = load <16 x i8>, <16 x i8>* %71
%73 = getelementptr inbounds i8, i8* %70, i64 16
%74 = bitcast i8* %73 to <16 x i8>*
%75 = load <16 x i8>, <16 x i8>* %74
%76 = getelementptr inbounds i8, i8* %45, i64 %68
%77 = bitcast i8* %76 to <16 x i8>*
store <16 x i8> %72, <16 x i8>* %77
%78 = getelementptr inbounds i8, i8* %76, i64 16
%79 = bitcast i8* %78 to <16 x i8>*
store <16 x i8> %75, <16 x i8>* %79
%80 = or i64 %68, 32
%81 = getelementptr inbounds i8, i8* %43, i64 %80
%82 = bitcast i8* %81 to <16 x i8>*
%83 = load <16 x i8>, <16 x i8>* %82
%84 = getelementptr inbounds i8, i8* %81, i64 16
%85 = bitcast i8* %84 to <16 x i8>*
%86 = load <16 x i8>, <16 x i8>* %85
%87 = getelementptr inbounds i8, i8* %45, i64 %80
%88 = bitcast i8* %87 to <16 x i8>*
store <16 x i8> %83, <16 x i8>* %88
%89 = getelementptr inbounds i8, i8* %87, i64 16
%90 = bitcast i8* %89 to <16 x i8>*
store <16 x i8> %86, <16 x i8>* %90
%91 = or i64 %68, 64
%92 = getelementptr inbounds i8, i8* %43, i64 %91
%93 = bitcast i8* %92 to <16 x i8>*
%94 = load <16 x i8>, <16 x i8>* %93
%95 = getelementptr inbounds i8, i8* %92, i64 16
%96 = bitcast i8* %95 to <16 x i8>*
%97 = load <16 x i8>, <16 x i8>* %96
%98 = getelementptr inbounds i8, i8* %45, i64 %91
%99 = bitcast i8* %98 to <16 x i8>*
store <16 x i8> %94, <16 x i8>* %99
%100 = getelementptr inbounds i8, i8* %98, i64 16
%101 = bitcast i8* %100 to <16 x i8>*
store <16 x i8> %97, <16 x i8>* %101
%102 = or i64 %68, 96
%103 = getelementptr inbounds i8, i8* %43, i64 %102
%104 = bitcast i8* %103 to <16 x i8>*
%105 = load <16 x i8>, <16 x i8>* %104
%106 = getelementptr inbounds i8, i8* %103, i64 16
%107 = bitcast i8* %106 to <16 x i8>*
%108 = load <16 x i8>, <16 x i8>* %107
%109 = getelementptr inbounds i8, i8* %45, i64 %102
%110 = bitcast i8* %109 to <16 x i8>*
store <16 x i8> %105, <16 x i8>* %110
%111 = getelementptr inbounds i8, i8* %109, i64 16
%112 = bitcast i8* %111 to <16 x i8>*
store <16 x i8> %108, <16 x i8>* %112
%113 = add nuw i64 %68, 128
%114 = add i64 %69, 4
%115 = icmp eq i64 %114, %66
br i1 %115, label %116, label %67
116: ; preds = %67, %58
%117 = phi i64 [ 0, %58 ], [ %113, %67 ]
%118 = icmp eq i64 %63, 0
br i1 %118, label %135, label %119
119: ; preds = %116, %119
%120 = phi i64 [ %132, %119 ], [ %117, %116 ]
%121 = phi i64 [ %133, %119 ], [ 0, %116 ]
%122 = getelementptr inbounds i8, i8* %43, i64 %120
%123 = bitcast i8* %122 to <16 x i8>*
%124 = load <16 x i8>, <16 x i8>* %123
%125 = getelementptr inbounds i8, i8* %122, i64 16
%126 = bitcast i8* %125 to <16 x i8>*
%127 = load <16 x i8>, <16 x i8>* %126
%128 = getelementptr inbounds i8, i8* %45, i64 %120
%129 = bitcast i8* %128 to <16 x i8>*
store <16 x i8> %124, <16 x i8>* %129
%130 = getelementptr inbounds i8, i8* %128, i64 16
%131 = bitcast i8* %130 to <16 x i8>*
store <16 x i8> %127, <16 x i8>* %131
%132 = add nuw i64 %120, 32
%133 = add i64 %121, 1
%134 = icmp eq i64 %133, %63
br i1 %134, label %135, label %119
135: ; preds = %119, %116
%136 = icmp eq i64 %59, %48
br i1 %136, label %173, label %137
137: ; preds = %135
%138 = and i64 %48, 24
%139 = icmp eq i64 %138, 0
br i1 %139, label %155, label %140
140: ; preds = %56, %137
%141 = phi i64 [ %59, %137 ], [ 0, %56 ]
%142 = zext i32 %41 to i64
%143 = and i64 %142, 4294967288
br label %144
144: ; preds = %144, %140
%145 = phi i64 [ %141, %140 ], [ %151, %144 ]
%146 = getelementptr inbounds i8, i8* %43, i64 %145
%147 = bitcast i8* %146 to <8 x i8>*
%148 = load <8 x i8>, <8 x i8>* %147
%149 = getelementptr inbounds i8, i8* %45, i64 %145
%150 = bitcast i8* %149 to <8 x i8>*
store <8 x i8> %148, <8 x i8>* %150
%151 = add nuw i64 %145, 8
%152 = icmp eq i64 %151, %143
br i1 %152, label %153, label %144
153: ; preds = %144
%154 = icmp eq i64 %143, %142
br i1 %154, label %173, label %155
155: ; preds = %50, %47, %137, %153
%156 = phi i64 [ 0, %47 ], [ 0, %50 ], [ %59, %137 ], [ %143, %153 ]
%157 = xor i64 %156, -1
%158 = add nsw i64 %157, %48
%159 = and i64 %48, 3
%160 = icmp eq i64 %159, 0
br i1 %160, label %170, label %161
161: ; preds = %155, %161
%162 = phi i64 [ %167, %161 ], [ %156, %155 ]
%163 = phi i64 [ %168, %161 ], [ 0, %155 ]
%164 = getelementptr inbounds i8, i8* %43, i64 %162
%165 = load i8, i8* %164
%166 = getelementptr inbounds i8, i8* %45, i64 %162
store i8 %165, i8* %166
%167 = add nuw nsw i64 %162, 1
%168 = add i64 %163, 1
%169 = icmp eq i64 %168, %159
br i1 %169, label %170, label %161
170: ; preds = %161, %155
%171 = phi i64 [ %156, %155 ], [ %167, %161 ]
%172 = icmp ult i64 %158, 3
br i1 %172, label %173, label %179
173: ; preds = %170, %179, %135, %153, %40
%174 = load i8, i8* %42
%175 = sext i32 %41 to i64
%176 = getelementptr inbounds i8, i8* %45, i64 %175
store i8 %174, i8* %176
%177 = call i32 @lookup_entry(i8* %45, i32 %44)
%178 = icmp eq i32 %177, -1
br i1 %178, label %198, label %207
179: ; preds = %170, %179
%180 = phi i64 [ %196, %179 ], [ %171, %170 ]
%181 = getelementptr inbounds i8, i8* %43, i64 %180
%182 = load i8, i8* %181
%183 = getelementptr inbounds i8, i8* %45, i64 %180
store i8 %182, i8* %183
%184 = add nuw nsw i64 %180, 1
%185 = getelementptr inbounds i8, i8* %43, i64 %184
%186 = load i8, i8* %185
%187 = getelementptr inbounds i8, i8* %45, i64 %184
store i8 %186, i8* %187
%188 = add nuw nsw i64 %180, 2
%189 = getelementptr inbounds i8, i8* %43, i64 %188
%190 = load i8, i8* %189
%191 = getelementptr inbounds i8, i8* %45, i64 %188
store i8 %190, i8* %191
%192 = add nuw nsw i64 %180, 3
%193 = getelementptr inbounds i8, i8* %43, i64 %192
%194 = load i8, i8* %193
%195 = getelementptr inbounds i8, i8* %45, i64 %192
store i8 %194, i8* %195
%196 = add nuw nsw i64 %180, 4
%197 = icmp eq i64 %196, %48
br i1 %197, label %173, label %179
198: ; preds = %173
%199 = call i32 @lookup_entry(i8* %43, i32 %41)
%200 = trunc i32 %199 to i16
store i16 %200, i16* %5
%201 = call i32 @fwrite(i16* %5, i32 2, i32 1, i32* %17)
%202 = call i32 @add_entry(i8* %45, i32 %44)
%203 = call i32 @free(i8* %43)
%204 = call dereferenceable_or_null(1) i8* @calloc(i32 1, i32 1)
%205 = load i8, i8* %42
store i8 %205, i8* %204
%206 = call i32 @assert(i32 1)
br label %209
207: ; preds = %173
%208 = call i32 @free(i8* %43)
br label %209
209: ; preds = %207, %198
%210 = phi i8* [ %204, %198 ], [ %45, %207 ]
%211 = phi i32 [ 1, %198 ], [ %44, %207 ]
%212 = call dereferenceable_or_null(1) i8* @calloc(i32 1, i32 1)
%213 = call i64 @fread(i8* %212, i32 1, i32 1, i32* %12)
%214 = icmp eq i64 %213, 0
br i1 %214, label %215, label %40
215: ; preds = %209, %25
%216 = phi i8* [ %26, %25 ], [ %210, %209 ]
%217 = phi i32 [ 1, %25 ], [ %211, %209 ]
%218 = bitcast i16* %6 to i8*
%219 = call i32 @lookup_entry(i8* %216, i32 %217)
%220 = trunc i32 %219 to i16
store i16 %220, i16* %6
%221 = call i32 @fwrite(i16* %6, i32 2, i32 1, i32* %17)
%222 = call i32 @fclose(i32* %12)
%223 = call i32 @fclose(i32* %17)
ret i32 0
}