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

```asm
<copy_hostent>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r14
  mov    %rsi,%r15
  mov    %edx,%ebp
  test   %rdi,%rdi
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  test   %r15,%r15
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  sub    $0x28,%ebp
  js     L127
  mov    0x20(%r14),%eax
  mov    %eax,0x20(%r15)
  mov    (%r14),%eax
  mov    %eax,(%r15)
  lea    0x28(%r15),%rbx
  mov    %rbx,0x8(%r15)
  mov    0x8(%r14),%rax
  cmpq   $0x0,(%rax)
  je     L177
  mov    $0x0,%edx
L221:
  add    $0x8,%rax
  add    $0x8,%rbx
  add    $0x1,%edx
  cmpq   $0x0,(%rax)
  jne    L221
L150:
  lea    0x8(,%rdx,8),%eax
  sub    %eax,%ebp
  js     L47
  lea    0x8(%rbx),%r12
  mov    %r12,0x10(%r15)
  mov    0x10(%r14),%r13
  mov    0x0(%r13),%rsi
  test   %rsi,%rsi
  je     L204
  mov    %r12,%rcx
  mov    %r13,%rdx
  mov    $0x0,%eax
L69:
  add    $0x8,%rdx
  mov    %rcx,%rbx
  add    $0x8,%rcx
  mov    %eax,%edi
  add    $0x1,%eax
  cmpq   $0x0,(%rdx)
  jne    L69
  lea    0x10(,%rdi,8),%eax
  sub    %eax,%ebp
  js     L5
  add    $0x10,%rbx
  mov    (%r14),%edx
  sub    %edx,%ebp
  js     L65
L135:
  mov    %rbx,%rdi
  call   <memcpy@plt>
  mov    %rbx,(%r12)
  mov    (%r14),%edx
  movslq %edx,%rax
  add    %rax,%rbx
  add    $0x8,%r13
  add    $0x8,%r12
  mov    0x0(%r13),%rsi
  test   %rsi,%rsi
  je     L141
  sub    %edx,%ebp
  jns    L135
  mov    $0xffffffff,%eax
L110:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L177:
  mov    $0x0,%edx
  jmp    L150
L127:
  mov    $0xffffffff,%eax
  jmp    L110
L47:
  mov    $0xffffffff,%eax
  jmp    L110
L37:
  mov    $0xffffffff,%eax
  jmp    L110
L151:
  mov    $0xffffffff,%eax
  jmp    L110
L65:
  mov    $0xffffffff,%eax
  jmp    L110
L5:
  mov    $0xffffffff,%eax
  jmp    L110
L204:
  mov    $0xffffffff,%eax
  sub    $0x8,%ebp
  js     L110
  add    $0x10,%rbx
L141:
  movq   $0x0,(%r12)
  mov    0x8(%r14),%r12
  mov    0x8(%r15),%r13
  mov    (%r12),%rsi
  test   %rsi,%rsi
  je     L215
L108:
  mov    %ebp,%edx
  mov    %rbx,%rdi
  call   <strlcpy@plt>
  mov    %rbx,0x0(%r13)
  add    $0x1,%eax
  movslq %eax,%rdx
  add    %rdx,%rbx
  sub    %eax,%ebp
  js     L37
  add    $0x8,%r12
  add    $0x8,%r13
  mov    (%r12),%rsi
  test   %rsi,%rsi
  jne    L108
L215:
  movq   $0x0,0x0(%r13)
  mov    %rbx,0x18(%r15)
  mov    0x18(%r14),%rsi
  mov    %ebp,%edx
  mov    %rbx,%rdi
  call   <strlcpy@plt>
  add    $0x1,%eax
  cmp    %eax,%ebp
  jl     L151
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <validate_hostent_copy@plt>
  not    %rax
  mov    %rax,%rdi
  shr    $0x3f,%rdi
  call   <assert@plt>
  mov    $0x0,%eax
  jmp    L110
```

assistant: ```c
int copy_hostent(const struct hostent *src, char *buf, int len) {
  struct hostent *dst;
  int n;
  char **p, **q;
  assert(src != NULL);
  assert(buf != NULL);
  dst = (struct hostent *)buf;
  if ((len -= sizeof(struct hostent)) < 0)
    return (-1);
  dst->h_addrtype = src->h_addrtype;
  dst->h_length = src->h_length;
  buf += sizeof(struct hostent);
  dst->h_aliases = (char **)buf;
  for (p = src->h_aliases, q = dst->h_aliases, n = 0; *p; p++, q++, n++) {
    ;
  }
  if ((len -= ++n * sizeof(char *)) < 0)
    return (-1);
  buf = (char *)(q + 1);
  dst->h_addr_list = (char **)buf;
  for (p = src->h_addr_list, q = dst->h_addr_list, n = 0; *p; p++, q++, n++) {
    ;
  }
  if ((len -= ++n * sizeof(char *)) < 0)
    return (-1);
  buf = (char *)(q + 1);
  for (p = src->h_addr_list, q = dst->h_addr_list; *p; p++, q++) {
    if ((len -= src->h_length) < 0)
      return (-1);
    memcpy(buf, *p, src->h_length);
    *q = buf;
    buf += src->h_length;
  }
  *q = NULL;
  for (p = src->h_aliases, q = dst->h_aliases; *p; p++, q++) {
    n = strlcpy(buf, *p, len);
    *q = buf;
    buf += ++n;
    if ((len -= n) < 0)
      return (-1);
  }
  *q = NULL;
  dst->h_name = buf;
  n = strlcpy(buf, src->h_name, len);
  buf += ++n;
  if ((len -= n) < 0)
    return (-1);
  assert(validate_hostent_copy(src, dst) >= 0);
  return (0);
}
```