user: Converte this assembly snippet into its equivalent C code:

```asm
<un_recv_fds>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x888,%rsp
  mov    %edi,-0x874(%rbp)
  mov    %rsi,-0x880(%rbp)
  mov    %edx,-0x878(%rbp)
  mov    %rcx,-0x888(%rbp)
  mov    %r8d,-0x88c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x868(%rbp)
  mov    -0x88c(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <CMSG_SPACE@plt>
  mov    %rax,-0x860(%rbp)
  cmpq   $0x800,-0x860(%rbp)
  setbe  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  lea    -0x850(%rbp),%rax
  mov    $0x20,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  lea    -0x820(%rbp),%rax
  mov    %rax,-0x850(%rbp)
  mov    -0x860(%rbp),%rax
  mov    %rax,-0x848(%rbp)
  lea    -0x830(%rbp),%rax
  mov    %rax,-0x838(%rbp)
  movl   $0x1,-0x840(%rbp)
  mov    -0x880(%rbp),%rax
  mov    %rax,-0x830(%rbp)
  mov    -0x878(%rbp),%eax
  mov    %eax,-0x828(%rbp)
L33:
  lea    -0x850(%rbp),%rcx
  mov    -0x874(%rbp),%eax
  mov    $0x0,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <recvmsg@plt>
  mov    %eax,-0x86c(%rbp)
  cmpl   $0xffffffff,-0x86c(%rbp)
  jne    L51
  mov    D1(%rip),%rax
  mov    (%rax),%rdx
  mov    D52(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  je     L33
  mov    D1(%rip),%rax
  mov    (%rax),%rdx
  mov    D6(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  je     L33
L51:
  cmpl   $0x0,-0x86c(%rbp)
  jle    L76
  cmpq   $0x0,-0x888(%rbp)
  je     L75
  lea    -0x850(%rbp),%rax
  mov    %rax,%rdi
  call   <CMSG_FIRSTHDR@plt>
  mov    %rax,-0x868(%rbp)
  cmpq   $0x0,-0x868(%rbp)
  setne  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x868(%rbp),%rax
  mov    (%rax),%rdx
  mov    D25(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x868(%rbp),%rax
  mov    0x8(%rax),%rdx
  mov    D14(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x868(%rbp),%rax
  mov    0x10(%rax),%rbx
  mov    -0x88c(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <CMSG_LEN@plt>
  cmp    %rax,%rbx
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x868(%rbp),%rax
  mov    %rax,%rdi
  call   <CMSG_DATA@plt>
  mov    %rax,-0x858(%rbp)
  movl   $0x0,-0x870(%rbp)
  jmp    L73
L10:
  mov    -0x870(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x858(%rbp),%rax
  add    %rdx,%rax
  mov    -0x870(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x888(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x870(%rbp)
L73:
  mov    -0x870(%rbp),%eax
  cmp    -0x88c(%rbp),%eax
  jl     L10
  jmp    L75
L76:
  nop
  jmp    L12
L75:
  nop
L12:
  mov    -0x86c(%rbp),%eax
  mov    -0x18(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L54
  call   <__stack_chk_fail@plt>
L54:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
int un_recv_fds(int fd, char *data, int datalen, int *fds, int fdslen) {
  struct msghdr mh;
  struct cmsghdr *cmh = NULL;
  char buf[2048];
  size_t buflen = CMSG_SPACE(sizeof(int) * fdslen);
  struct iovec iov[1];
  assert(sizeof(buf) >= buflen);
  memset(&mh, 0, sizeof(mh));
  mh.msg_control = buf;
  mh.msg_controllen = buflen;
  mh.msg_iov = iov;
  mh.msg_iovlen = 1;
  iov[0].iov_base = data;
  iov[0].iov_len = datalen;
  int rv;
  do {
    rv = recvmsg(fd, &mh, 0);
  } while (rv == -1 && (errno == EINTR || errno == EAGAIN));
  if (rv <= 0) {
    goto done;
  }
  if (fds != NULL) {
    cmh = CMSG_FIRSTHDR(&mh);
    assert(cmh != NULL);
    assert(cmh->cmsg_level == SOL_SOCKET);
    assert(cmh->cmsg_type == SCM_RIGHTS);
    assert(cmh->cmsg_len == CMSG_LEN(sizeof(int) * fdslen));
    int *fds_ = (int *)CMSG_DATA(cmh);
    int i;
    for (i = 0; i < fdslen; i++) {
      fds[i] = fds_[i];
    }
  }
done:
  return rv;
}
```