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

```asm
<ancil_recv_fds_with_buffer>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x88,%rsp
  mov    %edi,-0x74(%rbp)
  mov    %rsi,-0x80(%rbp)
  mov    %edx,-0x78(%rbp)
  mov    %rcx,-0x88(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  lea    -0x6d(%rbp),%rax
  mov    %rax,-0x60(%rbp)
  movl   $0x1,-0x58(%rbp)
  movq   $0x0,-0x28(%rbp)
  movq   $0x0,-0x30(%rbp)
  lea    -0x60(%rbp),%rax
  mov    %rax,-0x38(%rbp)
  movl   $0x1,-0x50(%rbp)
  movq   $0x0,-0x40(%rbp)
  mov    -0x88(%rbp),%rax
  mov    %rax,-0x48(%rbp)
  mov    -0x78(%rbp),%eax
  add    $0x3,%rax
  shl    $0x2,%eax
  mov    %eax,-0x4c(%rbp)
  lea    -0x50(%rbp),%rax
  mov    %rax,%rdi
  call   <CMSG_FIRSTHDR@plt>
  mov    %rax,-0x68(%rbp)
  mov    -0x4c(%rbp),%edx
  mov    -0x68(%rbp),%rax
  mov    %edx,(%rax)
  mov    D0(%rip),%rax
  mov    (%rax),%edx
  mov    -0x68(%rbp),%rax
  mov    %edx,0x8(%rax)
  mov    D5(%rip),%rax
  mov    (%rax),%edx
  mov    -0x68(%rbp),%rax
  mov    %edx,0x4(%rax)
  movl   $0x0,-0x6c(%rbp)
  jmp    L15
L64:
  mov    -0x6c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rbx
  mov    -0x68(%rbp),%rax
  mov    %rax,%rdi
  call   <CMSG_DATA@plt>
  add    %rbx,%rax
  movl   $0xffffffff,(%rax)
  addl   $0x1,-0x6c(%rbp)
L15:
  mov    -0x6c(%rbp),%eax
  cmp    %eax,-0x78(%rbp)
  ja     L64
  lea    -0x50(%rbp),%rcx
  mov    -0x74(%rbp),%eax
  mov    $0x0,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <recvmsg@plt>
  test   %rax,%rax
  jns    L46
  mov    $0xffffffff,%eax
  jmp    L1
L46:
  movl   $0x0,-0x6c(%rbp)
  jmp    L23
L35:
  mov    -0x6c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rbx
  mov    -0x68(%rbp),%rax
  mov    %rax,%rdi
  call   <CMSG_DATA@plt>
  add    %rbx,%rax
  mov    %rax,%rcx
  mov    -0x6c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x80(%rbp),%rax
  add    %rax,%rdx
  mov    (%rcx),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x6c(%rbp)
L23:
  mov    -0x6c(%rbp),%eax
  cmp    %eax,-0x78(%rbp)
  ja     L35
  mov    -0x68(%rbp),%rax
  mov    (%rax),%eax
  cltq
  sub    $0xc,%rax
  shr    $0x2,%rax
  mov    %eax,-0x78(%rbp)
  mov    -0x78(%rbp),%eax
L1:
  mov    -0x18(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L19
  call   <__stack_chk_fail@plt>
L19:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
int ancil_recv_fds_with_buffer(int sock, int *fds, unsigned n_fds, void *buffer) {
  struct msghdr msghdr;
  char nothing;
  struct iovec nothing_ptr;
  struct cmsghdr *cmsg;
  int i;
  nothing_ptr.iov_base = &nothing;
  nothing_ptr.iov_len = 1;
  msghdr.msg_name = NULL;
  msghdr.msg_namelen = 0;
  msghdr.msg_iov = &nothing_ptr;
  msghdr.msg_iovlen = 1;
  msghdr.msg_flags = 0;
  msghdr.msg_control = buffer;
  msghdr.msg_controllen = sizeof(struct cmsghdr) + sizeof(int) * n_fds;
  cmsg = CMSG_FIRSTHDR(&msghdr);
  cmsg->cmsg_len = msghdr.msg_controllen;
  cmsg->cmsg_level = SOL_SOCKET;
  cmsg->cmsg_type = SCM_RIGHTS;
  for (i = 0; i < n_fds; i++)
    ((int *)CMSG_DATA(cmsg))[i] = -1;
  if (recvmsg(sock, &msghdr, 0) < 0)
    return (-1);
  for (i = 0; i < n_fds; i++)
    fds[i] = ((int *)CMSG_DATA(cmsg))[i];
  n_fds = (cmsg->cmsg_len - sizeof(struct cmsghdr)) / sizeof(int);
  return (n_fds);
}
```