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

```asm
<dns_extract_name>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %r8,0x10(%rsp)
  mov    %r9d,0xc(%rsp)
  movb   $0x0,(%r8)
  cmp    %edx,%ecx
  jae    L178
  mov    %rsi,%r13
  mov    %edx,%r12d
  mov    %ecx,%ebx
  mov    $0x0,%ebp
  mov    $0x0,%r15d
  jmp    L6
L95:
  mov    %r15d,%edx
  lea    D90(%rip),%rsi
  mov    0x18(%rsp),%rdi
  mov    $0x0,%eax
  call   <FRAMERR@plt>
  jmp    L93
L169:
  lea    D73(%rip),%rsi
  mov    0x18(%rsp),%rdi
  mov    $0x0,%eax
  call   <FRAMERR@plt>
  lea    D97(%rip),%rdx
  mov    0xc(%rsp),%esi
  mov    0x10(%rsp),%rdi
  call   <strcpy_s@plt>
  mov    $0x5,%ebp
L93:
  mov    %ebp,%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L26:
  lea    0x1(%rbx),%esi
  movzbl %dl,%edx
  cmp    %esi,%r12d
  jbe    L127
  lea    (%rsi,%rdx,1),%ebx
  cmp    %r12d,%ebx
  ja     L30
  test   %ebp,%ebp
  je     L159
  lea    0x1(%rbp),%eax
  cmp    0xc(%rsp),%eax
  jae    L52
  mov    %ebp,%ebp
  mov    0x10(%rsp),%rcx
  movb   $0x2e,(%rcx,%rbp,1)
  mov    %eax,%ebp
L159:
  lea    0x0(%rbp,%rdx,1),%r14d
  lea    0x1(%r14),%eax
  cmp    0xc(%rsp),%eax
  jae    L104
  mov    %esi,%esi
  add    %r13,%rsi
  mov    %ebp,%edi
  mov    0x10(%rsp),%rbp
  add    %rbp,%rdi
  call   <memcpy@plt>
  mov    %r14d,%eax
  movb   $0x0,0x0(%rbp,%rax,1)
  mov    %r14d,%ebp
L8:
  cmp    %r12d,%ebx
  jae    L93
L6:
  mov    %ebx,%eax
  movzbl 0x0(%r13,%rax,1),%edx
  test   %dl,%dl
  je     L93
  test   $0xc0,%dl
  je     L26
  cmp    $0x64,%r15d
  jg     L95
  add    $0x1,%r15d
  add    $0x2,%ebx
  cmp    %r12d,%ebx
  ja     L169
  movzbl 0x1(%r13,%rax,1),%ebx
  movzbl %dl,%edx
  shl    $0x8,%edx
  or     %edx,%ebx
  and    $0x3fff,%ebx
  jmp    L8
L127:
  lea    D73(%rip),%rsi
  mov    0x18(%rsp),%rdi
  mov    $0x0,%eax
  call   <FRAMERR@plt>
  lea    D97(%rip),%rdx
  mov    0xc(%rsp),%esi
  mov    0x10(%rsp),%rdi
  call   <strcpy_s@plt>
  mov    $0x5,%ebp
  jmp    L93
L30:
  lea    D73(%rip),%rsi
  mov    0x18(%rsp),%rdi
  mov    $0x0,%eax
  call   <FRAMERR@plt>
  lea    D97(%rip),%rdx
  mov    0xc(%rsp),%esi
  mov    0x10(%rsp),%rdi
  call   <strcpy_s@plt>
  mov    $0x5,%ebp
  jmp    L93
L52:
  lea    D91(%rip),%rsi
  mov    0x18(%rsp),%rdi
  mov    $0x0,%eax
  call   <FRAMERR@plt>
  lea    D97(%rip),%rdx
  mov    0xc(%rsp),%esi
  mov    0x10(%rsp),%rdi
  call   <strcpy_s@plt>
  mov    $0x5,%ebp
  jmp    L93
L104:
  lea    D91(%rip),%rsi
  mov    0x18(%rsp),%rdi
  mov    $0x0,%eax
  call   <FRAMERR@plt>
  lea    D97(%rip),%rdx
  mov    0xc(%rsp),%esi
  mov    0x10(%rsp),%rdi
  call   <strcpy_s@plt>
  mov    $0x5,%ebp
  jmp    L93
L178:
  mov    $0x0,%ebp
  jmp    L93
```

tool_calls: name: extract_symbolic_data
arguments: tag: D90
type_guessed: string
name: extract_symbolic_data
arguments: tag: D73
type_guessed: string
name: extract_symbolic_data
arguments: tag: D97
type_guessed: string
name: extract_symbolic_data
arguments: tag: D91
type_guessed: string

tool: D90: dns: name: recursion exceeded %d


tool: D73: dns: name: not enough bytes


tool: D97: (err)

tool: D91: dns: name: too long


assistant: ```c
unsigned dns_extract_name(struct NetFrame *frame, const unsigned char *px, unsigned length, unsigned offset, char *name, unsigned sizeof_name) {
  int recurse_count = 0;
  unsigned name_offset = 0;
  name[0] = '\0';
  while (offset < length) {
    unsigned len;
    if (px[offset] == 0x00)
      break;
    if (px[offset] & 0xC0) {
      if (recurse_count > 100) {
        FRAMERR(frame, "dns: name: recursion exceeded %d\n", recurse_count);
        break;
      }
      recurse_count++;
      if (offset + 2 > length) {
        FRAMERR(frame, "dns: name: not enough bytes\n");
        strcpy_s(name, sizeof_name, "(err)");
        return 5;
      }
      offset = (*((unsigned char *)(px + offset) + 0) << 8 | *((unsigned char *)(px + offset) + 1) << 0) & 0x3FFF;
      continue;
    }
    len = px[offset++];
    if (offset >= length) {
      FRAMERR(frame, "dns: name: not enough bytes\n");
      strcpy_s(name, sizeof_name, "(err)");
      return 5;
    }
    if (offset + len > length) {
      FRAMERR(frame, "dns: name: not enough bytes\n");
      strcpy_s(name, sizeof_name, "(err)");
      return 5;
    }
    if (name_offset > 0) {
      if (name_offset + 1 >= sizeof_name) {
        FRAMERR(frame, "dns: name: too long\n");
        strcpy_s(name, sizeof_name, "(err)");
        return 5;
      }
      name[name_offset++] = '.';
    }
    if (name_offset + len + 1 >= sizeof_name) {
      FRAMERR(frame, "dns: name: too long\n");
      strcpy_s(name, sizeof_name, "(err)");
      return 5;
    }
    memcpy(name + name_offset, px + offset, len);
    name_offset += len;
    name[name_offset] = '\0';
    offset += len;
  }
  return name_offset;
}
```