user: Translate the below assembly code into C programming language:

```asm
<write_fd>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0xd8,%rsp
  mov    %edi,-0xa4(%rbp)
  mov    %rsi,-0xb0(%rbp)
  mov    %rdx,-0xb8(%rbp)
  mov    %ecx,-0xa8(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%rbx
  mov    $0x4,%edi
  call   <CMSG_SPACE@plt>
  mov    %eax,%ecx
  movslq %ecx,%rax
  mov    %rax,-0xd0(%rbp)
  movq   $0x0,-0xc8(%rbp)
  movslq %ecx,%rax
  sub    $0x1,%rax
  mov    %rax,-0x98(%rbp)
  movslq %ecx,%rax
  mov    %rax,-0xe0(%rbp)
  movq   $0x0,-0xd8(%rbp)
  movslq %ecx,%rax
  mov    $0xc,%edx
  cmp    %rdx,%rax
  cmovb  %rdx,%rax
  mov    %rax,%r14
  mov    $0x0,%r15d
  mov    %r14,%rax
  mov    %r15,%rdx
  shld   $0x3,%rax,%rdx
  shl    $0x3,%rax
  add    $0x1f,%rax
  adc    $0x0,%rdx
  mov    %rax,%rsi
  and    $0xffffffffffffffe0,%rsi
  mov    %rsi,-0xf0(%rbp)
  mov    %rdx,%rax
  and    $0xff,%ah
  mov    %rax,-0xe8(%rbp)
  movslq %ecx,%rax
  mov    $0xc,%edx
  cmp    %rdx,%rax
  cmovb  %rdx,%rax
  mov    %rax,%r12
  mov    $0x0,%r13d
  mov    %r12,%rax
  mov    %r13,%rdx
  shld   $0x3,%rax,%rdx
  shl    $0x3,%rax
  add    $0x1f,%rax
  adc    $0x0,%rdx
  mov    %rax,%rdi
  and    $0xffffffffffffffe0,%rdi
  mov    %rdi,-0x100(%rbp)
  mov    %rdx,%rax
  and    $0xff,%ah
  mov    %rax,-0xf8(%rbp)
  movslq %ecx,%rax
  mov    $0xc,%edx
  cmp    %rdx,%rax
  cmovb  %rdx,%rax
  add    $0x3,%rax
  and    $0xfffffffffffffffc,%rax
  mov    %rax,%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%edi
  mov    $0x0,%edx
  div    %rdi
  imul   $0x10,%rax,%rax
  mov    %rax,%rsi
  and    $0xfffffffffffff000,%rsi
  mov    %rsp,%rdx
  sub    %rsi,%rdx
L33:
  cmp    %rdx,%rsp
  je     L15
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L33
L15:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L27
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L27:
  mov    %rsp,%rax
  add    $0x3,%rax
  shr    $0x2,%rax
  shl    $0x2,%rax
  mov    %rax,-0x90(%rbp)
  mov    -0x90(%rbp),%rax
  mov    %rax,-0x80(%rbp)
  mov    %ecx,-0x78(%rbp)
  lea    -0x80(%rbp),%rax
  mov    %rax,%rdi
  call   <CMSG_FIRSTHDR@plt>
  mov    %rax,-0x88(%rbp)
  mov    $0x4,%edi
  call   <CMSG_LEN@plt>
  mov    -0x88(%rbp),%rdx
  mov    %eax,0x8(%rdx)
  mov    D1(%rip),%rax
  mov    (%rax),%edx
  mov    -0x88(%rbp),%rax
  mov    %edx,0x4(%rax)
  mov    D0(%rip),%rax
  mov    (%rax),%edx
  mov    -0x88(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x88(%rbp),%rax
  mov    %rax,%rdi
  call   <CMSG_DATA@plt>
  mov    %rax,%rdx
  mov    -0xa8(%rbp),%eax
  mov    %eax,(%rdx)
  movq   $0x0,-0x60(%rbp)
  movq   $0x0,-0x68(%rbp)
  mov    -0xb0(%rbp),%rax
  mov    %rax,-0x48(%rbp)
  mov    -0xb8(%rbp),%rax
  mov    %rax,-0x50(%rbp)
  lea    -0x50(%rbp),%rax
  mov    %rax,-0x70(%rbp)
  movl   $0x1,-0x74(%rbp)
  lea    -0x80(%rbp),%rcx
  mov    -0xa4(%rbp),%eax
  mov    $0x0,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <sendmsg@plt>
  mov    %rbx,%rsp
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L17
  call   <__stack_chk_fail@plt>
L17:
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

assistant: ```c
ssize_t write_fd(int fd, void *ptr, size_t nbytes, int sendfd) {
  struct msghdr msg;
  struct iovec iov[1];
  union {
    struct cmsghdr cm;
    char control[CMSG_SPACE(sizeof(int))];
  } control_un;
  struct cmsghdr *cmptr;
  msg.msg_control = control_un.control;
  msg.msg_controllen = sizeof(control_un.control);
  cmptr = CMSG_FIRSTHDR(&msg);
  cmptr->cmsg_len = CMSG_LEN(sizeof(int));
  cmptr->cmsg_level = SOL_SOCKET;
  cmptr->cmsg_type = SCM_RIGHTS;
  *((int *)CMSG_DATA(cmptr)) = sendfd;
  msg.msg_name = NULL;
  msg.msg_namelen = 0;
  iov[0].iov_base = ptr;
  iov[0].iov_len = nbytes;
  msg.msg_iov = iov;
  msg.msg_iovlen = 1;
  return (sendmsg(fd, &msg, 0));
}
```