#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, char *, int);
int blockLength(int, char *, int);
int tribus(int, int, int, int);
int getBinaryLength(int version, char inputMode[], int inputData[],
                    int inputLength, int gs1, int eci) {
  char currentMode;
  int i, 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    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <applyOptimisation@plt>
movb   $0x20,-0x25(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    117b <getBinaryLength+0x4b>
mov    -0x34(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x3,-0x24(%rbp)
je     118e <getBinaryLength+0x5e>
mov    -0x34(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1498 <getBinaryLength+0x368>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x25(%rbp),%ecx
cmp    %ecx,%eax
je     1485 <getBinaryLength+0x355>
mov    -0x34(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0xd,%eax
ja     1477 <getBinaryLength+0x347>
mov    -0x40(%rbp),%rax
lea    0xe15(%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    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <blockLength@plt>
imul   $0xd,%eax,%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1477 <getBinaryLength+0x347>
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
mov    $0x10,%ecx
mov    %ecx,%edx
call   1050 <tribus@plt>
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <blockLength@plt>
mov    -0x48(%rbp),%ecx
mov    %eax,%edx
mov    -0x44(%rbp),%eax
add    %edx,%ecx
cmp    %ecx,%eax
jge    12ba <getBinaryLength+0x18a>
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
cmpl   $0xff,(%rax,%rcx,4)
jle    129e <getBinaryLength+0x16e>
mov    -0x34(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x34(%rbp)
jmp    12a7 <getBinaryLength+0x177>
mov    -0x34(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x34(%rbp)
jmp    12ac <getBinaryLength+0x17c>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    124e <getBinaryLength+0x11e>
jmp    1477 <getBinaryLength+0x347>
mov    -0x4(%rbp),%edi
mov    $0x9,%esi
mov    $0xb,%edx
mov    $0xd,%ecx
call   1050 <tribus@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <blockLength@plt>
mov    %eax,%edx
shr    $0x1f,%edx
mov    %eax,%ecx
add    %edx,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
mov    %eax,-0x4c(%rbp)
je     131c <getBinaryLength+0x1ec>
jmp    130b <getBinaryLength+0x1db>
mov    -0x4c(%rbp),%eax
sub    $0x1,%eax
je     1341 <getBinaryLength+0x211>
jmp    136d <getBinaryLength+0x23d>
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <blockLength@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
imul   $0xb,%eax,%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    136d <getBinaryLength+0x23d>
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <blockLength@plt>
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
imul   $0xb,%eax,%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x34(%rbp)
jmp    1477 <getBinaryLength+0x347>
mov    -0x4(%rbp),%edi
mov    $0xa,%esi
mov    $0xc,%edx
mov    $0xe,%ecx
call   1050 <tribus@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
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,-0x50(%rbp)
je     13f0 <getBinaryLength+0x2c0>
jmp    13ce <getBinaryLength+0x29e>
mov    -0x50(%rbp),%eax
sub    $0x1,%eax
je     1415 <getBinaryLength+0x2e5>
jmp    13df <getBinaryLength+0x2af>
mov    -0x50(%rbp),%eax
sub    $0x2,%eax
je     1446 <getBinaryLength+0x316>
jmp    1472 <getBinaryLength+0x342>
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <blockLength@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
imul   $0xa,%eax,%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1472 <getBinaryLength+0x342>
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <blockLength@plt>
sub    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
imul   $0xa,%eax,%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x34(%rbp)
jmp    1472 <getBinaryLength+0x342>
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <blockLength@plt>
sub    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
imul   $0xa,%eax,%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x7,%eax
mov    %eax,-0x34(%rbp)
jmp    1477 <getBinaryLength+0x347>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x25(%rbp)
jmp    148a <getBinaryLength+0x35a>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1195 <getBinaryLength+0x65>
mov    -0x34(%rbp),%eax
add    $0x50,%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    %ecx,%r12d
mov    %rdx,%r15
mov    %rsi,%r13
mov    %edi,0x4(%rsp)
mov    %ecx,%edx
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   %r12d,%r12d
jle    1425 <getBinaryLength+0x2f5>
mov    %r12d,%edx
mov    $0x20,%al
xor    %r14d,%r14d
mov    %r15,0x8(%rsp)
mov    %rdx,0x10(%rsp)
jmp    11e7 <getBinaryLength+0xb7>
mov    0x4(%rsp),%edi
mov    $0x8,%esi
mov    $0xa,%edx
mov    $0xc,%ecx
call   1050 <tribus@plt>
mov    %eax,%r15d
add    %ebx,%r15d
mov    %r14d,%edi
mov    %r13,%rsi
mov    %r12d,%edx
call   1030 <blockLength@plt>
lea    (%rax,%rax,2),%ecx
lea    (%rax,%rcx,4),%ebx
add    %r15d,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13,%r14,1),%al
mov    0x10(%rsp),%rdx
add    $0x1,%r14
cmp    %rdx,%r14
je     1425 <getBinaryLength+0x2f5>
movsbl 0x0(%r13,%r14,1),%ecx
cmp    %al,%cl
je     11da <getBinaryLength+0xaa>
add    $0x4,%ebx
add    $0xffffffbf,%ecx
cmp    $0xd,%ecx
ja     11d0 <getBinaryLength+0xa0>
lea    0xdfd(%rip),%rdx
movslq (%rdx,%rcx,4),%rax
add    %rdx,%rax
jmp    *%rax
mov    0x4(%rsp),%edi
mov    $0x9,%esi
mov    $0xb,%edx
mov    $0xd,%ecx
call   1050 <tribus@plt>
mov    %eax,%r15d
add    %ebx,%r15d
mov    %r14d,%edi
mov    %r13,%rsi
mov    %r12d,%edx
call   1030 <blockLength@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
je     138a <getBinaryLength+0x25a>
test   %eax,%eax
jne    137a <getBinaryLength+0x24a>
mov    %r14d,%edi
mov    %r13,%rsi
mov    %r12d,%edx
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    %r15d,%ebx
jmp    11d0 <getBinaryLength+0xa0>
mov    0x4(%rsp),%edi
mov    $0x8,%esi
mov    $0x10,%edx
mov    $0x10,%ecx
call   1050 <tribus@plt>
mov    %eax,%r15d
add    %ebx,%r15d
mov    %r14d,%edi
mov    %r13,%rsi
mov    %r12d,%edx
call   1030 <blockLength@plt>
test   %eax,%eax
jle    1382 <getBinaryLength+0x252>
mov    %r14,%rbp
mov    %r15d,%ebx
mov    0x8(%rsp),%r15
nopl   0x0(%rax)
xor    %eax,%eax
cmpl   $0x100,(%r15,%rbp,4)
setge  %al
lea    (%rbx,%rax,8),%ebx
add    $0x8,%ebx
add    $0x1,%rbp
mov    %r14d,%edi
mov    %r13,%rsi
mov    %r12d,%edx
call   1030 <blockLength@plt>
add    %r14d,%eax
cmp    %ebp,%eax
jg     12c0 <getBinaryLength+0x190>
jmp    11d0 <getBinaryLength+0xa0>
mov    0x4(%rsp),%edi
mov    $0xa,%esi
mov    $0xc,%edx
mov    $0xe,%ecx
call   1050 <tribus@plt>
mov    %eax,%r15d
add    %ebx,%r15d
mov    %r14d,%edi
mov    %r13,%rsi
mov    %r12d,%edx
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     13b9 <getBinaryLength+0x289>
cmp    $0x1,%eax
je     13ef <getBinaryLength+0x2bf>
test   %eax,%eax
jne    137a <getBinaryLength+0x24a>
mov    %r14d,%edi
mov    %r13,%rsi
mov    %r12d,%edx
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    (%r15,%rax,2),%ebx
jmp    11d0 <getBinaryLength+0xa0>
mov    %r15d,%ebx
jmp    11d0 <getBinaryLength+0xa0>
mov    %r15d,%ebx
jmp    11d0 <getBinaryLength+0xa0>
mov    %r14d,%edi
mov    %r13,%rsi
mov    %r12d,%edx
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    (%r15,%rax,1),%ebx
add    $0x6,%ebx
jmp    11d0 <getBinaryLength+0xa0>
mov    %r14d,%edi
mov    %r13,%rsi
mov    %r12d,%edx
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    (%r15,%rax,2),%ebx
add    $0x7,%ebx
jmp    11d0 <getBinaryLength+0xa0>
mov    %r14d,%edi
mov    %r13,%rsi
mov    %r12d,%edx
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    (%r15,%rax,2),%ebx
add    $0x4,%ebx
jmp    11d0 <getBinaryLength+0xa0>
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, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %7
store i8* %1, i8** %8
store i32* %2, i32** %9
store i32 %3, i32* %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 i32, i32* %10
%20 = call i32 @applyOptimisation(i32 %17, i8* %18, i32 %19)
store i8 32, i8* %13
%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 i32 0, i32* %14
br label %33
33: ; preds = %184, %32
%34 = load i32, i32* %14
%35 = load i32, i32* %10
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %187
37: ; preds = %33
%38 = load i8*, i8** %8
%39 = load i32, i32* %14
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = load i8, i8* %13
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %43, %45
br i1 %46, label %47, label %183
47: ; preds = %37
%48 = load i32, i32* %16
%49 = add nsw i32 %48, 4
store i32 %49, i32* %16
%50 = load i8*, i8** %8
%51 = load i32, i32* %14
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
switch i32 %55, label %177 [
i32 75, label %56
i32 66, label %68
i32 65, label %101
i32 78, label %133
]
56: ; preds = %47
%57 = load i32, i32* %7
%58 = call i32 @tribus(i32 %57, i32 8, i32 10, i32 12)
%59 = load i32, i32* %16
%60 = add nsw i32 %59, %58
store i32 %60, i32* %16
%61 = load i32, i32* %14
%62 = load i8*, i8** %8
%63 = load i32, i32* %10
%64 = call i32 @blockLength(i32 %61, i8* %62, i32 %63)
%65 = mul nsw i32 %64, 13
%66 = load i32, i32* %16
%67 = add nsw i32 %66, %65
store i32 %67, i32* %16
br label %177
68: ; preds = %47
%69 = load i32, i32* %7
%70 = call i32 @tribus(i32 %69, i32 8, i32 16, i32 16)
%71 = load i32, i32* %16
%72 = add nsw i32 %71, %70
store i32 %72, i32* %16
%73 = load i32, i32* %14
store i32 %73, i32* %15
br label %74
74: ; preds = %97, %68
%75 = load i32, i32* %15
%76 = load i32, i32* %14
%77 = load i32, i32* %14
%78 = load i8*, i8** %8
%79 = load i32, i32* %10
%80 = call i32 @blockLength(i32 %77, i8* %78, i32 %79)
%81 = add nsw i32 %76, %80
%82 = icmp slt i32 %75, %81
br i1 %82, label %83, label %100
83: ; preds = %74
%84 = load i32*, i32** %9
%85 = load i32, i32* %15
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i32, i32* %84, i64 %86
%88 = load i32, i32* %87
%89 = icmp sgt i32 %88, 255
br i1 %89, label %90, label %93
90: ; preds = %83
%91 = load i32, i32* %16
%92 = add nsw i32 %91, 16
store i32 %92, i32* %16
br label %96
93: ; preds = %83
%94 = load i32, i32* %16
%95 = add nsw i32 %94, 8
store i32 %95, i32* %16
br label %96
96: ; preds = %93, %90
br label %97
97: ; preds = %96
%98 = load i32, i32* %15
%99 = add nsw i32 %98, 1
store i32 %99, i32* %15
br label %74
100: ; preds = %74
br label %177
101: ; preds = %47
%102 = load i32, i32* %7
%103 = call i32 @tribus(i32 %102, i32 9, i32 11, i32 13)
%104 = load i32, i32* %16
%105 = add nsw i32 %104, %103
store i32 %105, i32* %16
%106 = load i32, i32* %14
%107 = load i8*, i8** %8
%108 = load i32, i32* %10
%109 = call i32 @blockLength(i32 %106, i8* %107, i32 %108)
%110 = srem i32 %109, 2
switch i32 %110, label %132 [
i32 0, label %111
i32 1, label %120
]
111: ; preds = %101
%112 = load i32, i32* %14
%113 = load i8*, i8** %8
%114 = load i32, i32* %10
%115 = call i32 @blockLength(i32 %112, i8* %113, i32 %114)
%116 = sdiv i32 %115, 2
%117 = mul nsw i32 %116, 11
%118 = load i32, i32* %16
%119 = add nsw i32 %118, %117
store i32 %119, i32* %16
br label %132
120: ; preds = %101
%121 = load i32, i32* %14
%122 = load i8*, i8** %8
%123 = load i32, i32* %10
%124 = call i32 @blockLength(i32 %121, i8* %122, i32 %123)
%125 = sub nsw i32 %124, 1
%126 = sdiv i32 %125, 2
%127 = mul nsw i32 %126, 11
%128 = load i32, i32* %16
%129 = add nsw i32 %128, %127
store i32 %129, i32* %16
%130 = load i32, i32* %16
%131 = add nsw i32 %130, 6
store i32 %131, i32* %16
br label %132
132: ; preds = %101, %120, %111
br label %177
133: ; preds = %47
%134 = load i32, i32* %7
%135 = call i32 @tribus(i32 %134, i32 10, i32 12, i32 14)
%136 = load i32, i32* %16
%137 = add nsw i32 %136, %135
store i32 %137, i32* %16
%138 = load i32, i32* %14
%139 = load i8*, i8** %8
%140 = load i32, i32* %10
%141 = call i32 @blockLength(i32 %138, i8* %139, i32 %140)
%142 = srem i32 %141, 3
switch i32 %142, label %176 [
i32 0, label %143
i32 1, label %152
i32 2, label %164
]
143: ; preds = %133
%144 = load i32, i32* %14
%145 = load i8*, i8** %8
%146 = load i32, i32* %10
%147 = call i32 @blockLength(i32 %144, i8* %145, i32 %146)
%148 = sdiv i32 %147, 3
%149 = mul nsw i32 %148, 10
%150 = load i32, i32* %16
%151 = add nsw i32 %150, %149
store i32 %151, i32* %16
br label %176
152: ; preds = %133
%153 = load i32, i32* %14
%154 = load i8*, i8** %8
%155 = load i32, i32* %10
%156 = call i32 @blockLength(i32 %153, i8* %154, i32 %155)
%157 = sub nsw i32 %156, 1
%158 = sdiv i32 %157, 3
%159 = mul nsw i32 %158, 10
%160 = load i32, i32* %16
%161 = add nsw i32 %160, %159
store i32 %161, i32* %16
%162 = load i32, i32* %16
%163 = add nsw i32 %162, 4
store i32 %163, i32* %16
br label %176
164: ; preds = %133
%165 = load i32, i32* %14
%166 = load i8*, i8** %8
%167 = load i32, i32* %10
%168 = call i32 @blockLength(i32 %165, i8* %166, i32 %167)
%169 = sub nsw i32 %168, 2
%170 = sdiv i32 %169, 3
%171 = mul nsw i32 %170, 10
%172 = load i32, i32* %16
%173 = add nsw i32 %172, %171
store i32 %173, i32* %16
%174 = load i32, i32* %16
%175 = add nsw i32 %174, 7
store i32 %175, i32* %16
br label %176
176: ; preds = %133, %164, %152, %143
br label %177
177: ; preds = %47, %176, %132, %100, %56
%178 = load i8*, i8** %8
%179 = load i32, i32* %14
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds i8, i8* %178, i64 %180
%182 = load i8, i8* %181
store i8 %182, i8* %13
br label %183
183: ; preds = %177, %37
br label %184
184: ; preds = %183
%185 = load i32, i32* %14
%186 = add nsw i32 %185, 1
store i32 %186, i32* %14
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, i32 %3, i32 %4, i32 %5) {
%7 = tail call i32 @applyOptimisation(i32 %0, i8* %1, i32 %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 sgt i32 %3, 0
br i1 %13, label %14, label %103
14: ; preds = %6
%15 = zext i32 %3 to i64
br label %16
16: ; preds = %14, %98
%17 = phi i64 [ 0, %14 ], [ %101, %98 ]
%18 = phi i32 [ %12, %14 ], [ %100, %98 ]
%19 = phi i8 [ 32, %14 ], [ %99, %98 ]
%20 = getelementptr inbounds i8, i8* %1, i64 %17
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, %19
br i1 %22, label %98, label %23
23: ; preds = %16
%24 = sext i8 %21 to i32
%25 = add nsw i32 %18, 4
switch i32 %24, label %95 [
i32 75, label %26
i32 66, label %33
i32 65, label %52
i32 78, label %70
]
26: ; preds = %23
%27 = tail call i32 @tribus(i32 %0, i32 8, i32 10, i32 12)
%28 = add nsw i32 %27, %25
%29 = trunc i64 %17 to i32
%30 = tail call i32 @blockLength(i32 %29, i8* %1, i32 %3)
%31 = mul nsw i32 %30, 13
%32 = add nsw i32 %28, %31
br label %95
33: ; preds = %23
%34 = tail call i32 @tribus(i32 %0, i32 8, i32 16, i32 16)
%35 = add nsw i32 %34, %25
%36 = trunc i64 %17 to i32
%37 = tail call i32 @blockLength(i32 %36, i8* %1, i32 %3)
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %95
39: ; preds = %33, %39
%40 = phi i64 [ %47, %39 ], [ %17, %33 ]
%41 = phi i32 [ %46, %39 ], [ %35, %33 ]
%42 = getelementptr inbounds i32, i32* %2, i64 %40
%43 = load i32, i32* %42
%44 = icmp sgt i32 %43, 255
%45 = select i1 %44, i32 16, i32 8
%46 = add nsw i32 %45, %41
%47 = add nuw nsw i64 %40, 1
%48 = tail call i32 @blockLength(i32 %36, i8* %1, i32 %3)
%49 = add nsw i32 %48, %36
%50 = trunc i64 %47 to i32
%51 = icmp sgt i32 %49, %50
br i1 %51, label %39, label %95
52: ; preds = %23
%53 = tail call i32 @tribus(i32 %0, i32 9, i32 11, i32 13)
%54 = add nsw i32 %53, %25
%55 = trunc i64 %17 to i32
%56 = tail call i32 @blockLength(i32 %55, i8* %1, i32 %3)
%57 = srem i32 %56, 2
switch i32 %57, label %95 [
i32 0, label %58
i32 1, label %63
]
58: ; preds = %52
%59 = tail call i32 @blockLength(i32 %55, i8* %1, i32 %3)
%60 = sdiv i32 %59, 2
%61 = mul nsw i32 %60, 11
%62 = add nsw i32 %61, %54
br label %95
63: ; preds = %52
%64 = tail call i32 @blockLength(i32 %55, i8* %1, i32 %3)
%65 = add nsw i32 %64, -1
%66 = sdiv i32 %65, 2
%67 = mul nsw i32 %66, 11
%68 = add i32 %54, 6
%69 = add i32 %68, %67
br label %95
70: ; preds = %23
%71 = tail call i32 @tribus(i32 %0, i32 10, i32 12, i32 14)
%72 = add nsw i32 %71, %25
%73 = trunc i64 %17 to i32
%74 = tail call i32 @blockLength(i32 %73, i8* %1, i32 %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 = %70
%77 = tail call i32 @blockLength(i32 %73, i8* %1, i32 %3)
%78 = sdiv i32 %77, 3
%79 = mul nsw i32 %78, 10
%80 = add nsw i32 %79, %72
br label %95
81: ; preds = %70
%82 = tail call i32 @blockLength(i32 %73, i8* %1, i32 %3)
%83 = add nsw i32 %82, -1
%84 = sdiv i32 %83, 3
%85 = mul nsw i32 %84, 10
%86 = add i32 %72, 4
%87 = add i32 %86, %85
br label %95
88: ; preds = %70
%89 = tail call i32 @blockLength(i32 %73, i8* %1, i32 %3)
%90 = add nsw i32 %89, -2
%91 = sdiv i32 %90, 3
%92 = mul nsw i32 %91, 10
%93 = add i32 %72, 7
%94 = add i32 %93, %92
br label %95
95: ; preds = %39, %33, %76, %81, %88, %70, %58, %63, %52, %23, %26
%96 = phi i32 [ %25, %23 ], [ %72, %70 ], [ %94, %88 ], [ %87, %81 ], [ %80, %76 ], [ %54, %52 ], [ %69, %63 ], [ %62, %58 ], [ %32, %26 ], [ %35, %33 ], [ %46, %39 ]
%97 = load i8, i8* %20
br label %98
98: ; preds = %16, %95
%99 = phi i8 [ %97, %95 ], [ %19, %16 ]
%100 = phi i32 [ %96, %95 ], [ %18, %16 ]
%101 = add nuw nsw i64 %17, 1
%102 = icmp eq i64 %101, %15
br i1 %102, label %103, label %16
103: ; preds = %98, %6
%104 = phi i32 [ %12, %6 ], [ %100, %98 ]
ret i32 %104
}