#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*/ applyOptimisation(int const, char *, size_t const);
int blockLength(size_t, char *, size_t const);
int tribus(int const, int, int, int);
int getBinaryLength(const int version, char inputMode[], const int inputData[],
                    const size_t inputLength, const int gs1, const int eci) {
  size_t i;
  char currentMode;
  int j;
  int count = 0;
  applyOptimisation(version, inputMode, inputLength);
  currentMode = ' ';
  if (gs1 == 1) {
    count += 4;
  }
  if (eci != 3) {
    count += 12;
  }
  for (i = 0; i < inputLength; i++) {
    if (inputMode[i] != currentMode) {
      count += 4;
      switch (inputMode[i]) {
      case 'K':
        count += tribus(version, 8, 10, 12);
        count += (blockLength(i, inputMode, inputLength) * 13);
        break;
      case 'B':
        count += tribus(version, 8, 16, 16);
        for (j = i; j < (i + blockLength(i, inputMode, inputLength)); j++) {
          if (inputData[j] > 0xff) {
            count += 16;
          } else {
            count += 8;
          }
        }
        break;
      case 'A':
        count += tribus(version, 9, 11, 13);
        switch (blockLength(i, inputMode, inputLength) % 2) {
        case 0:
          count += (blockLength(i, inputMode, inputLength) / 2) * 11;
          break;
        case 1:
          count += ((blockLength(i, inputMode, inputLength) - 1) / 2) * 11;
          count += 6;
          break;
        }
        break;
      case 'N':
        count += tribus(version, 10, 12, 14);
        switch (blockLength(i, inputMode, inputLength) % 3) {
        case 0:
          count += (blockLength(i, inputMode, inputLength) / 3) * 10;
          break;
        case 1:
          count += ((blockLength(i, inputMode, inputLength) - 1) / 3) * 10;
          count += 4;
          break;
        case 2:
          count += ((blockLength(i, inputMode, inputLength) - 2) / 3) * 10;
          count += 7;
          break;
        }
        break;
      }
      currentMode = inputMode[i];
    }
  }
  return count;
}


