user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x27000(%rsp),%r11
L54:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L54
  sub    $0x148,%rsp
  lea    D8(%rip),%rsi
  lea    D14(%rip),%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x27138(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  lea    0x14(%rsp),%rsi
  lea    D34(%rip),%rdi
  mov    %rax,%r12
  xor    %eax,%eax
  call   <scanf@plt>
  mov    0x14(%rsp),%eax
  test   %eax,%eax
  jle    L21
  lea    0x1c(%rsp),%rax
  xor    %r13d,%r13d
  lea    0x20(%rsp),%rbp
  mov    %rax,0x8(%rsp)
  lea    0x18(%rsp),%rax
  lea    0x138b0(%rsp),%r14
  mov    %rax,(%rsp)
  lea    D9(%rip),%rbx
L23:
  mov    0x8(%rsp),%rdx
  mov    (%rsp),%rsi
  xor    %eax,%eax
  xor    %r15d,%r15d
  lea    D16(%rip),%rdi
  call   <scanf@plt>
  nopw   0x0(%rax,%rax,1)
L22:
  mov    0x1c(%rsp),%edx
  lea    (%rdx,%rdx,1),%eax
  cmp    %r15d,%eax
  jle    L75
L70:
  lea    0x13(%rsp),%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <scanf@plt>
  movzbl 0x13(%rsp),%eax
  lea    -0x3a(%rax),%esi
  lea    -0x30(%rax),%edx
  cmp    $0x6,%sil
  jbe    L22
  cmp    $0x16,%dl
  ja     L22
  sub    $0x37,%eax
  movsbl %dl,%esi
  cmp    $0x9,%dl
  mov    0x1c(%rsp),%edx
  movsbl %al,%eax
  cmovbe %esi,%eax
  mov    %eax,0x0(%rbp,%r15,4)
  add    $0x1,%r15
  lea    (%rdx,%rdx,1),%eax
  cmp    %r15d,%eax
  jg     L70
L75:
  mov    %r14,%rsi
  mov    %rbp,%rdi
  add    $0x1,%r13d
  call   <Caculate_len@plt>
  mov    0x18(%rsp),%edx
  lea    D30(%rip),%rsi
  mov    %r12,%rdi
  mov    %eax,%ecx
  mov    %eax,%r15d
  shr    $0x1f,%ecx
  add    %eax,%ecx
  xor    %eax,%eax
  sar    %ecx
  call   <fprintf@plt>
  mov    %r12,%rdx
  mov    %r15d,%esi
  mov    %r14,%rdi
  call   <PrintEncode@plt>
  mov    %r12,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  cmp    %r13d,0x14(%rsp)
  jg     L23
L21:
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x27138(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L10
  add    $0x27148,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L10:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D8
type_infered: string
name: extract_symbolic_data
arguments: data_label: D14
type_infered: string
name: extract_symbolic_data
arguments: data_label: D34
type_infered: string
name: extract_symbolic_data
arguments: data_label: D9
type_infered: string
name: extract_symbolic_data
arguments: data_label: D16
type_infered: string
name: extract_symbolic_data
arguments: data_label: D30
type_infered: string

tool: D8: w

tool: D14: a.out

tool: D34: %d

tool: D9: %c

tool: D16: %d%d

tool: D30: %d %d


assistant: ```c
int main() {
  int p, i, j;
  FILE *f = fopen("a.out", "w");
  scanf("%d", &p);
  for (i = 0; i < p; i++) {
    int n, B;
    int read[20000 + 1], wt[20000 + 1];
    char temp;
    scanf("%d%d", &n, &B);
    for (j = 0; j < 2 * B;) {
      scanf("%c", &temp);
      if ((temp > '9' && temp < 'A') || (temp < '0') || (temp > 'F')) {
        continue;
      }
      if (temp >= '0' && temp <= '9') {
        read[j] = temp - '0';
        j++;
      } else {
        read[j] = temp - 'A' + 10;
        j++;
      }
    }
    j = Caculate_len(read, wt, B);
    fprintf(f, "%d %d\n", n, j / 2);
    PrintEncode(wt, j, f);
    fprintf(f, "\n");
  }
  fclose(f);
  return 0;
}
```