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

```asm
<dns_parse_rr_label>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  movzbl (%rax),%eax
  mov    %al,-0x17(%rbp)
  cmpb   $0x0,-0x17(%rbp)
  je     L69
  movzbl -0x17(%rbp),%eax
  shr    $0x6,%al
  movzbl %al,%eax
  and    $0x3,%eax
  cmp    $0x3,%eax
  jne    L66
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <read_uint16@plt>
  mov    %ax,-0x16(%rbp)
  andw   $0x3fff,-0x16(%rbp)
  movzwl -0x16(%rbp),%edx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  lea    0x2(%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0x17(%rbp)
  nop
L1:
  mov    -0x40(%rbp),%rcx
  mov    -0x38(%rbp),%rdx
  lea    -0x10(%rbp),%rsi
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <dns_parse_rr_label>
  movsbl %al,%eax
  mov    %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jg     L1
  cmpl   $0x0,-0x14(%rbp)
  jne    L38
  mov    $0x0,%eax
  jmp    L61
L38:
  lea    D27(%rip),%rax
  mov    %rax,%rsi
  lea    D47(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <log_debug@plt>
  mov    $0xffffffff,%eax
  jmp    L61
L66:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  lea    0x1(%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rdx
  movzbl -0x17(%rbp),%eax
  add    %rdx,%rax
  cmp    %rax,-0x38(%rbp)
  jb     L88
  movzbl -0x17(%rbp),%edx
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rcx
  mov    -0x40(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <buffer_insert@plt>
  mov    -0x40(%rbp),%rax
  mov    $0x1,%edx
  lea    D28(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <buffer_insert@plt>
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rdx
  movzbl -0x17(%rbp),%eax
  add    %rax,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  movzbl -0x17(%rbp),%eax
  jmp    L61
L88:
  lea    D7(%rip),%rax
  mov    %rax,%rsi
  lea    D47(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <log_debug@plt>
  mov    $0xffffffff,%eax
  jmp    L61
L69:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  lea    0x1(%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    $0x0,%eax
L61:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L16
  call   <__stack_chk_fail@plt>
L16:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D27
datatype: string
name: extract_symbolic_data
arguments: label: D47
datatype: string
name: extract_symbolic_data
arguments: label: D28
datatype: string
name: extract_symbolic_data
arguments: label: D7
datatype: string

tool: D27: Failed to read label pointer.

tool: D47: dns_parse_rr_label

tool: D28: .

tool: D7: End of label outside of buffer!

assistant: ```c
char dns_parse_rr_label(char *bgof_msg, char **cursor, char *cursor_max, struct buffer *output) {
  char *label_ptr;
  unsigned short label_offset;
  unsigned char chunk_len;
  int label_len;
  chunk_len = (unsigned char)**cursor;
  if (chunk_len != 0) {
    if (((chunk_len >> 6) & 0x03) == 3) {
      label_offset = read_uint16(*cursor);
      label_offset &= 0x3fff;
      label_ptr = bgof_msg + label_offset;
      (*cursor) += 2;
      chunk_len = *label_ptr;
      while ((label_len = dns_parse_rr_label(bgof_msg, &label_ptr, cursor_max, output)) > 0) {
      }
      if (label_len == 0) {
        return 0;
      } else {
        log_debug(__func__, "Failed to read label pointer.");
        return -1;
      }
    } else {
      (*cursor)++;
      if (*cursor + chunk_len <= cursor_max) {
        buffer_insert(output, *cursor, chunk_len);
        buffer_insert(output, ".", 1);
        (*cursor) += chunk_len;
        return chunk_len;
      } else {
        log_debug(__func__, "End of label outside of buffer!");
        return -1;
      }
    }
  } else {
    (*cursor)++;
    return 0;
  }
}
```