user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<write_fd>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0xc8,%rsp
  mov    %edi,-0x94(%rbp)
  mov    %rsi,-0xa0(%rbp)
  mov    %rdx,-0xa8(%rbp)
  mov    %ecx,-0x98(%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,-0xc0(%rbp)
  movq   $0x0,-0xb8(%rbp)
  movslq %ecx,%rax
  sub    $0x1,%rax
  mov    %rax,-0x88(%rbp)
  movslq %ecx,%rax
  mov    %rax,-0xd0(%rbp)
  movq   $0x0,-0xc8(%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,-0xe0(%rbp)
  mov    %rdx,%rax
  and    $0xff,%ah
  mov    %rax,-0xd8(%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,-0xf0(%rbp)
  mov    %rdx,%rax
  and    $0xff,%ah
  mov    %rax,-0xe8(%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
L38:
  cmp    %rdx,%rsp
  je     L5
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L38
L5:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L26
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L26:
  mov    %rsp,%rax
  add    $0x3,%rax
  shr    $0x2,%rax
  shl    $0x2,%rax
  mov    %rax,-0x80(%rbp)
  mov    -0x80(%rbp),%rax
  mov    %rax,-0x60(%rbp)
  mov    %ecx,-0x58(%rbp)
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <CMSG_FIRSTHDR@plt>
  mov    %rax,-0x78(%rbp)
  mov    $0x4,%edi
  call   <CMSG_LEN@plt>
  mov    -0x78(%rbp),%rdx
  mov    %eax,0x8(%rdx)
  mov    D3(%rip),%rax
  mov    (%rax),%edx
  mov    -0x78(%rbp),%rax
  mov    %edx,0x4(%rax)
  mov    D17(%rip),%rax
  mov    (%rax),%edx
  mov    -0x78(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x78(%rbp),%rax
  mov    %rax,%rdi
  call   <CMSG_DATA@plt>
  mov    %rax,%rdx
  mov    -0x98(%rbp),%eax
  mov    %eax,(%rdx)
  movq   $0x0,-0x40(%rbp)
  movq   $0x0,-0x48(%rbp)
  mov    -0xa0(%rbp),%rax
  mov    %rax,-0x68(%rbp)
  mov    -0xa8(%rbp),%rax
  mov    %rax,-0x70(%rbp)
  lea    -0x70(%rbp),%rax
  mov    %rax,-0x50(%rbp)
  movl   $0x1,-0x54(%rbp)
  lea    -0x60(%rbp),%rcx
  mov    -0x94(%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     L30
  call   <__stack_chk_fail@plt>
L30:
  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;
  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.iov_base = ptr;
  iov.iov_len = nbytes;
  msg.msg_iov = &iov;
  msg.msg_iovlen = 1;
  return (sendmsg(fd, &msg, 0));
}
```