void applyOptimisation(int version, char inputMode[], int inputLength) {
  int blockCount = 0, block;
  int i, j;
  char currentMode = ' ';
  int *blockLength;
  char *blockMode;
  for (i = 0; i < inputLength; i++) {
    if (inputMode[i] != currentMode) {
      currentMode = inputMode[i];
      blockCount++;
    }
  }
  blockLength = (int *)malloc(sizeof(int) * blockCount);
  assert(blockLength);
  if (!blockLength)
    return;
  blockMode = (char *)malloc(sizeof(char) * blockCount);
  assert(blockMode);
  if (!blockMode) {
    free(blockLength);
    return;
  }
  j = -1;
  currentMode = ' ';
  for (i = 0; i < inputLength; i++) {
    if (inputMode[i] != currentMode) {
      j++;
      blockLength[j] = 1;
      blockMode[j] = inputMode[i];
      currentMode = inputMode[i];
    } else {
      blockLength[j]++;
    }
  }
  if (blockCount > 1) {
    for (i = 0; i <= (blockCount - 2); i++) {
      if (blockMode[i] == 'B') {
        switch (blockMode[i + 1]) {
        case 'K':
          if (blockLength[i + 1] < tribus(version, 4, 5, 6)) {
            blockMode[i + 1] = 'B';
          }
          break;
        case 'A':
          if (blockLength[i + 1] < tribus(version, 7, 8, 9)) {
            blockMode[i + 1] = 'B';
          }
          break;
        case 'N':
          if (blockLength[i + 1] < tribus(version, 3, 4, 5)) {
            blockMode[i + 1] = 'B';
          }
          break;
        }
      }
      if ((blockMode[i] == 'A') && (blockMode[i + 1] == 'N')) {
        if (blockLength[i + 1] < tribus(version, 6, 8, 10)) {
          blockMode[i + 1] = 'A';
        }
      }
    }
    for (i = blockCount - 1; i > 0; i--) {
      if (blockMode[i] == 'B') {
        switch (blockMode[i - 1]) {
        case 'K':
          if (blockLength[i - 1] < tribus(version, 4, 5, 6)) {
            blockMode[i - 1] = 'B';
          }
          break;
        case 'A':
          if (blockLength[i - 1] < tribus(version, 7, 8, 9)) {
            blockMode[i - 1] = 'B';
          }
          break;
        case 'N':
          if (blockLength[i - 1] < tribus(version, 3, 4, 5)) {
            blockMode[i - 1] = 'B';
          }
          break;
        }
      }
      if ((blockMode[i] == 'A') && (blockMode[i - 1] == 'N')) {
        if (blockLength[i - 1] < tribus(version, 6, 8, 10)) {
          blockMode[i - 1] = 'A';
        }
      }
    }
  }
  j = 0;
  for (block = 0; block < blockCount; block++) {
    currentMode = blockMode[block];
    for (i = 0; i < blockLength[block]; i++) {
      inputMode[j] = currentMode;
      j++;
    }
  }
  free(blockLength);
  free(blockMode);
}


