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

```asm
<a_link>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    -0x28(%rbp),%rax
  mov    $0x5b,%esi
  mov    %rax,%rdi
  call   <match@plt>
  test   %eax,%eax
  jne    L80
  mov    $0x0,%eax
  jmp    L117
L80:
  movl   $0xa,-0x18(%rbp)
  movl   $0x0,-0x1c(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  jmp    L62
L0:
  mov    -0x1c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x18(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,%edx
  jl     L109
  shll   -0x18(%rbp)
  mov    -0x18(%rbp),%edx
  mov    -0x10(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x10(%rbp)
L109:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    -0x14(%rbp),%edx
  mov    %dl,(%rax)
  addl   $0x1,-0x1c(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <consume@plt>
L62:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <next@plt>
  mov    %eax,-0x14(%rbp)
  cmpl   $0x5d,-0x14(%rbp)
  je     L87
  cmpl   $0xffffffff,-0x14(%rbp)
  jne    L0
L87:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x28(%rbp),%rax
  mov    $0x5d,%esi
  mov    %rax,%rdi
  call   <match@plt>
  test   %eax,%eax
  jne    L154
  mov    $0x0,%eax
  jmp    L117
L154:
  mov    -0x28(%rbp),%rax
  mov    $0x28,%esi
  mov    %rax,%rdi
  call   <match@plt>
  test   %eax,%eax
  jne    L131
  mov    $0x0,%eax
  jmp    L117
L131:
  movl   $0xa,-0x18(%rbp)
  movl   $0x0,-0x1c(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  jmp    L137
L120:
  mov    -0x1c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x18(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,%edx
  jl     L45
  shll   -0x18(%rbp)
  mov    -0x18(%rbp),%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x8(%rbp)
L45:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x14(%rbp),%edx
  mov    %dl,(%rax)
  addl   $0x1,-0x1c(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <consume@plt>
L137:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <next@plt>
  mov    %eax,-0x14(%rbp)
  cmpl   $0x29,-0x14(%rbp)
  je     L50
  cmpl   $0xffffffff,-0x14(%rbp)
  jne    L120
L50:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x28(%rbp),%rax
  mov    $0x29,%esi
  mov    %rax,%rdi
  call   <match@plt>
  test   %eax,%eax
  jne    L140
  mov    $0x0,%eax
  jmp    L117
L140:
  mov    -0x10(%rbp),%rcx
  mov    -0x8(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  lea    D7(%rip),%rsi
  mov    %rax,%rdi
  call   <parser_emit_string@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x1,%eax
L117:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D7
type: string

tool: D7: <a href="%s">%s</a>

assistant: ```c
bool a_link(struct cymkd_parser *parser) {
  int ch;
  int len;
  int bufsize;
  char *link_text;
  char *link_href;
  if (!match(parser, '[')) {
    return false;
  }
  bufsize = 10;
  len = 0;
  link_text = malloc(bufsize);
  while ((ch = next(parser)) != ']' && ch != -1) {
    if (len + 1 >= bufsize - 1) {
      bufsize *= 2;
      link_text = realloc(link_text, bufsize);
    }
    link_text[len] = ch;
    len++;
    consume(parser);
  }
  link_text[len] = '\0';
  if (!match(parser, ']')) {
    return false;
  }
  if (!match(parser, '(')) {
    return false;
  }
  bufsize = 10;
  len = 0;
  link_href = malloc(bufsize);
  while ((ch = next(parser)) != ')' && ch != -1) {
    if (len + 1 >= bufsize - 1) {
      bufsize *= 2;
      link_href = realloc(link_href, bufsize);
    }
    link_href[len] = ch;
    len++;
    consume(parser);
  }
  link_href[len] = '\0';
  if (!match(parser, ')')) {
    return false;
  }
  parser_emit_string(parser, "<a href=\"%s\">%s</a>", link_href, link_text);
  free(link_href);
  free(link_text);
  return true;
}
```