user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  lea    -0x27000(%rsp),%r11
L3:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L3
  sub    $0x140,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D17(%rip),%rax
  mov    %rax,%rsi
  lea    D55(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x27128(%rbp)
  lea    -0x2713c(%rbp),%rax
  mov    %rax,%rsi
  lea    D45(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  movl   $0x0,-0x27130(%rbp)
  jmp    L47
L8:
  lea    -0x27134(%rbp),%rdx
  lea    -0x27138(%rbp),%rax
  mov    %rax,%rsi
  lea    D49(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  movl   $0x0,-0x2712c(%rbp)
  jmp    L43
L49:
  lea    -0x2713d(%rbp),%rax
  mov    %rax,%rsi
  lea    D54(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  movzbl -0x2713d(%rbp),%eax
  cmp    $0x39,%al
  jle    L20
  movzbl -0x2713d(%rbp),%eax
  cmp    $0x40,%al
  jle    L43
L20:
  movzbl -0x2713d(%rbp),%eax
  cmp    $0x2f,%al
  jle    L43
  movzbl -0x2713d(%rbp),%eax
  cmp    $0x46,%al
  jle    L62
  jmp    L43
L62:
  movzbl -0x2713d(%rbp),%eax
  cmp    $0x2f,%al
  jle    L4
  movzbl -0x2713d(%rbp),%eax
  cmp    $0x39,%al
  jg     L4
  movzbl -0x2713d(%rbp),%eax
  movsbl %al,%eax
  lea    -0x30(%rax),%edx
  mov    -0x2712c(%rbp),%eax
  cltq
  mov    %edx,-0x27120(%rbp,%rax,4)
  addl   $0x1,-0x2712c(%rbp)
  jmp    L43
L4:
  movzbl -0x2713d(%rbp),%eax
  movsbl %al,%eax
  lea    -0x37(%rax),%edx
  mov    -0x2712c(%rbp),%eax
  cltq
  mov    %edx,-0x27120(%rbp,%rax,4)
  addl   $0x1,-0x2712c(%rbp)
L43:
  mov    -0x27134(%rbp),%eax
  add    %eax,%eax
  cmp    %eax,-0x2712c(%rbp)
  jl     L49
  mov    -0x27134(%rbp),%edx
  lea    -0x13890(%rbp),%rcx
  lea    -0x27120(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <Caculate_len@plt>
  mov    %eax,-0x2712c(%rbp)
  mov    -0x2712c(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,%ecx
  mov    -0x27138(%rbp),%edx
  mov    -0x27128(%rbp),%rax
  lea    D22(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    -0x27128(%rbp),%rdx
  mov    -0x2712c(%rbp),%ecx
  lea    -0x13890(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <PrintEncode@plt>
  mov    -0x27128(%rbp),%rax
  mov    %rax,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  addl   $0x1,-0x27130(%rbp)
L47:
  mov    -0x2713c(%rbp),%eax
  cmp    %eax,-0x27130(%rbp)
  jl     L8
  mov    -0x27128(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L7
  call   <__stack_chk_fail@plt>
L7:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_tag: D17
data_type: string
name: disassemble_data
arguments: data_tag: D55
data_type: string
name: disassemble_data
arguments: data_tag: D45
data_type: string
name: disassemble_data
arguments: data_tag: D49
data_type: string
name: disassemble_data
arguments: data_tag: D54
data_type: string
name: disassemble_data
arguments: data_tag: D22
data_type: string

tool: D17: w

tool: D55: a.out

tool: D45: %d

tool: D49: %d%d

tool: D54: %c

tool: D22: %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;
}
```