x86 assembly (clang, -O0):
<getBinaryLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <applyOptimisation@plt>
movb   $0x20,-0x31(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    117d <getBinaryLength+0x4d>
mov    -0x3c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x3,-0x28(%rbp)
je     1190 <getBinaryLength+0x60>
mov    -0x3c(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x3c(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    14be <getBinaryLength+0x38e>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x31(%rbp),%ecx
cmp    %ecx,%eax
je     14a8 <getBinaryLength+0x378>
mov    -0x3c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0xd,%eax
ja     149a <getBinaryLength+0x36a>
mov    -0x48(%rbp),%rax
lea    0xe10(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
mov    $0xa,%edx
mov    $0xc,%ecx
call   1050 <tribus@plt>
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <blockLength@plt>
imul   $0xd,%eax,%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    149a <getBinaryLength+0x36a>
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
mov    $0x10,%ecx
mov    %ecx,%edx
call   1050 <tribus@plt>
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
mov    %eax,-0x38(%rbp)
movslq -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <blockLength@plt>
mov    -0x58(%rbp),%rcx
mov    %eax,%edx
mov    -0x50(%rbp),%rax
movslq %edx,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    12cf <getBinaryLength+0x19f>
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
cmpl   $0xff,(%rax,%rcx,4)
jle    12b3 <getBinaryLength+0x183>
mov    -0x3c(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x3c(%rbp)
jmp    12bc <getBinaryLength+0x18c>
mov    -0x3c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x3c(%rbp)
jmp    12c1 <getBinaryLength+0x191>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1256 <getBinaryLength+0x126>
jmp    149a <getBinaryLength+0x36a>
mov    -0x4(%rbp),%edi
mov    $0x9,%esi
mov    $0xb,%edx
mov    $0xd,%ecx
call   1050 <tribus@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <blockLength@plt>
mov    %eax,%edx
shr    $0x1f,%edx
mov    %eax,%ecx
add    %edx,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
mov    %eax,-0x5c(%rbp)
je     1333 <getBinaryLength+0x203>
jmp    1322 <getBinaryLength+0x1f2>
mov    -0x5c(%rbp),%eax
sub    $0x1,%eax
je     135a <getBinaryLength+0x22a>
jmp    1388 <getBinaryLength+0x258>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <blockLength@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
imul   $0xb,%eax,%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    1388 <getBinaryLength+0x258>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <blockLength@plt>
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
imul   $0xb,%eax,%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x3c(%rbp)
jmp    149a <getBinaryLength+0x36a>
mov    -0x4(%rbp),%edi
mov    $0xa,%esi
mov    $0xc,%edx
mov    $0xe,%ecx
call   1050 <tribus@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <blockLength@plt>
movslq %eax,%rcx
imul   $0x55555556,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0x60(%rbp)
je     140d <getBinaryLength+0x2dd>
jmp    13eb <getBinaryLength+0x2bb>
mov    -0x60(%rbp),%eax
sub    $0x1,%eax
je     1434 <getBinaryLength+0x304>
jmp    13fc <getBinaryLength+0x2cc>
mov    -0x60(%rbp),%eax
sub    $0x2,%eax
je     1467 <getBinaryLength+0x337>
jmp    1495 <getBinaryLength+0x365>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <blockLength@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
imul   $0xa,%eax,%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    1495 <getBinaryLength+0x365>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <blockLength@plt>
sub    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
imul   $0xa,%eax,%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x3c(%rbp)
jmp    1495 <getBinaryLength+0x365>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <blockLength@plt>
sub    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
imul   $0xa,%eax,%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x7,%eax
mov    %eax,-0x3c(%rbp)
jmp    149a <getBinaryLength+0x36a>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x31(%rbp)
jmp    14ad <getBinaryLength+0x37d>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1198 <getBinaryLength+0x68>
mov    -0x3c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getBinaryLength>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%ebx
mov    %r8d,%ebp
mov    %rcx,%r12
mov    %rdx,0x10(%rsp)
mov    %rsi,%r13
mov    %edi,0xc(%rsp)
mov    %rcx,%rdx
call   1040 <applyOptimisation@plt>
xor    %eax,%eax
cmp    $0x1,%ebp
sete   %al
lea    0x0(,%rax,4),%ecx
cmp    $0x3,%ebx
lea    0xc(,%rax,4),%ebx
cmove  %ecx,%ebx
test   %r12,%r12
je     1451 <getBinaryLength+0x321>
mov    $0x20,%al
xor    %r14d,%r14d
xor    %ebp,%ebp
mov    %r12,(%rsp)
jmp    11d4 <getBinaryLength+0xa4>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    (%rsp),%r15
mov    %r15,%rdx
call   1030 <blockLength@plt>
mov    %eax,%ecx
add    $0xffffffff,%ecx
shr    $0x1f,%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
sar    %eax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,2),%eax
lea    (%r12,%rax,1),%ebx
add    $0x6,%ebx
mov    %r15,%r12
mov    0x0(%r13,%rbp,1),%al
add    $0x1,%rbp
add    $0x1,%r14d
cmp    %r12,%rbp
je     1451 <getBinaryLength+0x321>
movsbl 0x0(%r13,%rbp,1),%ecx
cmp    %al,%cl
je     11c3 <getBinaryLength+0x93>
add    $0x4,%ebx
add    $0xffffffbf,%ecx
cmp    $0xd,%ecx
ja     11be <getBinaryLength+0x8e>
lea    0xe10(%rip),%rdx
movslq (%rdx,%rcx,4),%rax
add    %rdx,%rax
jmp    *%rax
mov    0xc(%rsp),%edi
mov    $0x9,%esi
mov    $0xb,%edx
mov    $0xd,%ecx
call   1050 <tribus@plt>
mov    %r12,%rdx
mov    %eax,%r12d
add    %ebx,%r12d
mov    %rbp,%rdi
mov    %r13,%rsi
call   1030 <blockLength@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
je     118d <getBinaryLength+0x5d>
test   %eax,%eax
jne    13c5 <getBinaryLength+0x295>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    (%rsp),%r15
mov    %r15,%rdx
call   1030 <blockLength@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
lea    (%rcx,%rcx,4),%eax
lea    (%rcx,%rax,2),%ebx
add    %r12d,%ebx
jmp    11bb <getBinaryLength+0x8b>
mov    0xc(%rsp),%edi
mov    $0x8,%esi
mov    $0x10,%edx
mov    $0x10,%ecx
call   1050 <tribus@plt>
mov    %r12,%rdx
mov    %eax,%r12d
add    %ebx,%r12d
movslq %ebp,%rbx
mov    %rbp,%rdi
mov    %r13,%rsi
call   1030 <blockLength@plt>
cltq
add    %rbp,%rax
cmp    %rbx,%rax
jbe    13d1 <getBinaryLength+0x2a1>
movslq %r14d,%r15
mov    %r12d,%ebx
mov    (%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
mov    0x10(%rsp),%rcx
cmpl   $0x100,(%rcx,%r15,4)
setge  %al
lea    (%rbx,%rax,8),%ebx
add    $0x8,%ebx
add    $0x1,%r15
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1030 <blockLength@plt>
cltq
add    %rbp,%rax
cmp    %r15,%rax
ja     12c0 <getBinaryLength+0x190>
jmp    11be <getBinaryLength+0x8e>
mov    0xc(%rsp),%edi
mov    $0x8,%esi
mov    $0xa,%edx
mov    $0xc,%ecx
call   1050 <tribus@plt>
mov    %eax,%r12d
add    %ebx,%r12d
mov    %rbp,%rdi
mov    %r13,%rsi
mov    (%rsp),%rdx
call   1030 <blockLength@plt>
lea    (%rax,%rax,2),%ecx
lea    (%rax,%rcx,4),%ebx
add    %r12d,%ebx
mov    (%rsp),%r12
jmp    11be <getBinaryLength+0x8e>
mov    0xc(%rsp),%edi
mov    $0xa,%esi
mov    $0xc,%edx
mov    $0xe,%ecx
call   1050 <tribus@plt>
mov    %r12,%rdx
mov    %eax,%r12d
add    %ebx,%r12d
mov    %rbp,%rdi
mov    %r13,%rsi
call   1030 <blockLength@plt>
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    $0x2,%eax
je     13dd <getBinaryLength+0x2ad>
cmp    $0x1,%eax
je     1417 <getBinaryLength+0x2e7>
test   %eax,%eax
jne    13c5 <getBinaryLength+0x295>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    (%rsp),%r15
mov    %r15,%rdx
call   1030 <blockLength@plt>
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%eax
lea    (%r12,%rax,2),%ebx
jmp    11bb <getBinaryLength+0x8b>
mov    %r12d,%ebx
mov    (%rsp),%r12
jmp    11be <getBinaryLength+0x8e>
mov    %r12d,%ebx
mov    (%rsp),%r12
jmp    11be <getBinaryLength+0x8e>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    (%rsp),%r15
mov    %r15,%rdx
call   1030 <blockLength@plt>
add    $0xfffffffe,%eax
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%eax
lea    (%r12,%rax,2),%ebx
add    $0x7,%ebx
jmp    11bb <getBinaryLength+0x8b>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    (%rsp),%r15
mov    %r15,%rdx
call   1030 <blockLength@plt>
add    $0xffffffff,%eax
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%eax
lea    (%r12,%rax,2),%ebx
add    $0x4,%ebx
jmp    11bb <getBinaryLength+0x8b>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getBinaryLength(i32 %0, i8* %1, i32* %2, i64 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca i8
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %7
store i8* %1, i8** %8
store i32* %2, i32** %9
store i64 %3, i64* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
store i32 0, i32* %16
%17 = load i32, i32* %7
%18 = load i8*, i8** %8
%19 = load i64, i64* %10
%20 = call i32 @applyOptimisation(i32 %17, i8* %18, i64 %19)
store i8 32, i8* %14
%21 = load i32, i32* %11
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %26
23: ; preds = %6
%24 = load i32, i32* %16
%25 = add nsw i32 %24, 4
store i32 %25, i32* %16
br label %26
26: ; preds = %23, %6
%27 = load i32, i32* %12
%28 = icmp ne i32 %27, 3
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %16
%31 = add nsw i32 %30, 12
store i32 %31, i32* %16
br label %32
32: ; preds = %29, %26
store i64 0, i64* %13
br label %33
33: ; preds = %184, %32
%34 = load i64, i64* %13
%35 = load i64, i64* %10
%36 = icmp ult i64 %34, %35
br i1 %36, label %37, label %187
37: ; preds = %33
%38 = load i8*, i8** %8
%39 = load i64, i64* %13
%40 = getelementptr inbounds i8, i8* %38, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = load i8, i8* %14
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %42, %44
br i1 %45, label %46, label %183
46: ; preds = %37
%47 = load i32, i32* %16
%48 = add nsw i32 %47, 4
store i32 %48, i32* %16
%49 = load i8*, i8** %8
%50 = load i64, i64* %13
%51 = getelementptr inbounds i8, i8* %49, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
switch i32 %53, label %178 [
i32 75, label %54
i32 66, label %66
i32 65, label %102
i32 78, label %134
]
54: ; preds = %46
%55 = load i32, i32* %7
%56 = call i32 @tribus(i32 %55, i32 8, i32 10, i32 12)
%57 = load i32, i32* %16
%58 = add nsw i32 %57, %56
store i32 %58, i32* %16
%59 = load i64, i64* %13
%60 = load i8*, i8** %8
%61 = load i64, i64* %10
%62 = call i32 @blockLength(i64 %59, i8* %60, i64 %61)
%63 = mul nsw i32 %62, 13
%64 = load i32, i32* %16
%65 = add nsw i32 %64, %63
store i32 %65, i32* %16
br label %178
66: ; preds = %46
%67 = load i32, i32* %7
%68 = call i32 @tribus(i32 %67, i32 8, i32 16, i32 16)
%69 = load i32, i32* %16
%70 = add nsw i32 %69, %68
store i32 %70, i32* %16
%71 = load i64, i64* %13
%72 = trunc i64 %71 to i32
store i32 %72, i32* %15
br label %73
73: ; preds = %98, %66
%74 = load i32, i32* %15
%75 = sext i32 %74 to i64
%76 = load i64, i64* %13
%77 = load i64, i64* %13
%78 = load i8*, i8** %8
%79 = load i64, i64* %10
%80 = call i32 @blockLength(i64 %77, i8* %78, i64 %79)
%81 = sext i32 %80 to i64
%82 = add i64 %76, %81
%83 = icmp ult i64 %75, %82
br i1 %83, label %84, label %101
84: ; preds = %73
%85 = load i32*, i32** %9
%86 = load i32, i32* %15
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %85, i64 %87
%89 = load i32, i32* %88
%90 = icmp sgt i32 %89, 255
br i1 %90, label %91, label %94
91: ; preds = %84
%92 = load i32, i32* %16
%93 = add nsw i32 %92, 16
store i32 %93, i32* %16
br label %97
94: ; preds = %84
%95 = load i32, i32* %16
%96 = add nsw i32 %95, 8
store i32 %96, i32* %16
br label %97
97: ; preds = %94, %91
br label %98
98: ; preds = %97
%99 = load i32, i32* %15
%100 = add nsw i32 %99, 1
store i32 %100, i32* %15
br label %73
101: ; preds = %73
br label %178
102: ; preds = %46
%103 = load i32, i32* %7
%104 = call i32 @tribus(i32 %103, i32 9, i32 11, i32 13)
%105 = load i32, i32* %16
%106 = add nsw i32 %105, %104
store i32 %106, i32* %16
%107 = load i64, i64* %13
%108 = load i8*, i8** %8
%109 = load i64, i64* %10
%110 = call i32 @blockLength(i64 %107, i8* %108, i64 %109)
%111 = srem i32 %110, 2
switch i32 %111, label %133 [
i32 0, label %112
i32 1, label %121
]
112: ; preds = %102
%113 = load i64, i64* %13
%114 = load i8*, i8** %8
%115 = load i64, i64* %10
%116 = call i32 @blockLength(i64 %113, i8* %114, i64 %115)
%117 = sdiv i32 %116, 2
%118 = mul nsw i32 %117, 11
%119 = load i32, i32* %16
%120 = add nsw i32 %119, %118
store i32 %120, i32* %16
br label %133
121: ; preds = %102
%122 = load i64, i64* %13
%123 = load i8*, i8** %8
%124 = load i64, i64* %10
%125 = call i32 @blockLength(i64 %122, i8* %123, i64 %124)
%126 = sub nsw i32 %125, 1
%127 = sdiv i32 %126, 2
%128 = mul nsw i32 %127, 11
%129 = load i32, i32* %16
%130 = add nsw i32 %129, %128
store i32 %130, i32* %16
%131 = load i32, i32* %16
%132 = add nsw i32 %131, 6
store i32 %132, i32* %16
br label %133
133: ; preds = %102, %121, %112
br label %178
134: ; preds = %46
%135 = load i32, i32* %7
%136 = call i32 @tribus(i32 %135, i32 10, i32 12, i32 14)
%137 = load i32, i32* %16
%138 = add nsw i32 %137, %136
store i32 %138, i32* %16
%139 = load i64, i64* %13
%140 = load i8*, i8** %8
%141 = load i64, i64* %10
%142 = call i32 @blockLength(i64 %139, i8* %140, i64 %141)
%143 = srem i32 %142, 3
switch i32 %143, label %177 [
i32 0, label %144
i32 1, label %153
i32 2, label %165
]
144: ; preds = %134
%145 = load i64, i64* %13
%146 = load i8*, i8** %8
%147 = load i64, i64* %10
%148 = call i32 @blockLength(i64 %145, i8* %146, i64 %147)
%149 = sdiv i32 %148, 3
%150 = mul nsw i32 %149, 10
%151 = load i32, i32* %16
%152 = add nsw i32 %151, %150
store i32 %152, i32* %16
br label %177
153: ; preds = %134
%154 = load i64, i64* %13
%155 = load i8*, i8** %8
%156 = load i64, i64* %10
%157 = call i32 @blockLength(i64 %154, i8* %155, i64 %156)
%158 = sub nsw i32 %157, 1
%159 = sdiv i32 %158, 3
%160 = mul nsw i32 %159, 10
%161 = load i32, i32* %16
%162 = add nsw i32 %161, %160
store i32 %162, i32* %16
%163 = load i32, i32* %16
%164 = add nsw i32 %163, 4
store i32 %164, i32* %16
br label %177
165: ; preds = %134
%166 = load i64, i64* %13
%167 = load i8*, i8** %8
%168 = load i64, i64* %10
%169 = call i32 @blockLength(i64 %166, i8* %167, i64 %168)
%170 = sub nsw i32 %169, 2
%171 = sdiv i32 %170, 3
%172 = mul nsw i32 %171, 10
%173 = load i32, i32* %16
%174 = add nsw i32 %173, %172
store i32 %174, i32* %16
%175 = load i32, i32* %16
%176 = add nsw i32 %175, 7
store i32 %176, i32* %16
br label %177
177: ; preds = %134, %165, %153, %144
br label %178
178: ; preds = %46, %177, %133, %101, %54
%179 = load i8*, i8** %8
%180 = load i64, i64* %13
%181 = getelementptr inbounds i8, i8* %179, i64 %180
%182 = load i8, i8* %181
store i8 %182, i8* %14
br label %183
183: ; preds = %178, %37
br label %184
184: ; preds = %183
%185 = load i64, i64* %13
%186 = add i64 %185, 1
store i64 %186, i64* %13
br label %33
187: ; preds = %33
%188 = load i32, i32* %16
ret i32 %188
}

LLVM IR (-O2):
define i32 @getBinaryLength(i32 %0, i8* %1, i32* nocapture %2, i64 %3, i32 %4, i32 %5) {
%7 = tail call i32 @applyOptimisation(i32 %0, i8* %1, i64 %3)
%8 = icmp eq i32 %4, 1
%9 = select i1 %8, i32 4, i32 0
%10 = icmp eq i32 %5, 3
%11 = add nuw nsw i32 %9, 12
%12 = select i1 %10, i32 %9, i32 %11
%13 = icmp eq i64 %3, 0
br i1 %13, label %104, label %14
14: ; preds = %6, %98
%15 = phi i32 [ %102, %98 ], [ 0, %6 ]
%16 = phi i32 [ %100, %98 ], [ %12, %6 ]
%17 = phi i8 [ %99, %98 ], [ 32, %6 ]
%18 = phi i64 [ %101, %98 ], [ 0, %6 ]
%19 = sext i32 %15 to i64
%20 = getelementptr inbounds i8, i8* %1, i64 %18
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, %17
br i1 %22, label %98, label %23
23: ; preds = %14
%24 = sext i8 %21 to i32
%25 = add nsw i32 %16, 4
switch i32 %24, label %95 [
i32 75, label %26
i32 66, label %32
i32 65, label %54
i32 78, label %71
]
26: ; preds = %23
%27 = tail call i32 @tribus(i32 %0, i32 8, i32 10, i32 12)
%28 = add nsw i32 %27, %25
%29 = tail call i32 @blockLength(i64 %18, i8* %1, i64 %3)
%30 = mul nsw i32 %29, 13
%31 = add nsw i32 %28, %30
br label %95
32: ; preds = %23
%33 = tail call i32 @tribus(i32 %0, i32 8, i32 16, i32 16)
%34 = add nsw i32 %33, %25
%35 = shl i64 %18, 32
%36 = ashr exact i64 %35, 32
%37 = tail call i32 @blockLength(i64 %18, i8* %1, i64 %3)
%38 = sext i32 %37 to i64
%39 = add i64 %18, %38
%40 = icmp ugt i64 %39, %36
br i1 %40, label %41, label %95
41: ; preds = %32, %41
%42 = phi i64 [ %49, %41 ], [ %19, %32 ]
%43 = phi i32 [ %48, %41 ], [ %34, %32 ]
%44 = getelementptr inbounds i32, i32* %2, i64 %42
%45 = load i32, i32* %44
%46 = icmp sgt i32 %45, 255
%47 = select i1 %46, i32 16, i32 8
%48 = add nsw i32 %47, %43
%49 = add i64 %42, 1
%50 = tail call i32 @blockLength(i64 %18, i8* %1, i64 %3)
%51 = sext i32 %50 to i64
%52 = add i64 %18, %51
%53 = icmp ugt i64 %52, %49
br i1 %53, label %41, label %95
54: ; preds = %23
%55 = tail call i32 @tribus(i32 %0, i32 9, i32 11, i32 13)
%56 = add nsw i32 %55, %25
%57 = tail call i32 @blockLength(i64 %18, i8* %1, i64 %3)
%58 = srem i32 %57, 2
switch i32 %58, label %95 [
i32 0, label %59
i32 1, label %64
]
59: ; preds = %54
%60 = tail call i32 @blockLength(i64 %18, i8* %1, i64 %3)
%61 = sdiv i32 %60, 2
%62 = mul nsw i32 %61, 11
%63 = add nsw i32 %62, %56
br label %95
64: ; preds = %54
%65 = tail call i32 @blockLength(i64 %18, i8* %1, i64 %3)
%66 = add nsw i32 %65, -1
%67 = sdiv i32 %66, 2
%68 = mul nsw i32 %67, 11
%69 = add i32 %56, 6
%70 = add i32 %69, %68
br label %95
71: ; preds = %23
%72 = tail call i32 @tribus(i32 %0, i32 10, i32 12, i32 14)
%73 = add nsw i32 %72, %25
%74 = tail call i32 @blockLength(i64 %18, i8* %1, i64 %3)
%75 = srem i32 %74, 3
switch i32 %75, label %95 [
i32 0, label %76
i32 1, label %81
i32 2, label %88
]
76: ; preds = %71
%77 = tail call i32 @blockLength(i64 %18, i8* %1, i64 %3)
%78 = sdiv i32 %77, 3
%79 = mul nsw i32 %78, 10
%80 = add nsw i32 %79, %73
br label %95
81: ; preds = %71
%82 = tail call i32 @blockLength(i64 %18, i8* %1, i64 %3)
%83 = add nsw i32 %82, -1
%84 = sdiv i32 %83, 3
%85 = mul nsw i32 %84, 10
%86 = add i32 %73, 4
%87 = add i32 %86, %85
br label %95
88: ; preds = %71
%89 = tail call i32 @blockLength(i64 %18, i8* %1, i64 %3)
%90 = add nsw i32 %89, -2
%91 = sdiv i32 %90, 3
%92 = mul nsw i32 %91, 10
%93 = add i32 %73, 7
%94 = add i32 %93, %92
br label %95
95: ; preds = %41, %32, %76, %81, %88, %71, %59, %64, %54, %23, %26
%96 = phi i32 [ %25, %23 ], [ %73, %71 ], [ %94, %88 ], [ %87, %81 ], [ %80, %76 ], [ %56, %54 ], [ %70, %64 ], [ %63, %59 ], [ %31, %26 ], [ %34, %32 ], [ %48, %41 ]
%97 = load i8, i8* %20
br label %98
98: ; preds = %14, %95
%99 = phi i8 [ %97, %95 ], [ %17, %14 ]
%100 = phi i32 [ %96, %95 ], [ %16, %14 ]
%101 = add nuw i64 %18, 1
%102 = add i32 %15, 1
%103 = icmp eq i64 %101, %3
br i1 %103, label %104, label %14
104: ; preds = %98, %6
%105 = phi i32 [ %12, %6 ], [ %100, %98 ]
ret i32 %105
}