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

```asm
<connect_timeout>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %edi,%ebx
  mov    %rsi,%rbp
  mov    %edx,%r12d
  mov    %ecx,%r13d
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    $0x0,%edx
  mov    D128(%rip),%rax
  mov    (%rax),%esi
  call   <fcntl@plt>
  mov    %eax,%r14d
  mov    D169(%rip),%rax
  mov    (%rax),%edx
  test   %r14d,%edx
  je     L19
L114:
  mov    %r12d,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <connect@plt>
  test   %eax,%eax
  jns    L27
  mov    D91(%rip),%rax
  mov    (%rax),%eax
  mov    D21(%rip),%rdx
  cmp    (%rdx),%eax
  je     L114
  mov    D107(%rip),%rdx
  cmp    (%rdx),%eax
  jne    L82
  mov    %ebx,0x10(%rsp)
  mov    D123(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,0x14(%rsp)
  imul   $0x3e8,%r13d,%r13d
  lea    0x10(%rsp),%rbp
L103:
  mov    %r13d,%edx
  mov    $0x1,%esi
  mov    %rbp,%rdi
  call   <poll@plt>
  test   %eax,%eax
  jns    L16
  mov    D91(%rip),%rdx
  mov    D21(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,(%rdx)
  je     L103
L82:
  mov    D91(%rip),%rbp
  mov    0x0(%rbp),%r12d
  mov    %r14d,%edx
  mov    D33(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  call   <fcntl@plt>
  mov    %r12d,0x0(%rbp)
  mov    $0xffffffff,%ebp
  jmp    L23
L19:
  or     %r14d,%edx
  mov    D33(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  call   <fcntl@plt>
  jmp    L114
L16:
  je     L63
L27:
  movl   $0x4,0xc(%rsp)
  lea    0x8(%rsp),%rcx
  lea    0xc(%rsp),%r8
  mov    D130(%rip),%rax
  mov    (%rax),%edx
  mov    D137(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  call   <getsockopt@plt>
  mov    0x8(%rsp),%ebp
  test   %ebp,%ebp
  jne    L30
  mov    D169(%rip),%rax
  mov    (%rax),%edx
  not    %edx
  and    %r14d,%edx
  mov    D33(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  call   <fcntl@plt>
L23:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L53
  mov    %ebp,%eax
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L63:
  mov    D91(%rip),%rbp
  mov    0x0(%rbp),%r12d
  mov    %ebx,%edi
  call   <close@plt>
  mov    %r12d,0x0(%rbp)
  jmp    L82
L30:
  mov    D91(%rip),%rax
  mov    %ebp,(%rax)
  jmp    L82
L53:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int connect_timeout(int s, struct sockaddr *saddrp, int len, int time_secs) {
  struct pollfd pfds;
  int ret, oldfl, err, val;
  socklen_t val_len;
  oldfl = fcntl(s, F_GETFL, 0);
  if (!(oldfl & O_NONBLOCK))
    fcntl(s, F_SETFL, oldfl | O_NONBLOCK);
connect_timeout_connect_restart:
  ret = connect(s, saddrp, len);
  if (ret < 0) {
    if (errno == EINTR)
      goto connect_timeout_connect_restart;
    if (errno != EINPROGRESS)
      goto connect_timeout_err;
    pfds.fd = s;
    pfds.events = POLLOUT;
  connect_timeout_poll_restart:
    ret = poll(&pfds, 1, time_secs * 1000);
    if (ret < 0) {
      if (errno == EINTR)
        goto connect_timeout_poll_restart;
      else
        goto connect_timeout_err;
    }
    if (ret == 0) {
      err = errno;
      close(s);
      errno = err;
      goto connect_timeout_err;
    }
  }
  val_len = sizeof(val);
  ret = getsockopt(s, SOL_SOCKET, SO_ERROR, &val, &val_len);
  if (val != 0) {
    errno = val;
    goto connect_timeout_err;
  }
  fcntl(s, F_SETFL, oldfl & (~O_NONBLOCK));
  return 0;
connect_timeout_err:
  err = errno;
  fcntl(s, F_SETFL, oldfl);
  errno = err;
  return -1;
}
```