x86 assembly (clang, -O0):
<applyOptimisation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movb   $0x20,-0x25(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b2 <applyOptimisation+0x72>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x25(%rbp),%ecx
cmp    %ecx,%eax
je     119f <applyOptimisation+0x5f>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x25(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a4 <applyOptimisation+0x64>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1164 <applyOptimisation+0x24>
movslq -0x18(%rbp),%rdi
shl    $0x2,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x0,%al
call   1050 <assert@plt>
cmpq   $0x0,-0x30(%rbp)
jne    11de <applyOptimisation+0x9e>
jmp    1729 <applyOptimisation+0x5e9>
movslq -0x18(%rbp),%rdi
shl    $0x0,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0x0,%al
call   1050 <assert@plt>
cmpq   $0x0,-0x38(%rbp)
jne    1213 <applyOptimisation+0xd3>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    1729 <applyOptimisation+0x5e9>
movl   $0xffffffff,-0x24(%rbp)
movb   $0x20,-0x25(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12ae <applyOptimisation+0x16e>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x25(%rbp),%ecx
cmp    %ecx,%eax
je     128a <applyOptimisation+0x14a>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x38(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x25(%rbp)
jmp    129b <applyOptimisation+0x15b>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
jmp    12a0 <applyOptimisation+0x160>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1225 <applyOptimisation+0xe5>
cmpl   $0x1,-0x18(%rbp)
jle    169c <applyOptimisation+0x55c>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jg     14a8 <applyOptimisation+0x368>
mov    -0x38(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x42,%eax
jne    1417 <applyOptimisation+0x2d7>
mov    -0x38(%rbp),%rcx
movslq -0x20(%rbp),%rax
movsbl 0x1(%rax,%rcx,1),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x41,%eax
je     1374 <applyOptimisation+0x234>
jmp    1303 <applyOptimisation+0x1c3>
mov    -0x3c(%rbp),%eax
sub    $0x4b,%eax
je     1325 <applyOptimisation+0x1e5>
jmp    1314 <applyOptimisation+0x1d4>
mov    -0x3c(%rbp),%eax
sub    $0x4e,%eax
je     13c3 <applyOptimisation+0x283>
jmp    1412 <applyOptimisation+0x2d2>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x40(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
mov    $0x5,%edx
mov    $0x6,%ecx
mov    $0x0,%al
call   1040 <tribus@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
cmp    %ecx,%eax
jge    136f <applyOptimisation+0x22f>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x42,(%rax,%rcx,1)
jmp    1412 <applyOptimisation+0x2d2>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x44(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x7,%esi
mov    $0x8,%edx
mov    $0x9,%ecx
mov    $0x0,%al
call   1040 <tribus@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jge    13be <applyOptimisation+0x27e>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x42,(%rax,%rcx,1)
jmp    1412 <applyOptimisation+0x2d2>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x48(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
mov    $0x4,%edx
mov    $0x5,%ecx
mov    $0x0,%al
call   1040 <tribus@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
cmp    %ecx,%eax
jge    140d <applyOptimisation+0x2cd>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x42,(%rax,%rcx,1)
jmp    1412 <applyOptimisation+0x2d2>
jmp    1417 <applyOptimisation+0x2d7>
mov    -0x38(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x41,%eax
jne    1495 <applyOptimisation+0x355>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x4e,%eax
jne    1495 <applyOptimisation+0x355>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x6,%esi
mov    $0x8,%edx
mov    $0xa,%ecx
mov    $0x0,%al
call   1040 <tribus@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
cmp    %ecx,%eax
jge    1490 <applyOptimisation+0x350>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x41,(%rax,%rcx,1)
jmp    1495 <applyOptimisation+0x355>
jmp    149a <applyOptimisation+0x35a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12bf <applyOptimisation+0x17f>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    1697 <applyOptimisation+0x557>
mov    -0x38(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x42,%eax
jne    1606 <applyOptimisation+0x4c6>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x50(%rbp)
sub    $0x41,%eax
je     1563 <applyOptimisation+0x423>
jmp    14f2 <applyOptimisation+0x3b2>
mov    -0x50(%rbp),%eax
sub    $0x4b,%eax
je     1514 <applyOptimisation+0x3d4>
jmp    1503 <applyOptimisation+0x3c3>
mov    -0x50(%rbp),%eax
sub    $0x4e,%eax
je     15b2 <applyOptimisation+0x472>
jmp    1601 <applyOptimisation+0x4c1>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x54(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
mov    $0x5,%edx
mov    $0x6,%ecx
mov    $0x0,%al
call   1040 <tribus@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
jge    155e <applyOptimisation+0x41e>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x42,(%rax,%rcx,1)
jmp    1601 <applyOptimisation+0x4c1>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x58(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x7,%esi
mov    $0x8,%edx
mov    $0x9,%ecx
mov    $0x0,%al
call   1040 <tribus@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
cmp    %ecx,%eax
jge    15ad <applyOptimisation+0x46d>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x42,(%rax,%rcx,1)
jmp    1601 <applyOptimisation+0x4c1>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
mov    $0x4,%edx
mov    $0x5,%ecx
mov    $0x0,%al
call   1040 <tribus@plt>
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
cmp    %ecx,%eax
jge    15fc <applyOptimisation+0x4bc>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x42,(%rax,%rcx,1)
jmp    1601 <applyOptimisation+0x4c1>
jmp    1606 <applyOptimisation+0x4c6>
mov    -0x38(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x41,%eax
jne    1684 <applyOptimisation+0x544>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x4e,%eax
jne    1684 <applyOptimisation+0x544>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x60(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x6,%esi
mov    $0x8,%edx
mov    $0xa,%ecx
mov    $0x0,%al
call   1040 <tribus@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%eax
cmp    %ecx,%eax
jge    167f <applyOptimisation+0x53f>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x41,(%rax,%rcx,1)
jmp    1684 <applyOptimisation+0x544>
jmp    1689 <applyOptimisation+0x549>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    14b1 <applyOptimisation+0x371>
jmp    169c <applyOptimisation+0x55c>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1717 <applyOptimisation+0x5d7>
mov    -0x38(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x25(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x30(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1704 <applyOptimisation+0x5c4>
mov    -0x25(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    16cb <applyOptimisation+0x58b>
jmp    1709 <applyOptimisation+0x5c9>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    16aa <applyOptimisation+0x56a>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<applyOptimisation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r13d
mov    %rsi,%r12
mov    %edi,0xc(%rsp)
test   %edx,%edx
jle    1181 <applyOptimisation+0x31>
mov    %r13d,%eax
cmp    $0x8,%r13d
jae    1188 <applyOptimisation+0x38>
mov    $0x20,%sil
xor    %ecx,%ecx
xor    %edx,%edx
jmp    1270 <applyOptimisation+0x120>
xor    %edx,%edx
jmp    128b <applyOptimisation+0x13b>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
movaps 0xe6c(%rip),%xmm0
pxor   %xmm1,%xmm1
xor    %edx,%edx
movaps 0xe6e(%rip),%xmm8
pcmpeqd %xmm9,%xmm9
movdqa 0xe71(%rip),%xmm5
pxor   %xmm2,%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  (%r12,%rdx,1),%xmm3
xorps  %xmm7,%xmm7
movss  %xmm0,%xmm7
movss  0x4(%r12,%rdx,1),%xmm0
movaps %xmm3,%xmm6
andps  %xmm8,%xmm6
orps   %xmm7,%xmm6
psrld  $0x18,%xmm6
movaps %xmm3,%xmm7
pslld  $0x8,%xmm7
por    %xmm6,%xmm7
movaps %xmm0,%xmm6
andps  %xmm8,%xmm6
orps   %xmm3,%xmm6
psrld  $0x18,%xmm6
movaps %xmm0,%xmm4
pslld  $0x8,%xmm4
por    %xmm6,%xmm4
pcmpeqb %xmm3,%xmm7
pxor   %xmm9,%xmm7
punpcklbw %xmm7,%xmm7
punpcklwd %xmm7,%xmm7
pand   %xmm5,%xmm7
paddd  %xmm7,%xmm1
pcmpeqb %xmm0,%xmm4
pxor   %xmm9,%xmm4
punpcklbw %xmm4,%xmm4
punpcklwd %xmm4,%xmm4
pand   %xmm5,%xmm4
paddd  %xmm4,%xmm2
add    $0x8,%rdx
cmp    %rdx,%rcx
jne    11c0 <applyOptimisation+0x70>
paddd  %xmm1,%xmm2
pshufd $0xee,%xmm2,%xmm1
paddd  %xmm2,%xmm1
pshufd $0x55,%xmm1,%xmm2
paddd  %xmm1,%xmm2
movd   %xmm2,%edx
cmp    %rax,%rcx
je     128b <applyOptimisation+0x13b>
movd   %xmm0,%esi
shr    $0x18,%esi
nop
movzbl (%r12,%rcx,1),%ebx
xor    %edi,%edi
cmp    %sil,%bl
setne  %dil
add    %edi,%edx
add    $0x1,%rcx
mov    %ebx,%esi
cmp    %rcx,%rax
jne    1270 <applyOptimisation+0x120>
mov    %edx,%ebp
lea    0x0(,%rbp,4),%rdi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <assert@plt>
test   %rbx,%rbx
je     142e <applyOptimisation+0x2de>
mov    %rbx,0x10(%rsp)
mov    %rbp,0x20(%rsp)
mov    %rbp,%rdi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <assert@plt>
test   %r14,%r14
je     143d <applyOptimisation+0x2ed>
test   %r13d,%r13d
mov    0x10(%rsp),%rdi
jle    1321 <applyOptimisation+0x1d1>
mov    %r13d,%esi
mov    $0xffffffff,%ecx
mov    $0x20,%al
xor    %edx,%edx
jmp    1300 <applyOptimisation+0x1b0>
movslq %ecx,%rbp
addl   $0x1,(%rdi,%rbp,4)
add    $0x1,%rdx
cmp    %rdx,%rsi
je     1321 <applyOptimisation+0x1d1>
movzbl (%r12,%rdx,1),%ebx
cmp    %al,%bl
je     12f0 <applyOptimisation+0x1a0>
movslq %ecx,%rax
lea    0x1(%rax),%rcx
movl   $0x1,0x4(%rdi,%rax,4)
mov    %bl,0x1(%r14,%rax,1)
mov    %ebx,%eax
jmp    12f7 <applyOptimisation+0x1a7>
cmpl   $0x2,0x20(%rsp)
jb     156c <applyOptimisation+0x41c>
mov    0x20(%rsp),%r15
cmp    $0x2,%r15d
jl     1576 <applyOptimisation+0x426>
lea    -0x1(%r15),%r13d
xor    %ebx,%ebx
jmp    1359 <applyOptimisation+0x209>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %rbx,%r13
je     1447 <applyOptimisation+0x2f7>
mov    %rbx,%rbp
movzbl (%r14,%rbx,1),%eax
cmp    $0x42,%al
jne    13de <applyOptimisation+0x28e>
movsbl 0x1(%r14,%rbp,1),%eax
cmp    $0x41,%eax
je     13ac <applyOptimisation+0x25c>
cmp    $0x4e,%eax
je     1393 <applyOptimisation+0x243>
cmp    $0x4b,%eax
jne    13d9 <applyOptimisation+0x289>
mov    0x4(%rdi,%rbp,4),%ebx
mov    0xc(%rsp),%edi
mov    $0x4,%esi
mov    $0x5,%edx
mov    $0x6,%ecx
jmp    13c3 <applyOptimisation+0x273>
mov    0x4(%rdi,%rbp,4),%ebx
mov    0xc(%rsp),%edi
mov    $0x3,%esi
mov    $0x4,%edx
mov    $0x5,%ecx
jmp    13c3 <applyOptimisation+0x273>
mov    0x4(%rdi,%rbp,4),%ebx
mov    0xc(%rsp),%edi
mov    $0x7,%esi
mov    $0x8,%edx
mov    $0x9,%ecx
xor    %eax,%eax
call   1050 <tribus@plt>
mov    0x10(%rsp),%rdi
cmp    %eax,%ebx
jge    13d9 <applyOptimisation+0x289>
movb   $0x42,0x1(%r14,%rbp,1)
movzbl (%r14,%rbp,1),%eax
lea    0x1(%rbp),%rbx
cmp    $0x41,%al
jne    1350 <applyOptimisation+0x200>
cmpb   $0x4e,0x1(%r14,%rbp,1)
jne    1350 <applyOptimisation+0x200>
mov    0x4(%rdi,%rbp,4),%r15d
mov    0xc(%rsp),%edi
mov    $0x6,%esi
mov    $0x8,%edx
mov    $0xa,%ecx
xor    %eax,%eax
call   1050 <tribus@plt>
mov    0x10(%rsp),%rdi
cmp    %eax,%r15d
jge    1350 <applyOptimisation+0x200>
movb   $0x41,0x1(%r14,%rbp,1)
jmp    1350 <applyOptimisation+0x200>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rsp),%rdi
jmp    15af <applyOptimisation+0x45f>
cmpl   $0x2,0x20(%rsp)
jl     156c <applyOptimisation+0x41c>
mov    $0xfffffffe,%r13d
mov    0x20(%rsp),%rax
add    %rax,%r13
lea    -0x1(%rax),%rbp
jmp    1489 <applyOptimisation+0x339>
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%r13
lea    -0x1(%rbp),%rax
add    $0x1,%rbp
cmp    $0x2,%rbp
mov    %rax,%rbp
jle    156c <applyOptimisation+0x41c>
mov    %ebp,%ebx
movzbl (%r14,%rbx,1),%eax
cmp    $0x42,%al
jne    1520 <applyOptimisation+0x3d0>
mov    %r13d,%r15d
movsbl (%r14,%r15,1),%eax
cmp    $0x41,%eax
je     14e9 <applyOptimisation+0x399>
cmp    $0x4e,%eax
je     14cc <applyOptimisation+0x37c>
cmp    $0x4b,%eax
jne    151b <applyOptimisation+0x3cb>
mov    (%rdi,%r15,4),%eax
mov    %eax,0x1c(%rsp)
mov    0xc(%rsp),%edi
mov    $0x4,%esi
mov    $0x5,%edx
mov    $0x6,%ecx
jmp    1504 <applyOptimisation+0x3b4>
mov    (%rdi,%r15,4),%eax
mov    %eax,0x1c(%rsp)
mov    0xc(%rsp),%edi
mov    $0x3,%esi
mov    $0x4,%edx
mov    $0x5,%ecx
jmp    1504 <applyOptimisation+0x3b4>
mov    (%rdi,%r15,4),%eax
mov    %eax,0x1c(%rsp)
mov    0xc(%rsp),%edi
mov    $0x7,%esi
mov    $0x8,%edx
mov    $0x9,%ecx
xor    %eax,%eax
call   1050 <tribus@plt>
mov    0x10(%rsp),%rdi
cmp    %eax,0x1c(%rsp)
jge    151b <applyOptimisation+0x3cb>
movb   $0x42,(%r14,%r15,1)
movzbl (%r14,%rbx,1),%eax
cmp    $0x41,%al
jne    1470 <applyOptimisation+0x320>
mov    %r13d,%ebx
cmpb   $0x4e,(%r14,%rbx,1)
jne    1470 <applyOptimisation+0x320>
mov    (%rdi,%rbx,4),%r15d
mov    0xc(%rsp),%edi
mov    $0x6,%esi
mov    $0x8,%edx
mov    $0xa,%ecx
xor    %eax,%eax
call   1050 <tribus@plt>
mov    0x10(%rsp),%rdi
cmp    %eax,%r15d
jge    1470 <applyOptimisation+0x320>
movb   $0x41,(%r14,%rbx,1)
jmp    1470 <applyOptimisation+0x320>
mov    0x20(%rsp),%r15
test   %r15,%r15
je     15a7 <applyOptimisation+0x457>
cmp    $0x1,%r15d
jne    15c2 <applyOptimisation+0x472>
xor    %ebx,%ebx
xor    %r13d,%r13d
testb  $0x1,0x20(%rsp)
je     15a7 <applyOptimisation+0x457>
mov    (%rdi,%rbx,4),%edx
test   %edx,%edx
jle    15a7 <applyOptimisation+0x457>
movslq %r13d,%rax
add    %rax,%r12
movzbl (%r14,%rbx,1),%esi
mov    %r12,%rdi
call   1040 <memset@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
and    $0xfffffffe,%r15d
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    15d9 <applyOptimisation+0x489>
nopl   (%rax)
add    $0x2,%rbx
cmp    %rbx,%r15
je     1581 <applyOptimisation+0x431>
mov    (%rdi,%rbx,4),%ebp
test   %ebp,%ebp
jle    15fc <applyOptimisation+0x4ac>
movslq %r13d,%r13
lea    (%r12,%r13,1),%rdi
movzbl (%r14,%rbx,1),%esi
mov    %rbp,%rdx
call   1040 <memset@plt>
mov    0x10(%rsp),%rdi
add    %ebp,%r13d
mov    0x4(%rdi,%rbx,4),%ebp
test   %ebp,%ebp
jle    15d0 <applyOptimisation+0x480>
movslq %r13d,%r13
lea    (%r12,%r13,1),%rdi
movzbl 0x1(%r14,%rbx,1),%esi
mov    %rbp,%rdx
call   1040 <memset@plt>
mov    0x10(%rsp),%rdi
add    %ebp,%r13d
jmp    15d0 <applyOptimisation+0x480>

LLVM IR (-O0):
define void @applyOptimisation(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
%12 = alloca i32*
%13 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i8 32, i8* %11
store i32 0, i32* %9
br label %14
14: ; preds = %37, %3
%15 = load i32, i32* %9
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %40
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = load i8, i8* %11
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %24, %26
br i1 %27, label %28, label %36
28: ; preds = %18
%29 = load i8*, i8** %5
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
store i8 %33, i8* %11
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %36
36: ; preds = %28, %18
br label %37
37: ; preds = %36
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
br label %14
40: ; preds = %14
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = mul i64 4, %42
%44 = call i8* @malloc(i64 %43)
%45 = bitcast i8* %44 to i32*
store i32* %45, i32** %12
%46 = load i32*, i32** %12
%47 = call i32 (i32*, ...) bitcast (i32 (...)* @assert to i32 (i32*, ...)*)(i32* %46)
%48 = load i32*, i32** %12
%49 = icmp ne i32* %48, null
br i1 %49, label %51, label %50
50: ; preds = %40
br label %376
51: ; preds = %40
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = mul i64 1, %53
%55 = call i8* @malloc(i64 %54)
store i8* %55, i8** %13
%56 = load i8*, i8** %13
%57 = call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %56)
%58 = load i8*, i8** %13
%59 = icmp ne i8* %58, null
br i1 %59, label %63, label %60
60: ; preds = %51
%61 = load i32*, i32** %12
%62 = bitcast i32* %61 to i8*
br label %376
63: ; preds = %51
store i32 -1, i32* %10
store i8 32, i8* %11
store i32 0, i32* %9
br label %64
64: ; preds = %107, %63
%65 = load i32, i32* %9
%66 = load i32, i32* %6
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %110
68: ; preds = %64
%69 = load i8*, i8** %5
%70 = load i32, i32* %9
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = load i8, i8* %11
%76 = sext i8 %75 to i32
%77 = icmp ne i32 %74, %76
br i1 %77, label %78, label %99
78: ; preds = %68
%79 = load i32, i32* %10
%80 = add nsw i32 %79, 1
store i32 %80, i32* %10
%81 = load i32*, i32** %12
%82 = load i32, i32* %10
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %81, i64 %83
store i32 1, i32* %84
%85 = load i8*, i8** %5
%86 = load i32, i32* %9
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %85, i64 %87
%89 = load i8, i8* %88
%90 = load i8*, i8** %13
%91 = load i32, i32* %10
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %90, i64 %92
store i8 %89, i8* %93
%94 = load i8*, i8** %5
%95 = load i32, i32* %9
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
%98 = load i8, i8* %97
store i8 %98, i8* %11
br label %106
99: ; preds = %68
%100 = load i32*, i32** %12
%101 = load i32, i32* %10
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i32, i32* %100, i64 %102
%104 = load i32, i32* %103
%105 = add nsw i32 %104, 1
store i32 %105, i32* %103
br label %106
106: ; preds = %99, %78
br label %107
107: ; preds = %106
%108 = load i32, i32* %9
%109 = add nsw i32 %108, 1
store i32 %109, i32* %9
br label %64
110: ; preds = %64
%111 = load i32, i32* %7
%112 = icmp sgt i32 %111, 1
br i1 %112, label %113, label %338
113: ; preds = %110
store i32 0, i32* %9
br label %114
114: ; preds = %222, %113
%115 = load i32, i32* %9
%116 = load i32, i32* %7
%117 = sub nsw i32 %116, 2
%118 = icmp sle i32 %115, %117
br i1 %118, label %119, label %225
119: ; preds = %114
%120 = load i8*, i8** %13
%121 = load i32, i32* %9
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds i8, i8* %120, i64 %122
%124 = load i8, i8* %123
%125 = sext i8 %124 to i32
%126 = icmp eq i32 %125, 66
br i1 %126, label %127, label %187
127: ; preds = %119
%128 = load i8*, i8** %13
%129 = load i32, i32* %9
%130 = add nsw i32 %129, 1
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds i8, i8* %128, i64 %131
%133 = load i8, i8* %132
%134 = sext i8 %133 to i32
switch i32 %134, label %186 [
i32 75, label %135
i32 65, label %152
i32 78, label %169
]
135: ; preds = %127
%136 = load i32*, i32** %12
%137 = load i32, i32* %9
%138 = add nsw i32 %137, 1
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds i32, i32* %136, i64 %139
%141 = load i32, i32* %140
%142 = load i32, i32* %4
%143 = call i32 (i32, i32, i32, i32, ...) bitcast (i32 (...)* @tribus to i32 (i32, i32, i32, i32, ...)*)(i32 %142, i32 4, i32 5, i32 6)
%144 = icmp slt i32 %141, %143
br i1 %144, label %145, label %151
145: ; preds = %135
%146 = load i8*, i8** %13
%147 = load i32, i32* %9
%148 = add nsw i32 %147, 1
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds i8, i8* %146, i64 %149
store i8 66, i8* %150
br label %151
151: ; preds = %145, %135
br label %186
152: ; preds = %127
%153 = load i32*, i32** %12
%154 = load i32, i32* %9
%155 = add nsw i32 %154, 1
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds i32, i32* %153, i64 %156
%158 = load i32, i32* %157
%159 = load i32, i32* %4
%160 = call i32 (i32, i32, i32, i32, ...) bitcast (i32 (...)* @tribus to i32 (i32, i32, i32, i32, ...)*)(i32 %159, i32 7, i32 8, i32 9)
%161 = icmp slt i32 %158, %160
br i1 %161, label %162, label %168
162: ; preds = %152
%163 = load i8*, i8** %13
%164 = load i32, i32* %9
%165 = add nsw i32 %164, 1
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds i8, i8* %163, i64 %166
store i8 66, i8* %167
br label %168
168: ; preds = %162, %152
br label %186
169: ; preds = %127
%170 = load i32*, i32** %12
%171 = load i32, i32* %9
%172 = add nsw i32 %171, 1
%173 = sext i32 %172 to i64
%174 = getelementptr inbounds i32, i32* %170, i64 %173
%175 = load i32, i32* %174
%176 = load i32, i32* %4
%177 = call i32 (i32, i32, i32, i32, ...) bitcast (i32 (...)* @tribus to i32 (i32, i32, i32, i32, ...)*)(i32 %176, i32 3, i32 4, i32 5)
%178 = icmp slt i32 %175, %177
br i1 %178, label %179, label %185
179: ; preds = %169
%180 = load i8*, i8** %13
%181 = load i32, i32* %9
%182 = add nsw i32 %181, 1
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds i8, i8* %180, i64 %183
store i8 66, i8* %184
br label %185
185: ; preds = %179, %169
br label %186
186: ; preds = %127, %185, %168, %151
br label %187
187: ; preds = %186, %119
%188 = load i8*, i8** %13
%189 = load i32, i32* %9
%190 = sext i32 %189 to i64
%191 = getelementptr inbounds i8, i8* %188, i64 %190
%192 = load i8, i8* %191
%193 = sext i8 %192 to i32
%194 = icmp eq i32 %193, 65
br i1 %194, label %195, label %221
195: ; preds = %187
%196 = load i8*, i8** %13
%197 = load i32, i32* %9
%198 = add nsw i32 %197, 1
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds i8, i8* %196, i64 %199
%201 = load i8, i8* %200
%202 = sext i8 %201 to i32
%203 = icmp eq i32 %202, 78
br i1 %203, label %204, label %221
204: ; preds = %195
%205 = load i32*, i32** %12
%206 = load i32, i32* %9
%207 = add nsw i32 %206, 1
%208 = sext i32 %207 to i64
%209 = getelementptr inbounds i32, i32* %205, i64 %208
%210 = load i32, i32* %209
%211 = load i32, i32* %4
%212 = call i32 (i32, i32, i32, i32, ...) bitcast (i32 (...)* @tribus to i32 (i32, i32, i32, i32, ...)*)(i32 %211, i32 6, i32 8, i32 10)
%213 = icmp slt i32 %210, %212
br i1 %213, label %214, label %220
214: ; preds = %204
%215 = load i8*, i8** %13
%216 = load i32, i32* %9
%217 = add nsw i32 %216, 1
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds i8, i8* %215, i64 %218
store i8 65, i8* %219
br label %220
220: ; preds = %214, %204
br label %221
221: ; preds = %220, %195, %187
br label %222
222: ; preds = %221
%223 = load i32, i32* %9
%224 = add nsw i32 %223, 1
store i32 %224, i32* %9
br label %114
225: ; preds = %114
%226 = load i32, i32* %7
%227 = sub nsw i32 %226, 1
store i32 %227, i32* %9
br label %228
228: ; preds = %334, %225
%229 = load i32, i32* %9
%230 = icmp sgt i32 %229, 0
br i1 %230, label %231, label %337
231: ; preds = %228
%232 = load i8*, i8** %13
%233 = load i32, i32* %9
%234 = sext i32 %233 to i64
%235 = getelementptr inbounds i8, i8* %232, i64 %234
%236 = load i8, i8* %235
%237 = sext i8 %236 to i32
%238 = icmp eq i32 %237, 66
br i1 %238, label %239, label %299
239: ; preds = %231
%240 = load i8*, i8** %13
%241 = load i32, i32* %9
%242 = sub nsw i32 %241, 1
%243 = sext i32 %242 to i64
%244 = getelementptr inbounds i8, i8* %240, i64 %243
%245 = load i8, i8* %244
%246 = sext i8 %245 to i32
switch i32 %246, label %298 [
i32 75, label %247
i32 65, label %264
i32 78, label %281
]
247: ; preds = %239
%248 = load i32*, i32** %12
%249 = load i32, i32* %9
%250 = sub nsw i32 %249, 1
%251 = sext i32 %250 to i64
%252 = getelementptr inbounds i32, i32* %248, i64 %251
%253 = load i32, i32* %252
%254 = load i32, i32* %4
%255 = call i32 (i32, i32, i32, i32, ...) bitcast (i32 (...)* @tribus to i32 (i32, i32, i32, i32, ...)*)(i32 %254, i32 4, i32 5, i32 6)
%256 = icmp slt i32 %253, %255
br i1 %256, label %257, label %263
257: ; preds = %247
%258 = load i8*, i8** %13
%259 = load i32, i32* %9
%260 = sub nsw i32 %259, 1
%261 = sext i32 %260 to i64
%262 = getelementptr inbounds i8, i8* %258, i64 %261
store i8 66, i8* %262
br label %263
263: ; preds = %257, %247
br label %298
264: ; preds = %239
%265 = load i32*, i32** %12
%266 = load i32, i32* %9
%267 = sub nsw i32 %266, 1
%268 = sext i32 %267 to i64
%269 = getelementptr inbounds i32, i32* %265, i64 %268
%270 = load i32, i32* %269
%271 = load i32, i32* %4
%272 = call i32 (i32, i32, i32, i32, ...) bitcast (i32 (...)* @tribus to i32 (i32, i32, i32, i32, ...)*)(i32 %271, i32 7, i32 8, i32 9)
%273 = icmp slt i32 %270, %272
br i1 %273, label %274, label %280
274: ; preds = %264
%275 = load i8*, i8** %13
%276 = load i32, i32* %9
%277 = sub nsw i32 %276, 1
%278 = sext i32 %277 to i64
%279 = getelementptr inbounds i8, i8* %275, i64 %278
store i8 66, i8* %279
br label %280
280: ; preds = %274, %264
br label %298
281: ; preds = %239
%282 = load i32*, i32** %12
%283 = load i32, i32* %9
%284 = sub nsw i32 %283, 1
%285 = sext i32 %284 to i64
%286 = getelementptr inbounds i32, i32* %282, i64 %285
%287 = load i32, i32* %286
%288 = load i32, i32* %4
%289 = call i32 (i32, i32, i32, i32, ...) bitcast (i32 (...)* @tribus to i32 (i32, i32, i32, i32, ...)*)(i32 %288, i32 3, i32 4, i32 5)
%290 = icmp slt i32 %287, %289
br i1 %290, label %291, label %297
291: ; preds = %281
%292 = load i8*, i8** %13
%293 = load i32, i32* %9
%294 = sub nsw i32 %293, 1
%295 = sext i32 %294 to i64
%296 = getelementptr inbounds i8, i8* %292, i64 %295
store i8 66, i8* %296
br label %297
297: ; preds = %291, %281
br label %298
298: ; preds = %239, %297, %280, %263
br label %299
299: ; preds = %298, %231
%300 = load i8*, i8** %13
%301 = load i32, i32* %9
%302 = sext i32 %301 to i64
%303 = getelementptr inbounds i8, i8* %300, i64 %302
%304 = load i8, i8* %303
%305 = sext i8 %304 to i32
%306 = icmp eq i32 %305, 65
br i1 %306, label %307, label %333
307: ; preds = %299
%308 = load i8*, i8** %13
%309 = load i32, i32* %9
%310 = sub nsw i32 %309, 1
%311 = sext i32 %310 to i64
%312 = getelementptr inbounds i8, i8* %308, i64 %311
%313 = load i8, i8* %312
%314 = sext i8 %313 to i32
%315 = icmp eq i32 %314, 78
br i1 %315, label %316, label %333
316: ; preds = %307
%317 = load i32*, i32** %12
%318 = load i32, i32* %9
%319 = sub nsw i32 %318, 1
%320 = sext i32 %319 to i64
%321 = getelementptr inbounds i32, i32* %317, i64 %320
%322 = load i32, i32* %321
%323 = load i32, i32* %4
%324 = call i32 (i32, i32, i32, i32, ...) bitcast (i32 (...)* @tribus to i32 (i32, i32, i32, i32, ...)*)(i32 %323, i32 6, i32 8, i32 10)
%325 = icmp slt i32 %322, %324
br i1 %325, label %326, label %332
326: ; preds = %316
%327 = load i8*, i8** %13
%328 = load i32, i32* %9
%329 = sub nsw i32 %328, 1
%330 = sext i32 %329 to i64
%331 = getelementptr inbounds i8, i8* %327, i64 %330
store i8 65, i8* %331
br label %332
332: ; preds = %326, %316
br label %333
333: ; preds = %332, %307, %299
br label %334
334: ; preds = %333
%335 = load i32, i32* %9
%336 = add nsw i32 %335, -1
store i32 %336, i32* %9
br label %228
337: ; preds = %228
br label %338
338: ; preds = %337, %110
store i32 0, i32* %10
store i32 0, i32* %8
br label %339
339: ; preds = %369, %338
%340 = load i32, i32* %8
%341 = load i32, i32* %7
%342 = icmp slt i32 %340, %341
br i1 %342, label %343, label %372
343: ; preds = %339
%344 = load i8*, i8** %13
%345 = load i32, i32* %8
%346 = sext i32 %345 to i64
%347 = getelementptr inbounds i8, i8* %344, i64 %346
%348 = load i8, i8* %347
store i8 %348, i8* %11
store i32 0, i32* %9
br label %349
349: ; preds = %365, %343
%350 = load i32, i32* %9
%351 = load i32*, i32** %12
%352 = load i32, i32* %8
%353 = sext i32 %352 to i64
%354 = getelementptr inbounds i32, i32* %351, i64 %353
%355 = load i32, i32* %354
%356 = icmp slt i32 %350, %355
br i1 %356, label %357, label %368
357: ; preds = %349
%358 = load i8, i8* %11
%359 = load i8*, i8** %5
%360 = load i32, i32* %10
%361 = sext i32 %360 to i64
%362 = getelementptr inbounds i8, i8* %359, i64 %361
store i8 %358, i8* %362
%363 = load i32, i32* %10
%364 = add nsw i32 %363, 1
store i32 %364, i32* %10
br label %365
365: ; preds = %357
%366 = load i32, i32* %9
%367 = add nsw i32 %366, 1
store i32 %367, i32* %9
br label %349
368: ; preds = %349
br label %369
369: ; preds = %368
%370 = load i32, i32* %8
%371 = add nsw i32 %370, 1
store i32 %371, i32* %8
br label %339
372: ; preds = %339
%373 = load i32*, i32** %12
%374 = bitcast i32* %373 to i8*
%375 = load i8*, i8** %13
br label %376
376: ; preds = %372, %60, %50
ret void
}

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