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

```asm
<un_recv_fds>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x858,%rsp
  mov    %edi,%ebx
  mov    %rsi,%r14
  mov    %edx,%r13d
  mov    %rcx,0x8(%rsp)
  mov    %r8d,%ebp
  mov    %fs:0x28,%rax
  mov    %rax,0x848(%rsp)
  xor    %eax,%eax
  lea    0x0(,%r8,4),%r15d
  mov    %r15d,%edi
  call   <CMSG_SPACE@plt>
  mov    %rax,%r12
  cmp    $0x800,%rax
  setbe  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  lea    0x10(%rsp),%rdi
  mov    $0x20,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  lea    0x40(%rsp),%rax
  mov    %rax,0x10(%rsp)
  mov    %r12,0x18(%rsp)
  lea    0x30(%rsp),%rax
  mov    %rax,0x28(%rsp)
  movl   $0x1,0x20(%rsp)
  mov    %r14,0x30(%rsp)
  mov    %r13d,0x38(%rsp)
  lea    0x10(%rsp),%r13
L31:
  mov    $0x0,%edx
  mov    %r13,%rsi
  mov    %ebx,%edi
  call   <recvmsg@plt>
  mov    %eax,%r12d
  cmp    $0xffffffff,%eax
  jne    L8
  mov    D7(%rip),%rax
  mov    (%rax),%rax
  mov    D17(%rip),%rdx
  cmp    (%rdx),%rax
  je     L31
  mov    D41(%rip),%rdx
  cmp    (%rdx),%rax
  je     L31
L56:
  mov    0x848(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L76
  mov    %r12d,%eax
  add    $0x858,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L8:
  mov    0x8(%rsp),%r14
  test   %r14,%r14
  je     L56
  test   %eax,%eax
  jle    L56
  lea    0x10(%rsp),%rdi
  call   <CMSG_FIRSTHDR@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    D49(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rbx)
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    D4(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,0x8(%rbx)
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x10(%rbx),%r13
  mov    %r15d,%edi
  call   <CMSG_LEN@plt>
  cmp    %rax,%r13
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    %rbx,%rdi
  call   <CMSG_DATA@plt>
  test   %ebp,%ebp
  jle    L56
  mov    %ebp,%ebp
  lea    (%rax,%rbp,4),%rsi
  mov    %rax,%rdx
  mov    %r14,%rcx
  sub    %rax,%rcx
L81:
  mov    (%rdx),%eax
  mov    %eax,(%rcx,%rdx,1)
  add    $0x4,%rdx
  cmp    %rsi,%rdx
  jne    L81
  jmp    L56
L76:
  call   <__stack_chk_fail@plt>
```

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