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

```asm
<_nss_dnspq_gethostbyname3_r>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %r9,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  mov    D23(%rip),%rax
  movq   $0x0,0x30(%rsp)
  mov    0x80(%rsp),%r15
  mov    0x88(%rsp),%r10
  mov    0x90(%rsp),%r9
  cmp    %esi,(%rax)
  je     L47
L67:
  mov    D31(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,0x0(%rbp)
  mov    D40(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,(%r15)
  mov    D34(%rip),%rax
  mov    (%rax),%eax
L31:
  mov    0x38(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L10
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L47:
  mov    %r9,0x18(%rsp)
  mov    %rdi,%r12
  mov    %esi,%ebx
  mov    %rdx,%r14
  mov    %r10,0x10(%rsp)
  mov    %rcx,%r13
  mov    %r8,0x8(%rsp)
  call   <strlen@plt>
  mov    %rax,%r11
  test   %rax,%rax
  je     L67
  mov    0x8(%rsp),%r8
  lea    0x1d(%rax),%rax
  mov    0x10(%rsp),%r10
  mov    0x18(%rsp),%r9
  cmp    %r8,%rax
  ja     L67
  lea    0x30(%rsp),%rdi
  mov    %r12,%rsi
  mov    %r11,0x18(%rsp)
  mov    %r9,0x10(%rsp)
  mov    %r10,0x8(%rsp)
  call   <get_dnss_for_domain@plt>
  test   %rax,%rax
  je     L67
  mov    0x30(%rsp),%rdi
  lea    0x2c(%rsp),%rcx
  mov    %r13,%rdx
  mov    %r12,%rsi
  lea    0x2b(%rsp),%r8
  call   <dnsq@plt>
  mov    0x18(%rsp),%r11
  test   %rax,%rax
  jne    L67
  lea    0x20(%r13),%rax
  lea    0x38(%r13),%rdi
  mov    %ebx,(%r14)
  mov    %r12,%rsi
  mov    %rax,0x8(%r14)
  lea    0x30(%r13),%rax
  lea    0x1(%r11),%rdx
  movl   $0x4,0x4(%r14)
  mov    %r13,0x20(%r13)
  movq   $0x0,0x28(%r13)
  mov    %rax,0x10(%r14)
  movq   $0x0,0x30(%r13)
  mov    %rdi,0x18(%r14)
  call   <memcpy@plt>
  mov    0x8(%rsp),%r10
  mov    0x10(%rsp),%r9
  test   %r10,%r10
  je     L48
  mov    0x2c(%rsp),%eax
  mov    %rax,(%r10)
L48:
  test   %r9,%r9
  je     L24
  mov    0x18(%r14),%rax
  mov    %rax,(%r9)
L24:
  mov    D49(%rip),%rax
  movl   $0x0,0x0(%rbp)
  movl   $0x0,(%r15)
  mov    (%rax),%eax
  jmp    L31
L10:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
enum nss_status _nss_dnspq_gethostbyname3_r(const char *name, int af, struct hostent *host, char *buf, size_t buflen, int *errnop, int *h_errnop, int32_t *ttlp, char **canonp) {
  unsigned int ttl;
  char sid;
  struct sockaddr_in **dnsservers = NULL;
  size_t nlen = 0;
  if (af == AF_INET && (nlen = strlen(name)) > 0 && buflen >= nlen + 1 + 2 * sizeof(void *) + sizeof(struct in_addr) + sizeof(void *) && get_dnss_for_domain(&dnsservers, name) && dnsq(dnsservers, name, (struct in_addr *)buf, &ttl, &sid) == 0) {
    host->h_addrtype = af;
    host->h_length = sizeof(struct in_addr);
    host->h_addr_list = (char **)buf + sizeof(struct in_addr);
    host->h_addr_list[0] = buf;
    host->h_addr_list[1] = NULL;
    host->h_aliases = (char **)&host->h_addr_list[2];
    host->h_aliases[0] = NULL;
    host->h_name = (char *)&host->h_aliases[1];
    memcpy(host->h_name, name, nlen + 1);
    if (ttlp != NULL)
      *ttlp = (int32_t)ttl;
    if (canonp != NULL)
      *canonp = host->h_name;
    *errnop = 0;
    *h_errnop = 0;
    return NSS_STATUS_SUCCESS;
  }
  *errnop = EINVAL;
  *h_errnop = NO_RECOVERY;
  return NSS_STATUS_UNAVAIL;
}
```