#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*/ appack(char *, char *);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *in(char *, int *);
int /*<<< orphan*/ lz4wpack(char *, char *);
int /*<<< orphan*/ out(unsigned char *, int, int, int, int, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ remove(char *);
unsigned char *packEx(unsigned char *data, int inOffset, int size, int intSize,
                      int *outSize, int *method) {
  unsigned char *src;
  unsigned char *result;
  unsigned char *results[2 + 1];
  int sizes[2 + 1];
  int minSize;
  int autoSelect;
  int i;
  results[0] = data;
  sizes[0] = size;
  if (!out(data, inOffset, size, intSize, (intSize > 1) ? 1 : 0, "pack.in")) {
    *outSize = 0;
    return 0;
  }
  src = in("pack.in", outSize);
  if (src == 0) {
    *outSize = 0;
    return 0;
  }
  for (i = 1; i <= 2; i++)
    results[i] = 0;
  autoSelect = (*method == -1);
  for (i = 1; i <= 2; i++) {
    if (autoSelect || (*method == i)) {
      switch (i) {
      case 1:
        if (appack("pack.in", "pack.out"))
          results[1] = in("pack.out", &sizes[1]);
        break;
      case 2:
        if (lz4wpack("pack.in", "pack.out"))
          results[2] = in("pack.out", &sizes[2]);
        break;
      }
    }
  }
  minSize = sizes[0];
  result = results[0];
  *method = 0;
  for (i = 1; i <= 2; i++) {
    if (results[i] != 0) {
      if (sizes[i] < minSize) {
        minSize = sizes[i];
        result = results[i];
        *method = i;
      }
    }
  }
  switch (*method) {
  case 1:
    printf("Packed with APLIB, ");
    break;
  case 2:
    printf("Packed with LZ4W, ");
    break;
  default:
    printf("No compression, ");
  }
  printf("original size = %d compressed to %d (%g %%)\n", size, minSize,
         (minSize * 100.0) / (float)size);
  *outSize = minSize;
  for (i = 0; i <= 2; i++) {
    if ((results[i] != 0) && (results[i] != result))
      free(results[i]);
  }
  remove("pack.in");
  remove("pack.out");
  return result;
}


x86 assembly (clang, -O0):
<packEx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%r9d
xor    %r8d,%r8d
mov    $0x1,%eax
cmp    $0x1,%r9d
cmovg  %eax,%r8d
lea    0xe42(%rip),%r9
call   1070 <out@plt>
cmp    $0x0,%eax
jne    11eb <packEx+0x7b>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    14c7 <packEx+0x357>
mov    -0x28(%rbp),%rsi
lea    0xe12(%rip),%rdi
call   1090 <in@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1221 <packEx+0xb1>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    14c7 <packEx+0x357>
movl   $0x1,-0x78(%rbp)
cmpl   $0x2,-0x78(%rbp)
jg     124d <packEx+0xdd>
movslq -0x78(%rbp),%rax
movq   $0x0,-0x60(%rbp,%rax,8)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1228 <packEx+0xb8>
mov    -0x30(%rbp),%rax
cmpl   $0xffffffff,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x74(%rbp)
movl   $0x1,-0x78(%rbp)
cmpl   $0x2,-0x78(%rbp)
jg     1338 <packEx+0x1c8>
cmpl   $0x0,-0x74(%rbp)
jne    1289 <packEx+0x119>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
cmp    -0x78(%rbp),%eax
jne    1325 <packEx+0x1b5>
mov    -0x78(%rbp),%eax
mov    %eax,-0x7c(%rbp)
sub    $0x1,%eax
je     12ae <packEx+0x13e>
jmp    129d <packEx+0x12d>
mov    -0x7c(%rbp),%eax
sub    $0x2,%eax
je     12e7 <packEx+0x177>
jmp    1320 <packEx+0x1b0>
lea    0xd53(%rip),%rdi
lea    0xd54(%rip),%rsi
call   1060 <appack@plt>
cmp    $0x0,%eax
je     12e2 <packEx+0x172>
lea    -0x6c(%rbp),%rsi
add    $0x4,%rsi
lea    0xd37(%rip),%rdi
call   1090 <in@plt>
mov    %rax,-0x58(%rbp)
jmp    1320 <packEx+0x1b0>
lea    0xd1a(%rip),%rdi
lea    0xd1b(%rip),%rsi
call   1080 <lz4wpack@plt>
cmp    $0x0,%eax
je     131b <packEx+0x1ab>
lea    -0x6c(%rbp),%rsi
add    $0x8,%rsi
lea    0xcfe(%rip),%rdi
call   1090 <in@plt>
mov    %rax,-0x50(%rbp)
jmp    1320 <packEx+0x1b0>
jmp    1325 <packEx+0x1b5>
jmp    132a <packEx+0x1ba>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1266 <packEx+0xf6>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x78(%rbp)
cmpl   $0x2,-0x78(%rbp)
jg     13bb <packEx+0x24b>
movslq -0x78(%rbp),%rax
cmpq   $0x0,-0x60(%rbp,%rax,8)
je     13a8 <packEx+0x238>
movslq -0x78(%rbp),%rax
mov    -0x6c(%rbp,%rax,4),%eax
cmp    -0x70(%rbp),%eax
jge    13a3 <packEx+0x233>
movslq -0x78(%rbp),%rax
mov    -0x6c(%rbp,%rax,4),%eax
mov    %eax,-0x70(%rbp)
movslq -0x78(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x78(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
jmp    13a8 <packEx+0x238>
jmp    13ad <packEx+0x23d>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1357 <packEx+0x1e7>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
sub    $0x1,%eax
je     13e3 <packEx+0x273>
jmp    13d2 <packEx+0x262>
mov    -0x80(%rbp),%eax
sub    $0x2,%eax
je     13f6 <packEx+0x286>
jmp    1409 <packEx+0x299>
lea    0xc2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1417 <packEx+0x2a7>
lea    0xc30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1417 <packEx+0x2a7>
lea    0xc30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%esi
mov    -0x70(%rbp),%edx
cvtsi2sdl -0x70(%rbp),%xmm0
movsd  0xbd6(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2ssl -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
lea    0xc0f(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x70(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x78(%rbp)
cmpl   $0x2,-0x78(%rbp)
jg     14a7 <packEx+0x337>
movslq -0x78(%rbp),%rax
cmpq   $0x0,-0x60(%rbp,%rax,8)
je     1494 <packEx+0x324>
movslq -0x78(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rax
cmp    -0x40(%rbp),%rax
je     1494 <packEx+0x324>
movslq -0x78(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
call   1030 <free@plt>
jmp    1499 <packEx+0x329>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1459 <packEx+0x2e9>
lea    0xb5a(%rip),%rdi
call   1040 <remove@plt>
lea    0xb56(%rip),%rdi
call   1040 <remove@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<packEx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%r15
mov    %r8,%rbp
mov    %edx,%r13d
mov    %rdi,%r12
mov    %edx,0xc(%rsp)
xor    %r8d,%r8d
cmp    $0x2,%ecx
setge  %r8b
lea    0xe69(%rip),%r9
call   1070 <out@plt>
test   %eax,%eax
je     1203 <packEx+0x93>
lea    0xe59(%rip),%rdi
mov    %rbp,%rsi
call   1090 <in@plt>
test   %rax,%rax
je     1203 <packEx+0x93>
mov    (%r15),%ebx
cmp    $0xffffffff,%ebx
mov    %rbp,0x20(%rsp)
je     11ce <packEx+0x5e>
cmp    $0x1,%ebx
jne    1211 <packEx+0xa1>
lea    0xe33(%rip),%rdi
lea    0xe34(%rip),%rsi
call   1060 <appack@plt>
test   %eax,%eax
je     121d <packEx+0xad>
lea    0x10(%rsp),%rsi
lea    0xe1f(%rip),%rdi
call   1090 <in@plt>
cmp    $0xffffffff,%ebx
je     1224 <packEx+0xb4>
cmpl   $0x2,(%r15)
jne    1219 <packEx+0xa9>
jmp    1224 <packEx+0xb4>
movl   $0x0,0x0(%rbp)
xor    %ebx,%ebx
jmp    134a <packEx+0x1da>
xor    %eax,%eax
cmpl   $0x2,(%r15)
je     1224 <packEx+0xb4>
xor    %ebp,%ebp
jmp    1259 <packEx+0xe9>
xor    %eax,%eax
cmp    $0xffffffff,%ebx
jne    11fb <packEx+0x8b>
mov    %rax,%rbx
lea    0xdda(%rip),%rdi
lea    0xddb(%rip),%rsi
call   1080 <lz4wpack@plt>
test   %eax,%eax
je     1254 <packEx+0xe4>
lea    0x14(%rsp),%rsi
lea    0xdc6(%rip),%rdi
call   1090 <in@plt>
mov    %rax,%rbp
jmp    1256 <packEx+0xe6>
xor    %ebp,%ebp
mov    %rbx,%rax
mov    0xc(%rsp),%r14d
movl   $0x0,(%r15)
lea    0xdd4(%rip),%rdi
test   %rax,%rax
je     1293 <packEx+0x123>
mov    0x10(%rsp),%ecx
mov    %r12,%rbx
cmp    %r14d,%ecx
jge    1296 <packEx+0x126>
movl   $0x1,(%r15)
lea    0xd8e(%rip),%rdi
mov    %rax,%rbx
mov    %ecx,%r14d
jmp    1296 <packEx+0x126>
mov    %r12,%rbx
test   %rbp,%rbp
mov    %rax,0x18(%rsp)
je     12bd <packEx+0x14d>
mov    0x14(%rsp),%eax
cmp    %r14d,%eax
jge    12bd <packEx+0x14d>
movl   $0x2,(%r15)
lea    0xd76(%rip),%rdi
mov    %eax,%r14d
mov    %rbp,%rbx
xor    %eax,%eax
call   1050 <printf@plt>
cvtsi2sd %r14d,%xmm0
cvtsi2ss %r13d,%xmm1
mulsd  0xd2a(%rip),%xmm0
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
lea    0xd6c(%rip),%rdi
mov    %r13d,%esi
mov    %r14d,%edx
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x20(%rsp),%rax
mov    %r14d,(%rax)
test   %r12,%r12
je     130c <packEx+0x19c>
cmp    %r12,%rbx
je     130c <packEx+0x19c>
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
test   %rdi,%rdi
je     1320 <packEx+0x1b0>
cmp    %rbx,%rdi
je     1320 <packEx+0x1b0>
call   1030 <free@plt>
test   %rbp,%rbp
je     1332 <packEx+0x1c2>
cmp    %rbx,%rbp
je     1332 <packEx+0x1c2>
mov    %rbp,%rdi
call   1030 <free@plt>
lea    0xccf(%rip),%rdi
call   1040 <remove@plt>
lea    0xccb(%rip),%rdi
call   1040 <remove@plt>
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"pack.in\00"
@.str.1 = [9 x i8] c"pack.out\00"
@.str.2 = [20 x i8] c"Packed with APLIB, \00"
@.str.3 = [19 x i8] c"Packed with LZ4W, \00"
@.str.4 = [17 x i8] c"No compression, \00"
@.str.5 = [45 x i8] c"original size = %d compressed to %d (%g %%)\0A\00"
define i8* @packEx(i8* %0, i32 %1, i32 %2, i32 %3, i32* %4, i32* %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca [3 x i8*]
%17 = alloca [3 x i32]
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i8* %0, i8** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32* %4, i32** %12
store i32* %5, i32** %13
%21 = load i8*, i8** %8
%22 = getelementptr inbounds [3 x i8*], [3 x i8*]* %16, i64 0, i64 0
store i8* %21, i8** %22
%23 = load i32, i32* %10
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0, i64 0
store i32 %23, i32* %24
%25 = load i8*, i8** %8
%26 = load i32, i32* %9
%27 = load i32, i32* %10
%28 = load i32, i32* %11
%29 = load i32, i32* %11
%30 = icmp sgt i32 %29, 1
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 1, i32 0
%33 = call i32 @out(i8* %25, i32 %26, i32 %27, i32 %28, i32 %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %6
%36 = load i32*, i32** %12
store i32 0, i32* %36
store i8* null, i8** %7
br label %184
37: ; preds = %6
%38 = load i32*, i32** %12
%39 = call i8* @in(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %38)
store i8* %39, i8** %14
%40 = load i8*, i8** %14
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = load i32*, i32** %12
store i32 0, i32* %43
store i8* null, i8** %7
br label %184
44: ; preds = %37
store i32 1, i32* %20
br label %45
45: ; preds = %52, %44
%46 = load i32, i32* %20
%47 = icmp sle i32 %46, 2
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = load i32, i32* %20
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [3 x i8*], [3 x i8*]* %16, i64 0, i64 %50
store i8* null, i8** %51
br label %52
52: ; preds = %48
%53 = load i32, i32* %20
%54 = add nsw i32 %53, 1
store i32 %54, i32* %20
br label %45
55: ; preds = %45
%56 = load i32*, i32** %13
%57 = load i32, i32* %56
%58 = icmp eq i32 %57, -1
%59 = zext i1 %58 to i32
store i32 %59, i32* %19
store i32 1, i32* %20
br label %60
60: ; preds = %91, %55
%61 = load i32, i32* %20
%62 = icmp sle i32 %61, 2
br i1 %62, label %63, label %94
63: ; preds = %60
%64 = load i32, i32* %19
%65 = icmp ne i32 %64, 0
br i1 %65, label %71, label %66
66: ; preds = %63
%67 = load i32*, i32** %13
%68 = load i32, i32* %67
%69 = load i32, i32* %20
%70 = icmp eq i32 %68, %69
br i1 %70, label %71, label %90
71: ; preds = %66, %63
%72 = load i32, i32* %20
switch i32 %72, label %89 [
i32 1, label %73
i32 2, label %81
]
73: ; preds = %71
%74 = call i32 @appack(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %73
%77 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0, i64 1
%78 = call i8* @in(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %77)
%79 = getelementptr inbounds [3 x i8*], [3 x i8*]* %16, i64 0, i64 1
store i8* %78, i8** %79
br label %80
80: ; preds = %76, %73
br label %89
81: ; preds = %71
%82 = call i32 @lz4wpack(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %88
84: ; preds = %81
%85 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0, i64 2
%86 = call i8* @in(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %85)
%87 = getelementptr inbounds [3 x i8*], [3 x i8*]* %16, i64 0, i64 2
store i8* %86, i8** %87
br label %88
88: ; preds = %84, %81
br label %89
89: ; preds = %71, %88, %80
br label %90
90: ; preds = %89, %66
br label %91
91: ; preds = %90
%92 = load i32, i32* %20
%93 = add nsw i32 %92, 1
store i32 %93, i32* %20
br label %60
94: ; preds = %60
%95 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0, i64 0
%96 = load i32, i32* %95
store i32 %96, i32* %18
%97 = getelementptr inbounds [3 x i8*], [3 x i8*]* %16, i64 0, i64 0
%98 = load i8*, i8** %97
store i8* %98, i8** %15
%99 = load i32*, i32** %13
store i32 0, i32* %99
store i32 1, i32* %20
br label %100
100: ; preds = %129, %94
%101 = load i32, i32* %20
%102 = icmp sle i32 %101, 2
br i1 %102, label %103, label %132
103: ; preds = %100
%104 = load i32, i32* %20
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [3 x i8*], [3 x i8*]* %16, i64 0, i64 %105
%107 = load i8*, i8** %106
%108 = icmp ne i8* %107, null
br i1 %108, label %109, label %128
109: ; preds = %103
%110 = load i32, i32* %20
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0, i64 %111
%113 = load i32, i32* %112
%114 = load i32, i32* %18
%115 = icmp slt i32 %113, %114
br i1 %115, label %116, label %127
116: ; preds = %109
%117 = load i32, i32* %20
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0, i64 %118
%120 = load i32, i32* %119
store i32 %120, i32* %18
%121 = load i32, i32* %20
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [3 x i8*], [3 x i8*]* %16, i64 0, i64 %122
%124 = load i8*, i8** %123
store i8* %124, i8** %15
%125 = load i32, i32* %20
%126 = load i32*, i32** %13
store i32 %125, i32* %126
br label %127
127: ; preds = %116, %109
br label %128
128: ; preds = %127, %103
br label %129
129: ; preds = %128
%130 = load i32, i32* %20
%131 = add nsw i32 %130, 1
store i32 %131, i32* %20
br label %100
132: ; preds = %100
%133 = load i32*, i32** %13
%134 = load i32, i32* %133
switch i32 %134, label %139 [
i32 1, label %135
i32 2, label %137
]
135: ; preds = %132
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %141
137: ; preds = %132
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %141
139: ; preds = %132
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %141
141: ; preds = %139, %137, %135
%142 = load i32, i32* %10
%143 = load i32, i32* %18
%144 = load i32, i32* %18
%145 = sitofp i32 %144 to double
%146 = fmul double %145, 1.000000e+02
%147 = load i32, i32* %10
%148 = sitofp i32 %147 to float
%149 = fpext float %148 to double
%150 = fdiv double %146, %149
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %142, i32 %143, double %150)
%152 = load i32, i32* %18
%153 = load i32*, i32** %12
store i32 %152, i32* %153
store i32 0, i32* %20
br label %154
154: ; preds = %177, %141
%155 = load i32, i32* %20
%156 = icmp sle i32 %155, 2
br i1 %156, label %157, label %180
157: ; preds = %154
%158 = load i32, i32* %20
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds [3 x i8*], [3 x i8*]* %16, i64 0, i64 %159
%161 = load i8*, i8** %160
%162 = icmp ne i8* %161, null
br i1 %162, label %163, label %176
163: ; preds = %157
%164 = load i32, i32* %20
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds [3 x i8*], [3 x i8*]* %16, i64 0, i64 %165
%167 = load i8*, i8** %166
%168 = load i8*, i8** %15
%169 = icmp ne i8* %167, %168
br i1 %169, label %170, label %176
170: ; preds = %163
%171 = load i32, i32* %20
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [3 x i8*], [3 x i8*]* %16, i64 0, i64 %172
%174 = load i8*, i8** %173
%175 = call i32 @free(i8* %174)
br label %176
176: ; preds = %170, %163, %157
br label %177
177: ; preds = %176
%178 = load i32, i32* %20
%179 = add nsw i32 %178, 1
store i32 %179, i32* %20
br label %154
180: ; preds = %154
%181 = call i32 @remove(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%182 = call i32 @remove(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%183 = load i8*, i8** %15
store i8* %183, i8** %7
br label %184
184: ; preds = %180, %42, %35
%185 = load i8*, i8** %7
ret i8* %185
}

LLVM IR (-O2):
@.str = [8 x i8] c"pack.in\00"
@.str.1 = [9 x i8] c"pack.out\00"
@.str.2 = [20 x i8] c"Packed with APLIB, \00"
@.str.3 = [19 x i8] c"Packed with LZ4W, \00"
@.str.4 = [17 x i8] c"No compression, \00"
@.str.5 = [45 x i8] c"original size = %d compressed to %d (%g %%)\0A\00"
define i8* @packEx(i8* %0, i32 %1, i32 %2, i32 %3, i32* %4, i32* nocapture %5) {
%7 = alloca [3 x i32]
%8 = bitcast [3 x i32]* %7 to i8*
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
store i32 %2, i32* %9
%10 = icmp sgt i32 %3, 1
%11 = zext i1 %10 to i32
%12 = tail call i32 @out(i8* %0, i32 %1, i32 %2, i32 %3, i32 %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %6
store i32 0, i32* %4
br label %88
15: ; preds = %6
%16 = tail call i8* @in(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %4)
%17 = icmp eq i8* %16, null
br i1 %17, label %23, label %18
18: ; preds = %15
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, -1
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
switch i32 %19, label %31 [
i32 -1, label %24
i32 1, label %24
]
23: ; preds = %15
store i32 0, i32* %4
br label %88
24: ; preds = %18, %18
%25 = call i32 @appack(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = call i8* @in(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %22)
br label %29
29: ; preds = %24, %27
%30 = phi i8* [ null, %24 ], [ %28, %27 ]
br i1 %20, label %35, label %31
31: ; preds = %18, %29
%32 = phi i8* [ %30, %29 ], [ null, %18 ]
%33 = load i32, i32* %5
%34 = icmp eq i32 %33, 2
br i1 %34, label %35, label %41
35: ; preds = %29, %31
%36 = phi i8* [ %32, %31 ], [ %30, %29 ]
%37 = call i32 @lz4wpack(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %35
%40 = call i8* @in(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %21)
br label %41
41: ; preds = %39, %35, %31
%42 = phi i8* [ %32, %31 ], [ %36, %35 ], [ %36, %39 ]
%43 = phi i8* [ null, %31 ], [ null, %35 ], [ %40, %39 ]
%44 = load i32, i32* %9
store i32 0, i32* %5
%45 = icmp eq i8* %42, null
br i1 %45, label %50, label %46
46: ; preds = %41
%47 = load i32, i32* %22
%48 = icmp slt i32 %47, %44
br i1 %48, label %49, label %50
49: ; preds = %46
store i32 1, i32* %5
br label %50
50: ; preds = %41, %49, %46
%51 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), %41 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), %49 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), %46 ]
%52 = phi i8* [ %0, %41 ], [ %42, %49 ], [ %0, %46 ]
%53 = phi i32 [ %44, %41 ], [ %47, %49 ], [ %44, %46 ]
%54 = icmp eq i8* %43, null
br i1 %54, label %59, label %55
55: ; preds = %50
%56 = load i32, i32* %21
%57 = icmp slt i32 %56, %53
br i1 %57, label %58, label %59
58: ; preds = %55
store i32 2, i32* %5
br label %59
59: ; preds = %50, %55, %58
%60 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %58 ], [ %51, %55 ], [ %51, %50 ]
%61 = phi i32 [ %56, %58 ], [ %53, %55 ], [ %53, %50 ]
%62 = phi i8* [ %43, %58 ], [ %52, %55 ], [ %52, %50 ]
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %60)
%64 = sitofp i32 %61 to double
%65 = fmul double %64, 1.000000e+02
%66 = sitofp i32 %2 to float
%67 = fpext float %66 to double
%68 = fdiv double %65, %67
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %2, i32 %61, double %68)
store i32 %61, i32* %4
%70 = icmp eq i8* %0, null
%71 = icmp eq i8* %62, %0
%72 = select i1 %70, i1 true, i1 %71
br i1 %72, label %75, label %73
73: ; preds = %59
%74 = call i32 @free(i8* %0)
br label %75
75: ; preds = %59, %73
%76 = icmp eq i8* %42, %62
%77 = select i1 %45, i1 true, i1 %76
br i1 %77, label %80, label %78
78: ; preds = %75
%79 = call i32 @free(i8* %42)
br label %80
80: ; preds = %78, %75
%81 = icmp eq i8* %43, %62
%82 = select i1 %54, i1 true, i1 %81
br i1 %82, label %85, label %83
83: ; preds = %80
%84 = call i32 @free(i8* %43)
br label %85
85: ; preds = %83, %80
%86 = call i32 @remove(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%87 = call i32 @remove(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %88
88: ; preds = %85, %23, %14
%89 = phi i8* [ null, %23 ], [ %62, %85 ], [ null, %14 ]
ret i8* %89
}