user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<read_dns_name>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %ecx,-0x3c(%rbp)
  movl   $0x0,-0x20(%rbp)
  movl   $0x0,-0x1c(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x8(%rbp)
L520:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  and    $0xc0,%eax
  cmp    $0xc0,%eax
  jne    L404
  mov    -0x30(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <ntohs@plt>
  sub    $0xc000,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x30(%rbp)
  mov    -0xc(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0x30(%rbp)
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  cmp    %rax,-0x30(%rbp)
  ja     L428
  mov    -0x30(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  jae    L80
L428:
  mov    $0x0,%eax
  jmp    L246
L80:
  addl   $0x2,-0x20(%rbp)
  cmpl   $0x100,-0x20(%rbp)
  jg     L215
  cmpl   $0x0,-0x20(%rbp)
  jns    L408
L215:
  mov    $0x0,%eax
  jmp    L246
L408:
  mov    -0x8(%rbp),%rax
  add    $0x100,%rax
  cmp    %rax,-0x38(%rbp)
  ja     L132
  mov    -0x38(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jae    L55
L132:
  mov    $0x0,%eax
  jmp    L246
L55:
  movl   $0x1,-0x1c(%rbp)
  jmp    L39
L404:
  mov    -0x14(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  cmpl   $0x0,-0x10(%rbp)
  jne    L20
  cmpl   $0x0,-0x20(%rbp)
  jle    L69
  mov    -0x38(%rbp),%rax
  sub    $0x1,%rax
  movb   $0x0,(%rax)
  cmpl   $0x0,-0x1c(%rbp)
  jne    L511
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  cmp    %rax,-0x30(%rbp)
  ja     L196
  mov    -0x30(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  jae    L52
L196:
  mov    $0x0,%eax
  jmp    L246
L52:
  addl   $0x1,-0x20(%rbp)
  cmpl   $0x100,-0x20(%rbp)
  jg     L400
  cmpl   $0x0,-0x20(%rbp)
  jns    L78
L400:
  mov    $0x0,%eax
  jmp    L246
L78:
  mov    -0x8(%rbp),%rax
  add    $0x100,%rax
  cmp    %rax,-0x38(%rbp)
  ja     L379
  mov    -0x38(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jae    L511
L379:
  mov    $0x0,%eax
  jmp    L246
L69:
  mov    -0x38(%rbp),%rax
  movb   $0x0,(%rax)
  jmp    L511
L20:
  addq   $0x4,-0x30(%rbp)
  cmpl   $0x0,-0x1c(%rbp)
  jne    L310
  addl   $0x1,-0x20(%rbp)
L310:
  movl   $0x0,-0x18(%rbp)
  jmp    L298
L284:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%rax
  mov    %dl,(%rax)
  cmpl   $0x0,-0x1c(%rbp)
  jne    L437
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  cmp    %rax,-0x30(%rbp)
  ja     L280
  mov    -0x30(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  jae    L440
L280:
  mov    $0x0,%eax
  jmp    L246
L440:
  addl   $0x1,-0x20(%rbp)
  cmpl   $0x100,-0x20(%rbp)
  jg     L344
  cmpl   $0x0,-0x20(%rbp)
  jns    L537
L344:
  mov    $0x0,%eax
  jmp    L246
L537:
  mov    -0x8(%rbp),%rax
  add    $0x100,%rax
  cmp    %rax,-0x38(%rbp)
  ja     L491
  mov    -0x38(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jae    L437
L491:
  mov    $0x0,%eax
  jmp    L246
L437:
  addq   $0x4,-0x30(%rbp)
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  cmp    %rax,-0x30(%rbp)
  ja     L521
  mov    -0x30(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  jae    L125
L521:
  mov    $0x0,%eax
  jmp    L246
L125:
  cmpl   $0x100,-0x20(%rbp)
  jg     L4
  cmpl   $0x0,-0x20(%rbp)
  jns    L34
L4:
  mov    $0x0,%eax
  jmp    L246
L34:
  addq   $0x1,-0x38(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x100,%rax
  cmp    %rax,-0x38(%rbp)
  ja     L137
  mov    -0x38(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jae    L329
L137:
  mov    $0x0,%eax
  jmp    L246
L329:
  addl   $0x1,-0x18(%rbp)
L298:
  mov    -0x18(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L284
  mov    -0x38(%rbp),%rax
  movb   $0x2e,(%rax)
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  cmp    %rax,-0x30(%rbp)
  ja     L448
  mov    -0x30(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  jae    L271
L448:
  mov    $0x0,%eax
  jmp    L246
L271:
  cmpl   $0x100,-0x20(%rbp)
  jg     L59
  cmpl   $0x0,-0x20(%rbp)
  jns    L442
L59:
  mov    $0x0,%eax
  jmp    L246
L442:
  addq   $0x1,-0x38(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x100,%rax
  cmp    %rax,-0x38(%rbp)
  ja     L87
  mov    -0x38(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jae    L520
L87:
  mov    $0x0,%eax
  jmp    L246
L39:
  jmp    L520
L511:
  nop
  mov    -0x20(%rbp),%eax
L246:
  leave
  ret
```

assistant: ```c
int read_dns_name(u_char *base, u_char *ptr, char *name, int psize) {
  u_char c;
  int len;
  int count = 0, compressed = 0;
  char *base_name = name;
  for (;;) {
    int i;
    c = *ptr;
    if ((c & 0xc0) == 0xc0) {
      int offset;
      offset = (ntohs(*(u_short *)(ptr)) - 0xc000);
      ptr = base;
      do {
        ptr += offset;
        if ((ptr > (base + psize)) || (ptr < base))
          return 0;
        count += 2;
        if ((count > 256) || (count < 0))
          return 0;
        name += 0;
        if ((name > (base_name + 256)) || (name < base_name))
          return 0;
      } while (0);
      compressed = 1;
      continue;
    }
    len = c;
    if (len == 0) {
      if (count > 0) {
        *(name - 1) = '\0';
        if (!compressed)
          do {
            ptr += 0;
            if ((ptr > (base + psize)) || (ptr < base))
              return 0;
            count += 1;
            if ((count > 256) || (count < 0))
              return 0;
            name += 0;
            if ((name > (base_name + 256)) || (name < base_name))
              return 0;
          } while (0);
      } else {
        *name = '\0';
      }
      break;
    }
    ptr++;
    if (!compressed)
      count++;
    for (i = 0; i < len; i++) {
      *name = *ptr;
      if (!compressed)
        do {
          ptr += 0;
          if ((ptr > (base + psize)) || (ptr < base))
            return 0;
          count += 1;
          if ((count > 256) || (count < 0))
            return 0;
          name += 0;
          if ((name > (base_name + 256)) || (name < base_name))
            return 0;
        } while (0);
      do {
        ptr += 1;
        if ((ptr > (base + psize)) || (ptr < base))
          return 0;
        count += 0;
        if ((count > 256) || (count < 0))
          return 0;
        name += 1;
        if ((name > (base_name + 256)) || (name < base_name))
          return 0;
      } while (0);
    }
    *name = '.';
    do {
      ptr += 0;
      if ((ptr > (base + psize)) || (ptr < base))
        return 0;
      count += 0;
      if ((count > 256) || (count < 0))
        return 0;
      name += 1;
      if ((name > (base_name + 256)) || (name < base_name))
        return 0;
    } while (0);
  }
  return count;
}
```