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

```asm
<readtree>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  mov    $0xf4241,%edi
  push   %rbp
  push   %rbx
  mov    %esi,%ebx
  mov    $0x1,%esi
  sub    $0x8,%rsp
  call   <check_alloc@plt>
  imul   $0x12c,%ebx,%edi
  mov    $0x1,%esi
  mov    %rax,%rbp
  call   <check_alloc@plt>
  movb   $0xa,0x0(%rbp)
  mov    %rax,%r13
L325:
  mov    %r12,%rdx
  mov    $0xf4240,%esi
  mov    %rbp,%rdi
  call   <fgets@plt>
  movzbl 0x0(%rbp),%eax
  cmp    $0xa,%al
  je     L325
  cmp    $0x9,%al
  je     L414
  cmp    $0x20,%al
  jne    L6
L414:
  lea    0x1(%rbp),%rdx
  nopl   0x0(%rax,%rax,1)
L127:
  movzbl (%rdx),%eax
  mov    %rdx,%r15
  add    $0x1,%rdx
  cmp    $0x20,%al
  je     L127
  cmp    $0x9,%al
  je     L127
L290:
  cmp    $0x28,%al
  je     L272
  cmp    $0x5b,%al
  je     L265
  lea    D5(%rip),%rdi
  xor    %r13d,%r13d
  call   <printf@plt>
L267:
  add    $0x8,%rsp
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L33:
  mov    %r12,%rdx
  mov    $0xf4240,%esi
  mov    %rbp,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L417
L265:
  mov    $0x5d,%esi
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L33
  lea    0x1(%rax),%r15
  movzbl 0x1(%rax),%eax
  cmp    $0x9,%al
  je     L176
  cmp    $0x20,%al
  jne    L0
  nopl   0x0(%rax,%rax,1)
L176:
  movzbl 0x1(%r15),%eax
  add    $0x1,%r15
  cmp    $0x20,%al
  je     L176
  cmp    $0x9,%al
  je     L176
L0:
  cmp    $0xa,%al
  je     L227
  movzbl (%r15),%eax
L38:
  cmp    $0x28,%al
  je     L202
  lea    D35(%rip),%rdi
  xor    %r13d,%r13d
  call   <printf@plt>
  jmp    L267
  nopl   (%rax)
L272:
  cmp    $0x5b,%al
  je     L265
L202:
  lea    D29(%rip),%r14
  mov    %r15,%rdx
  mov    %r13,%rdi
  mov    %r14,%rsi
  call   <sprintf@plt>
  movzbl 0x0(%r13),%eax
  cmp    $0x3b,%al
  je     L330
  mov    %r13,%rbx
  cmp    $0xa,%al
  jne    L152
  jmp    L330
  nopw   0x0(%rax,%rax,1)
L284:
  movzbl 0x1(%rbx),%eax
  add    $0x1,%rbx
  cmp    $0xa,%al
  je     L245
  cmp    $0x3b,%al
  je     L267
L152:
  test   %al,%al
  jne    L284
  nopl   0x0(%rax)
L74:
  mov    %r12,%rdx
  mov    $0xf4240,%esi
  mov    %rbp,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L199
  mov    %r14,%rsi
  mov    %rbx,%rdi
  mov    %rbp,%rdx
  call   <sprintf@plt>
  mov    $0x3b,%esi
  mov    %rbp,%rdi
  call   <strchr@plt>
  cmp    %rax,%r15
  je     L311
  movzbl (%rbx),%eax
  test   %al,%al
  je     L74
  cmp    $0xa,%al
  je     L74
L258:
  movzbl 0x1(%rbx),%eax
  add    $0x1,%rbx
  cmp    $0xa,%al
  je     L74
  test   %al,%al
  jne    L258
  jmp    L74
L199:
  movb   $0x0,(%rbx)
  mov    %rbp,%rdi
  call   <free@plt>
  jmp    L267
L311:
  movb   $0x0,0x1(%r15)
  jmp    L267
L417:
  lea    D23(%rip),%rdi
  xor    %r13d,%r13d
  call   <printf@plt>
  jmp    L267
L6:
  mov    %rbp,%r15
  jmp    L290
L227:
  movb   $0xa,0x0(%rbp)
  nopl   0x0(%rax)
L119:
  mov    %r12,%rdx
  mov    $0xf4240,%esi
  mov    %rbp,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  movzbl 0x0(%rbp),%eax
  je     L296
  cmp    $0xa,%al
  je     L119
L296:
  mov    %rbp,%r15
  cmp    $0x20,%al
  jne    L175
  nopl   0x0(%rax)
L396:
  movzbl 0x1(%r15),%eax
  add    $0x1,%r15
  cmp    $0x20,%al
  je     L396
L175:
  cmp    $0x9,%al
  je     L396
  jmp    L38
L330:
  mov    %r13,%rbx
L245:
  cmp    $0x3b,%al
  jne    L74
  jmp    L267
```

tool_calls: name: extract_symbolic_data
arguments: tag: D5
type: string
name: extract_symbolic_data
arguments: tag: D35
type: string
name: extract_symbolic_data
arguments: tag: D29
type: string
name: extract_symbolic_data
arguments: tag: D23
type: string

tool: D5: Tree first character should be '[' or '('


tool: D35: Comments should be followed by '('


tool: D29: %s

tool: D23: Unterminated comment in tree ('[' missing)


assistant: ```c
char *readtree(FILE *treef, int nbsp) {
  char *line;
  char *ctree, *ctreefin, *prov;
  int i;
  line = (char *)check_alloc(1000000 + 1, sizeof(char));
  ctree = check_alloc(3 * 100 * nbsp, sizeof(char));
  ctreefin = ctree;
  line[0] = '\n';
  while (line[0] == '\n')
    fgets(line, 1000000, treef);
  i = 0;
  while (line[i] == ' ' || line[i] == '\t')
    i++;
  if (line[i] != '(' && line[i] != '[') {
    printf("Tree first character should be '[' or '('\n");
    return NULL;
  }
  if (line[i] == '[') {
    while ((prov = strchr(line, ']')) == NULL) {
      if (!fgets(line, 1000000, treef)) {
        printf("Unterminated comment in tree ('[' missing)\n");
        return NULL;
      }
    }
    prov++;
    while (*prov == ' ' || *prov == '\t')
      prov++;
    if (*prov == '\n') {
      line[0] = '\n';
      while (line[0] == '\n' && fgets(line, 1000000, treef))
        ;
      prov = line;
      while (*prov == ' ' || *prov == '\t')
        prov++;
    }
    if (*prov != '(') {
      printf("Comments should be followed by '('\n");
      return NULL;
    }
  } else {
    prov = line + i;
  }
  sprintf(ctree, "%s", prov);
  while (*ctreefin != '\n' && *ctreefin != ';' && *ctreefin)
    ctreefin++;
  if (*ctreefin == ';')
    return ctree;
  while (fgets(line, 1000000, treef)) {
    sprintf(ctreefin, "%s", line);
    if (prov == strchr(line, ';')) {
      *(prov + 1) = 0;
      return ctree;
    }
    while (*ctreefin != '\n' && *ctreefin)
      ctreefin++;
  }
  *ctreefin = 0;
  free(line);
  return ctree;
}
```