user: Please show me the C implementation that matches the assembly code listed below:

```asm
<getBinaryLength>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %ecx,-0x18(%rbp)
  mov    %r8d,-0x2c(%rbp)
  mov    %r9d,-0x30(%rbp)
  movl   $0x0,-0x4(%rbp)
  mov    -0x18(%rbp),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0x14(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <applyOptimisation@plt>
  movb   $0x20,-0xd(%rbp)
  cmpl   $0x1,-0x2c(%rbp)
  jne    L125
  addl   $0x4,-0x4(%rbp)
L125:
  cmpl   $0x3,-0x30(%rbp)
  je     L29
  addl   $0xc,-0x4(%rbp)
L29:
  movl   $0x0,-0xc(%rbp)
  jmp    L30
L260:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    %al,-0xd(%rbp)
  je     L190
  addl   $0x4,-0x4(%rbp)
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    $0x4e,%eax
  je     L77
  cmp    $0x4e,%eax
  jg     L163
  cmp    $0x4b,%eax
  je     L52
  cmp    $0x4b,%eax
  jg     L163
  cmp    $0x41,%eax
  je     L281
  cmp    $0x42,%eax
  je     L40
  jmp    L163
L52:
  mov    -0x14(%rbp),%eax
  mov    $0xc,%ecx
  mov    $0xa,%edx
  mov    $0x8,%esi
  mov    %eax,%edi
  call   <tribus@plt>
  add    %eax,-0x4(%rbp)
  mov    -0x18(%rbp),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0xc(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <blockLength@plt>
  mov    %eax,%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,-0x4(%rbp)
  jmp    L163
L40:
  mov    -0x14(%rbp),%eax
  mov    $0x10,%ecx
  mov    $0x10,%edx
  mov    $0x8,%esi
  mov    %eax,%edi
  call   <tribus@plt>
  add    %eax,-0x4(%rbp)
  mov    -0xc(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L230
L254:
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    $0xff,%eax
  jle    L33
  addl   $0x10,-0x4(%rbp)
  jmp    L214
L33:
  addl   $0x8,-0x4(%rbp)
L214:
  addl   $0x1,-0x8(%rbp)
L230:
  mov    -0x18(%rbp),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0xc(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <blockLength@plt>
  mov    -0xc(%rbp),%edx
  add    %edx,%eax
  cmp    %eax,-0x8(%rbp)
  jl     L254
  jmp    L163
L281:
  mov    -0x14(%rbp),%eax
  mov    $0xd,%ecx
  mov    $0xb,%edx
  mov    $0x9,%esi
  mov    %eax,%edi
  call   <tribus@plt>
  add    %eax,-0x4(%rbp)
  mov    -0x18(%rbp),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0xc(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <blockLength@plt>
  cltd
  shr    $0x1f,%edx
  add    %edx,%eax
  and    $0x1,%eax
  sub    %edx,%eax
  test   %eax,%eax
  je     L82
  cmp    $0x1,%eax
  je     L180
  jmp    L163
L82:
  mov    -0x18(%rbp),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0xc(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <blockLength@plt>
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  add    %eax,-0x4(%rbp)
  jmp    L266
L180:
  mov    -0x18(%rbp),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0xc(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <blockLength@plt>
  sub    $0x1,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  add    %eax,-0x4(%rbp)
  addl   $0x6,-0x4(%rbp)
  nop
L266:
  jmp    L163
L77:
  mov    -0x14(%rbp),%eax
  mov    $0xe,%ecx
  mov    $0xc,%edx
  mov    $0xa,%esi
  mov    %eax,%edi
  call   <tribus@plt>
  add    %eax,-0x4(%rbp)
  mov    -0x18(%rbp),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0xc(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <blockLength@plt>
  mov    %eax,%edx
  movslq %edx,%rax
  imul   $0x55555556,%rax,%rax
  shr    $0x20,%rax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  mov    %eax,%ecx
  add    %ecx,%ecx
  add    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  cmp    $0x2,%eax
  je     L272
  cmp    $0x2,%eax
  jg     L244
  test   %eax,%eax
  je     L137
  cmp    $0x1,%eax
  je     L67
  jmp    L244
L137:
  mov    -0x18(%rbp),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0xc(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <blockLength@plt>
  movslq %eax,%rdx
  imul   $0x55555556,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x1f,%eax
  sub    %eax,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  add    %eax,-0x4(%rbp)
  jmp    L244
L67:
  mov    -0x18(%rbp),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0xc(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <blockLength@plt>
  sub    $0x1,%eax
  movslq %eax,%rdx
  imul   $0x55555556,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x1f,%eax
  sub    %eax,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  add    %eax,-0x4(%rbp)
  addl   $0x4,-0x4(%rbp)
  jmp    L244
L272:
  mov    -0x18(%rbp),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0xc(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <blockLength@plt>
  sub    $0x2,%eax
  movslq %eax,%rdx
  imul   $0x55555556,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x1f,%eax
  sub    %eax,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  add    %eax,-0x4(%rbp)
  addl   $0x7,-0x4(%rbp)
  nop
L244:
  nop
L163:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0xd(%rbp)
L190:
  addl   $0x1,-0xc(%rbp)
L30:
  mov    -0xc(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jl     L260
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
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;
}
```