user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<connect_nonb>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  xor    %edx,%edx
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %ecx,%ebx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  mov    D69(%rip),%rax
  mov    (%rax),%esi
  call   <fcntl@plt>
  mov    D22(%rip),%r15
  mov    %ebp,%edi
  mov    %eax,%r12d
  mov    D6(%rip),%rax
  mov    (%r15),%esi
  mov    (%rax),%edx
  or     %r12d,%edx
  call   <fcntl@plt>
  mov    %r14d,%edx
  mov    %r13,%rsi
  mov    %ebp,%edi
  movl   $0x0,(%rsp)
  call   <connect@plt>
  test   %eax,%eax
  js     L110
  jne    L47
L109:
  mov    (%r15),%esi
  mov    %r12d,%edx
  mov    %ebp,%edi
  call   <fcntl@plt>
  mov    (%rsp),%eax
  test   %eax,%eax
  jne    L100
L23:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L31
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L110:
  mov    D21(%rip),%rax
  mov    D62(%rip),%rdx
  mov    (%rax),%eax
  cmp    %eax,(%rdx)
  jne    L72
L47:
  lea    0x8(%rsp),%r13
  lea    0xc(%rsp),%r14
  mov    %r13,%rdi
  call   <FD_ZERO@plt>
  mov    %r13,%rsi
  mov    %ebp,%edi
  call   <FD_SET@plt>
  mov    0x8(%rsp),%eax
  lea    0x1(%rbp),%edi
  mov    %r14,%rdx
  lea    0x10(%rsp),%r8
  mov    %r13,%rsi
  mov    %ebx,0x10(%rsp)
  mov    %eax,0xc(%rsp)
  xor    %eax,%eax
  test   %ebx,%ebx
  movq   $0x0,0x18(%rsp)
  cmove  %rax,%r8
  xor    %ecx,%ecx
  call   <select@plt>
  test   %eax,%eax
  je     L114
  mov    %r13,%rsi
  mov    %ebp,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  jne    L121
  mov    %r14,%rsi
  mov    %ebp,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L63
L121:
  mov    D51(%rip),%rax
  mov    %rsp,%rcx
  lea    0x4(%rsp),%r8
  mov    %ebp,%edi
  movl   $0x4,0x4(%rsp)
  mov    (%rax),%edx
  mov    D4(%rip),%rax
  mov    (%rax),%esi
  call   <getsockopt@plt>
  test   %rax,%rax
  jns    L109
  cs nopw 0x0(%rax,%rax,1)
L72:
  mov    $0xffffffff,%eax
  jmp    L23
  nopw   0x0(%rax,%rax,1)
L63:
  xor    %edi,%edi
  call   <assert@plt>
  jmp    L109
L100:
  mov    %ebp,%edi
  call   <close@plt>
  mov    D62(%rip),%rax
  mov    (%rsp),%edx
  mov    %edx,(%rax)
  jmp    L72
L114:
  mov    %ebp,%edi
  call   <close@plt>
  mov    D48(%rip),%rax
  mov    (%rax),%edx
  mov    D62(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L23
L31:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int connect_nonb(int sockfd, const struct sockaddr *saptr, socklen_t salen, int nsec) {
  int flags, n, error;
  socklen_t len;
  fd_set rset, wset;
  struct timeval tval;
  flags = fcntl(sockfd, F_GETFL, 0);
  fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
  error = 0;
  if ((n = connect(sockfd, saptr, salen)) < 0)
    if (errno != EINPROGRESS)
      return (-1);
  if (n == 0)
    goto done;
  FD_ZERO(&rset);
  FD_SET(sockfd, &rset);
  wset = rset;
  tval.tv_sec = nsec;
  tval.tv_usec = 0;
  if ((n = select(sockfd + 1, &rset, &wset, NULL, nsec ? &tval : NULL)) == 0) {
    close(sockfd);
    errno = ETIMEDOUT;
    return (-1);
  }
  if (FD_ISSET(sockfd, &rset) || FD_ISSET(sockfd, &wset)) {
    len = sizeof(error);
    if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
      return (-1);
  } else
    assert(0 && "select error: sockfd not set");
done:
  fcntl(sockfd, F_SETFL, flags);
  if (error) {
    close(sockfd);
    errno = error;
    return (-1);
  }
  return (0);
}
```