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

```asm
<micro_qr_intermediate>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x58,%rsp
  mov    0x90(%rsp),%rax
  mov    %rsi,0x18(%rsp)
  lea    D44(%rip),%rsi
  mov    %rdx,0x10(%rsp)
  mov    %ecx,0xc(%rsp)
  mov    %r8,0x20(%rsp)
  mov    %r9,0x28(%rsp)
  mov    %rax,0x30(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  call   <strcpy@plt>
L152:
  mov    %rbx,%rdi
  call   <strlen@plt>
  cmp    $0x80,%eax
  jg     L165
  mov    0x10(%rsp),%rcx
  movslq %r12d,%r14
  mov    0xc(%rsp),%edi
  xor    %r13d,%r13d
  lea    (%rcx,%r14,1),%rax
  lea    0x1(%rcx,%r14,1),%rdx
  mov    %rax,(%rsp)
  movzbl (%rax),%esi
  lea    0x1(%r12),%eax
  jmp    L68
  nopw   0x0(%rax,%rax,1)
L310:
  movzbl (%rdx),%ecx
  add    $0x1,%eax
  add    $0x1,%rdx
  cmp    %sil,%cl
  jne    L349
L68:
  movslq %r13d,%rbp
  mov    %eax,%r12d
  add    $0x1,%r13d
  cmp    %edi,%eax
  jl     L310
L349:
  cmp    $0x4b,%sil
  je     L295
  jg     L118
  cmp    $0x41,%sil
  je     L113
  cmp    $0x42,%sil
  jne    L256
  lea    D51(%rip),%rsi
  mov    %rbx,%rdi
  add    %r14,%rbp
  call   <strcat@plt>
  mov    0x30(%rsp),%rax
  lea    0x46(%rsp),%rsi
  mov    %rbx,%rdi
  mov    %r13b,0x46(%rsp)
  movl   $0x1,(%rax)
  movb   $0x0,0x47(%rsp)
  call   <strcat@plt>
  mov    0x18(%rsp),%rax
  lea    (%rax,%r14,4),%r15
  lea    0x4(%rax,%rbp,4),%rbp
  nopw   0x0(%rax,%rax,1)
L59:
  mov    (%r15),%esi
  mov    %rbx,%rdi
  mov    $0x80,%edx
  call   <qr_diran@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  cmp    $0x80,%eax
  jg     L165
  add    $0x4,%r15
  cmp    %r15,%rbp
  jne    L59
L256:
  mov    0xc(%rsp),%eax
  sub    $0x1,%eax
  cmp    %eax,%r12d
  jl     L152
L325:
  xor    %eax,%eax
  jmp    L273
  nopl   0x0(%rax,%rax,1)
L118:
  cmp    $0x4e,%sil
  jne    L256
  lea    D36(%rip),%rsi
  mov    %rbx,%rdi
  xor    %r15d,%r15d
  call   <strcat@plt>
  lea    0x46(%rsp),%rsi
  mov    %rbx,%rdi
  mov    %r13b,0x46(%rsp)
  movb   $0x0,0x47(%rsp)
  call   <strcat@plt>
  mov    0x18(%rsp),%rax
  mov    %r12d,0x38(%rsp)
  mov    %r15,%r12
  mov    %ebp,%r15d
  mov    (%rsp),%rbp
  lea    (%rax,%r14,4),%r14
  jmp    L78
  nopl   0x0(%rax)
L247:
  lea    (%rax,%rax,2),%ecx
  mov    $0x1,%edx
  shl    %cl,%edx
L283:
  mov    %rbx,%rdi
  mov    %r9d,%esi
  call   <qr_diran@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  cmp    $0x80,%eax
  jg     L165
  add    $0x3,%r12
  add    $0xc,%r14
  cmp    %r12d,%r13d
  jle    L13
L78:
  movsbl (%r14),%esi
  lea    D83(%rip),%rdi
  call   <posn@plt>
  mov    %eax,%r9d
  mov    $0x1,%eax
  cmp    %r12d,%r15d
  jle    L203
  cmpb   $0x4e,0x1(%rbp,%r12,1)
  je     L178
L203:
  lea    0x2(%r12),%edx
  cmp    %edx,%r13d
  jle    L247
  cmpb   $0x4e,0x2(%rbp,%r12,1)
  jne    L247
  movsbl 0x8(%r14),%esi
  lea    D83(%rip),%rdi
  mov    %r9d,(%rsp)
  call   <posn@plt>
  mov    (%rsp),%r9d
  lea    (%r9,%r9,4),%edx
  lea    (%rax,%rdx,2),%r9d
  mov    $0x200,%edx
  jmp    L283
  nopl   0x0(%rax,%rax,1)
L165:
  mov    $0x5,%eax
L273:
  mov    0x48(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L202
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L295:
  lea    D67(%rip),%rsi
  mov    %rbx,%rdi
  add    %r14,%rbp
  call   <strcat@plt>
  mov    0x20(%rsp),%rax
  lea    0x46(%rsp),%rsi
  mov    %rbx,%rdi
  mov    %r13b,0x46(%rsp)
  movl   $0x1,(%rax)
  movb   $0x0,0x47(%rsp)
  call   <strcat@plt>
  mov    0x18(%rsp),%rax
  lea    (%rax,%r14,4),%r15
  lea    0x4(%rax,%rbp,4),%rbp
  nopw   0x0(%rax,%rax,1)
L162:
  mov    (%r15),%eax
  mov    %rbx,%rdi
  cmp    $0x9fff,%eax
  lea    -0xc140(%rax),%edx
  cmovg  %edx,%eax
  mov    %eax,%edx
  movzbl %al,%eax
  sar    $0x4,%edx
  and    $0xff0,%edx
  lea    (%rdx,%rdx,2),%esi
  mov    $0x1000,%edx
  shl    $0x6,%esi
  add    %eax,%esi
  call   <qr_diran@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  cmp    $0x80,%eax
  jg     L165
  add    $0x4,%r15
  cmp    %rbp,%r15
  jne    L162
  mov    0xc(%rsp),%eax
  sub    $0x1,%eax
  cmp    %eax,%r12d
  jl     L152
  jmp    L325
  nopl   (%rax)
L113:
  lea    D24(%rip),%rsi
  mov    %rbx,%rdi
  xor    %r15d,%r15d
  call   <strcat@plt>
  mov    0x28(%rsp),%rax
  lea    0x46(%rsp),%rsi
  mov    %rbx,%rdi
  mov    %r13b,0x46(%rsp)
  movl   $0x1,(%rax)
  movb   $0x0,0x47(%rsp)
  call   <strcat@plt>
  mov    0x18(%rsp),%rax
  mov    %r12d,0x3c(%rsp)
  mov    %r15,%r12
  mov    %r13d,%r15d
  mov    %ebp,%r13d
  lea    (%rax,%r14,4),%rax
  lea    D41(%rip),%r14
  mov    %rax,%rbp
  jmp    L3
  nopw   0x0(%rax,%rax,1)
L106:
  mov    %rbx,%rdi
  mov    %r8d,%esi
  call   <qr_diran@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  cmp    $0x80,%eax
  jg     L165
  add    $0x2,%r12
  cmp    %r12d,%r15d
  jle    L257
L3:
  movsbl 0x0(%rbp,%r12,4),%esi
  mov    %r14,%rdi
  call   <posn@plt>
  mov    $0x20,%edx
  mov    %eax,%r8d
  cmp    %r12d,%r13d
  jle    L106
  mov    (%rsp),%rax
  cmpb   $0x41,0x1(%rax,%r12,1)
  jne    L106
  movsbl 0x4(%rbp,%r12,4),%esi
  mov    %r14,%rdi
  mov    %r8d,0x38(%rsp)
  call   <posn@plt>
  mov    0x38(%rsp),%r8d
  mov    $0x400,%edx
  imul   $0x2d,%r8d,%r8d
  add    %eax,%r8d
  jmp    L106
  nopl   0x0(%rax,%rax,1)
L178:
  movsbl 0x4(%r14),%esi
  lea    D83(%rip),%rdi
  mov    %r9d,(%rsp)
  call   <posn@plt>
  mov    (%rsp),%r9d
  lea    (%r9,%r9,4),%edx
  lea    (%rax,%rdx,2),%r9d
  mov    $0x2,%eax
  jmp    L203
  nopl   0x0(%rax,%rax,1)
L13:
  mov    0xc(%rsp),%eax
  mov    0x38(%rsp),%r12d
  sub    $0x1,%eax
  cmp    %eax,%r12d
  jl     L152
  jmp    L325
  nopw   0x0(%rax,%rax,1)
L257:
  mov    0xc(%rsp),%eax
  mov    0x3c(%rsp),%r12d
  sub    $0x1,%eax
  cmp    %eax,%r12d
  jl     L152
  jmp    L325
L202:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D44
datatype: string
name: parse_data
arguments: label: D51
datatype: string
name: parse_data
arguments: label: D36
datatype: string
name: parse_data
arguments: label: D83
datatype: string
name: parse_data
arguments: label: D67
datatype: string
name: parse_data
arguments: label: D24
datatype: string
name: parse_data
arguments: label: D41
datatype: string

tool: 

tool: D51: B

tool: D36: N

tool: D83: 0123456789

tool: D67: K

tool: D24: A

tool: D41: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:

assistant: ```c
int micro_qr_intermediate(char binary[], int jisdata[], char mode[], int length, int *kanji_used, int *alphanum_used, int *byte_used) {
  int position = 0, debug = 0;
  int short_data_block_length, i;
  char data_block;
  char buffer[2];
  strcpy(binary, "");
  if (debug) {
    for (i = 0; i < length; i++) {
      printf("%c", mode[i]);
    }
    printf("\n");
  }
  do {
    if (strlen(binary) > 128) {
      return 5;
    }
    data_block = mode[position];
    short_data_block_length = 0;
    do {
      short_data_block_length++;
    } while (((short_data_block_length + position) < length) && (mode[position + short_data_block_length] == data_block));
    switch (data_block) {
    case 'K':
      strcat(binary, "K");
      *kanji_used = 1;
      buffer[0] = short_data_block_length;
      buffer[1] = '\0';
      strcat(binary, buffer);
      if (debug) {
        printf("Kanji block (length %d)\n\t", short_data_block_length);
      }
      for (i = 0; i < short_data_block_length; i++) {
        int jis = jisdata[position + i];
        int msb, lsb, prod;
        if (jis > 0x9fff) {
          jis -= 0xc140;
        }
        msb = (jis & 0xff00) >> 4;
        lsb = (jis & 0xff);
        prod = (msb * 0xc0) + lsb;
        qr_diran(binary, prod, 0x1000);
        if (debug) {
          printf("0x%4X ", prod);
        }
        if (strlen(binary) > 128) {
          return 5;
        }
      }
      if (debug) {
        printf("\n");
      }
      break;
    case 'B':
      strcat(binary, "B");
      *byte_used = 1;
      buffer[0] = short_data_block_length;
      buffer[1] = '\0';
      strcat(binary, buffer);
      if (debug) {
        printf("Byte block (length %d)\n\t", short_data_block_length);
      }
      for (i = 0; i < short_data_block_length; i++) {
        int byte = jisdata[position + i];
        qr_diran(binary, byte, 0x80);
        if (debug) {
          printf("0x%4X ", byte);
        }
        if (strlen(binary) > 128) {
          return 5;
        }
      }
      if (debug) {
        printf("\n");
      }
      break;
    case 'A':
      strcat(binary, "A");
      *alphanum_used = 1;
      buffer[0] = short_data_block_length;
      buffer[1] = '\0';
      strcat(binary, buffer);
      if (debug) {
        printf("Alpha block (length %d)\n\t", short_data_block_length);
      }
      i = 0;
      while (i < short_data_block_length) {
        int count;
        int first = 0, second = 0, prod;
        first = posn("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", (char)jisdata[position + i]);
        count = 1;
        prod = first;
        if (i + 1 < short_data_block_length && mode[position + i + 1] == 'A') {
          second = posn("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", (char)jisdata[position + i + 1]);
          count = 2;
          prod = (first * 45) + second;
        }
        qr_diran(binary, prod, 1 << (5 * count));
        if (debug) {
          printf("0x%4X ", prod);
        }
        if (strlen(binary) > 128) {
          return 5;
        }
        i += 2;
      };
      if (debug) {
        printf("\n");
      }
      break;
    case 'N':
      strcat(binary, "N");
      buffer[0] = short_data_block_length;
      buffer[1] = '\0';
      strcat(binary, buffer);
      if (debug) {
        printf("Number block (length %d)\n\t", short_data_block_length);
      }
      i = 0;
      while (i < short_data_block_length) {
        int count;
        int first = 0, second = 0, third = 0, prod;
        first = posn("0123456789", (char)jisdata[position + i]);
        count = 1;
        prod = first;
        if (i + 1 < short_data_block_length && mode[position + i + 1] == 'N') {
          second = posn("0123456789", (char)jisdata[position + i + 1]);
          count = 2;
          prod = (prod * 10) + second;
        }
        if (i + 2 < short_data_block_length && mode[position + i + 2] == 'N') {
          third = posn("0123456789", (char)jisdata[position + i + 2]);
          count = 3;
          prod = (prod * 10) + third;
        }
        qr_diran(binary, prod, 1 << (3 * count));
        if (debug) {
          printf("0x%4X (%d)", prod, prod);
        }
        if (strlen(binary) > 128) {
          return 5;
        }
        i += 3;
      };
      if (debug) {
        printf("\n");
      }
      break;
    }
    position += short_data_block_length;
  } while (position < length - 1);
  return 0;
}
```