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     L135
  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     L197
  mov    $0x0,%edx
L184:
  add    $0x8,%rax
  add    $0x8,%rbx
  add    $0x1,%edx
  cmpq   $0x0,(%rax)
  jne    L184
L153:
  lea    0x8(,%rdx,8),%eax
  sub    %eax,%ebp
  js     L109
  lea    0x8(%rbx),%r12
  mov    %r12,0x10(%r15)
  mov    0x10(%r14),%r13
  mov    0x0(%r13),%rsi
  test   %rsi,%rsi
  je     L105
  mov    %r12,%rcx
  mov    %r13,%rdx
  mov    $0x0,%eax
L217:
  add    $0x8,%rdx
  mov    %rcx,%rbx
  add    $0x8,%rcx
  mov    %eax,%edi
  add    $0x1,%eax
  cmpq   $0x0,(%rdx)
  jne    L217
  lea    0x10(,%rdi,8),%eax
  sub    %eax,%ebp
  js     L220
  add    $0x10,%rbx
  mov    (%r14),%edx
  sub    %edx,%ebp
  js     L131
L41:
  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     L78
  sub    %edx,%ebp
  jns    L41
  mov    $0xffffffff,%eax
L17:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L197:
  mov    $0x0,%edx
  jmp    L153
L135:
  mov    $0xffffffff,%eax
  jmp    L17
L109:
  mov    $0xffffffff,%eax
  jmp    L17
L134:
  mov    $0xffffffff,%eax
  jmp    L17
L111:
  mov    $0xffffffff,%eax
  jmp    L17
L131:
  mov    $0xffffffff,%eax
  jmp    L17
L220:
  mov    $0xffffffff,%eax
  jmp    L17
L105:
  mov    $0xffffffff,%eax
  sub    $0x8,%ebp
  js     L17
  add    $0x10,%rbx
L78:
  movq   $0x0,(%r12)
  mov    0x8(%r14),%r12
  mov    0x8(%r15),%r13
  mov    (%r12),%rsi
  test   %rsi,%rsi
  je     L162
L164:
  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     L134
  add    $0x8,%r12
  add    $0x8,%r13
  mov    (%r12),%rsi
  test   %rsi,%rsi
  jne    L164
L162:
  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     L111
  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    L17
```

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);
}
```