user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<timed_write>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %ecx,%ebx
  sub    $0x58,%rsp
  mov    %rsi,0x10(%rsp)
  mov    %rdx,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  call   <fd_get_flags@plt>
  cmp    $0xffffffff,%eax
  je     L10
  mov    %eax,%esi
  mov    %ebp,%edi
  mov    %eax,%r13d
  call   <fd_set_nonblocking@plt>
  test   %rax,%rax
  jne    L10
  test   %ebx,%ebx
  lea    0x1(%rbp),%r15d
  lea    0x2c(%rsp),%r12
  mov    $0xffffffff,%eax
  movq   $0x0,0x8(%rsp)
  cmove  %eax,%ebx
  lea    0x30(%rsp),%r14
L101:
  mov    %r12,%rdi
  call   <FD_ZERO@plt>
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <FD_SET@plt>
  xor    %ecx,%ecx
  xor    %esi,%esi
  mov    %r14,%r8
  mov    %r12,%rdx
  mov    %r15d,%edi
  mov    %ebx,0x30(%rsp)
  movq   $0x0,0x38(%rsp)
  call   <select@plt>
  test   %eax,%eax
  je     L13
  cmp    $0xffffffff,%eax
  jne    L12
  mov    D58(%rip),%rax
  mov    D45(%rip),%rdx
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  je     L101
L44:
  mov    $0xffffffff,%r12d
L156:
  mov    %r13d,%esi
  mov    %ebp,%edi
  call   <fd_clear_nonblocking@plt>
L151:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L119
  add    $0x58,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L12:
  mov    0x8(%rsp),%rax
  mov    0x18(%rsp),%rdx
  mov    %ebp,%edi
  mov    0x10(%rsp),%rsi
  sub    %rax,%rdx
  add    %rax,%rsi
  call   <write@plt>
  cmp    $0xffffffff,%eax
  je     L78
  test   %eax,%eax
  je     L92
  cltq
  add    %rax,0x8(%rsp)
  jmp    L101
  nopl   (%rax)
L78:
  mov    D45(%rip),%rax
  mov    D58(%rip),%rdx
  mov    (%rax),%rax
  cmp    (%rdx),%rax
  je     L101
  mov    D54(%rip),%rdx
  cmp    (%rdx),%rax
  jne    L44
  jmp    L101
  nopw   0x0(%rax,%rax,1)
L13:
  mov    0x8(%rsp),%rax
  mov    %eax,%r12d
  test   %rax,%rax
  jne    L156
  mov    D21(%rip),%rax
  mov    $0xffffffff,%r12d
  mov    (%rax),%rdx
  mov    D45(%rip),%rax
  mov    %rdx,(%rax)
  jmp    L156
L10:
  mov    $0xffffffff,%r12d
  jmp    L151
L92:
  mov    0x8(%rsp),%r12d
  jmp    L156
L119:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
ssize_t timed_write(int fd, const void *buf, size_t size, unsigned int timeout) {
  int ret;
  int flags;
  fd_set set;
  size_t have;
  ssize_t count;
  struct timeval wait_time;
  flags = fd_get_flags(fd);
  if (flags == -1)
    return -1;
  if (fd_set_nonblocking(fd, flags))
    return -1;
  if (!timeout)
    timeout = (unsigned int)-1;
  have = 0;
  for (;;) {
    FD_ZERO(&set);
    FD_SET(fd, &set);
    wait_time.tv_sec = timeout;
    wait_time.tv_usec = 0;
    ret = select(fd + 1, NULL, &set, NULL, &wait_time);
    if (ret == 0) {
      if (!have) {
        errno = ETIMEDOUT;
        have = -1;
      }
      break;
    } else if (ret == -1) {
      if (errno == EINTR) {
        continue;
      } else {
        have = -1;
        break;
      }
    } else {
      count = write(fd, buf + have, size - have);
      if (count == -1) {
        if (errno == EINTR || errno == EAGAIN) {
          continue;
        } else {
          have = -1;
          break;
        }
      } else if (count == 0) {
        break;
      } else {
        have += (size_t)count;
      }
    }
  }
  (void)fd_clear_nonblocking(fd, flags);
  return have;
}
```