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

```asm
<dns_ptodn>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    -0x30(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  cmpl   $0xff,-0x34(%rbp)
  ja     L135
  mov    -0x34(%rbp),%eax
  lea    -0x1(%rax),%rdx
  jmp    L45
L135:
  mov    $0xfe,%edx
L45:
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  jmp    L56
L81:
  cmpl   $0x2e,-0x20(%rbp)
  jne    L76
  mov    -0x18(%rbp),%rax
  sub    -0x10(%rbp),%rax
  mov    %eax,-0x1c(%rbp)
  cmpl   $0x0,-0x1c(%rbp)
  je     L56
  cmpl   $0x3f,-0x1c(%rbp)
  jbe    L8
  mov    D33(%rip),%rax
  mov    (%rax),%edx
  mov    D3(%rip),%rax
  mov    %edx,(%rax)
  mov    $0x0,%eax
  jmp    L46
L8:
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  mov    -0x1c(%rbp),%edx
  mov    %dl,(%rax)
  addq   $0x1,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  jmp    L56
L76:
  cmpl   $0x5c,-0x20(%rbp)
  jne    L61
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x20(%rbp)
  cmpl   $0x0,-0x20(%rbp)
  je     L67
  cmpl   $0x2f,-0x20(%rbp)
  jbe    L61
  cmpl   $0x39,-0x20(%rbp)
  ja     L61
  subl   $0x30,-0x20(%rbp)
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jle    L61
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x39,%al
  jg     L61
  mov    -0x20(%rbp),%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  mov    %eax,%ecx
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  add    %ecx,%eax
  sub    $0x30,%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jle    L61
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x39,%al
  jg     L61
  mov    -0x20(%rbp),%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  mov    %eax,%ecx
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  add    %ecx,%eax
  sub    $0x30,%eax
  mov    %eax,-0x20(%rbp)
  cmpl   $0xff,-0x20(%rbp)
  jbe    L61
  mov    D8(%rip),%rax
  mov    (%rax),%edx
  mov    D3(%rip),%rax
  mov    %edx,(%rax)
  mov    $0x0,%eax
  jmp    L46
L61:
  mov    -0x18(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jb     L89
  mov    D33(%rip),%rax
  mov    (%rax),%edx
  mov    D3(%rip),%rax
  mov    %edx,(%rax)
  mov    $0x0,%eax
  jmp    L46
L89:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  mov    -0x20(%rbp),%edx
  mov    %dl,(%rax)
L56:
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x20(%rbp)
  cmpl   $0x0,-0x20(%rbp)
  jne    L81
  jmp    L149
L67:
  nop
L149:
  mov    -0x18(%rbp),%rax
  sub    -0x10(%rbp),%rax
  mov    %eax,-0x1c(%rbp)
  cmpl   $0x3f,-0x1c(%rbp)
  jbe    L133
  mov    D33(%rip),%rax
  mov    (%rax),%edx
  mov    D3(%rip),%rax
  mov    %edx,(%rax)
  mov    $0x0,%eax
  jmp    L46
L133:
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  mov    -0x1c(%rbp),%edx
  mov    %dl,(%rax)
  movzbl (%rax),%eax
  test   %al,%al
  je     L27
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x0,(%rax)
L27:
  mov    -0x18(%rbp),%rax
  sub    -0x30(%rbp),%rax
L46:
  pop    %rbp
  ret
```

assistant: ```c
unsigned dns_ptodn(const char *name, unsigned char *dn, unsigned dnsiz) {
  unsigned char *d;
  unsigned char *label;
  unsigned char *m;
  unsigned l;
  unsigned c;
  d = dn + 1;
  label = d;
  m = dn + (dnsiz > 255 ? 255 : dnsiz) - 1;
  while ((c = (unsigned char)*name++) != 0) {
    if (c == '.') {
      if ((l = d - label) != 0) {
        if (l > 63) {
          errno = EMSGSIZE;
          return 0;
        }
        label[-1] = (char)l;
        label = ++d;
      }
      continue;
    }
    if (c == '\\') {
      if (!(c = (unsigned char)*name++))
        break;
      if (c >= '0' && c <= '9') {
        c -= '0';
        if (*name >= '0' && *name <= '9') {
          c = (c * 10) + (*name++ - '0');
          if (*name >= '0' && *name <= '9') {
            c = (c * 10) + (*name++ - '0');
            if (c > 255) {
              errno = EINVAL;
              return 0;
            }
          }
        }
      }
    }
    if (d >= m) {
      errno = EMSGSIZE;
      return 0;
    }
    *d++ = (char)c;
  }
  if ((l = d - label) > 63) {
    errno = EMSGSIZE;
    return 0;
  }
  if ((label[-1] = (char)l) != 0)
    *d++ = 0;
  return d - dn;
}
```