user: What would the C source look like for the assembly code provided here:

```asm
<connect_nb>:
  endbr64
  push   %r15
  mov    $0x4,%r8d
  push   %r14
  push   %r13
  mov    %edx,%r13d
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %ecx,%ebx
  sub    $0x48,%rsp
  mov    D102(%rip),%r14
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  mov    D113(%rip),%rax
  lea    0xc(%rsp),%rcx
  movl   $0x1,0xc(%rsp)
  mov    (%r14),%esi
  mov    (%rax),%edx
  call   <setsockopt@plt>
  test   %rax,%rax
  js     L1
  mov    D21(%rip),%rax
  xor    %edx,%edx
  mov    %ebp,%edi
  mov    (%rax),%esi
  call   <fcntl@plt>
  mov    D31(%rip),%rdx
  mov    D37(%rip),%r15
  mov    %ebp,%edi
  mov    %eax,0xc(%rsp)
  mov    (%r15),%esi
  or     (%rdx),%eax
  mov    %eax,%edx
  call   <fcntl@plt>
  mov    %r13d,%edx
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <connect@plt>
  test   %eax,%eax
  js     L90
  je     L89
L99:
  lea    0x18(%rsp),%r12
  lea    0x1c(%rsp),%r13
  mov    %r12,%rdi
  call   <FD_ZERO@plt>
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <FD_SET@plt>
  mov    %r13,%rdi
  call   <FD_ZERO@plt>
  mov    %r13,%rsi
  mov    %ebp,%edi
  call   <FD_SET@plt>
  xor    %ecx,%ecx
  lea    0x1(%rbp),%edi
  lea    0x20(%rsp),%r8
  mov    %r13,%rdx
  mov    %r12,%rsi
  mov    %ebx,0x20(%rsp)
  movq   $0x0,0x28(%rsp)
  call   <select@plt>
  test   %rax,%rax
  je     L85
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L47
L32:
  mov    (%r14),%esi
  lea    0x10(%rsp),%rcx
  lea    0x14(%rsp),%r8
  mov    %ebp,%edi
  mov    D2(%rip),%rax
  movl   $0x4,0x14(%rsp)
  mov    (%rax),%edx
  call   <getsockopt@plt>
  test   %rax,%rax
  js     L38
  mov    0x10(%rsp),%r12d
  test   %r12d,%r12d
  jne    L49
  mov    0xc(%rsp),%edx
  mov    (%r15),%esi
  mov    %ebp,%edi
  call   <fcntl@plt>
L114:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L9
  add    $0x48,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L47:
  mov    %r13,%rsi
  mov    %ebp,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  jne    L32
  nopl   0x0(%rax,%rax,1)
L89:
  mov    D123(%rip),%rax
  mov    (%rax),%edx
  mov    D105(%rip),%rax
  mov    %edx,(%rax)
L1:
  mov    $0xffffffff,%r12d
  jmp    L114
  nopw   0x0(%rax,%rax,1)
L90:
  mov    D124(%rip),%rax
  mov    D105(%rip),%rdx
  mov    (%rax),%eax
  cmp    %eax,(%rdx)
  je     L99
  jmp    L1
  nopw   0x0(%rax,%rax,1)
L85:
  mov    D96(%rip),%rax
  mov    $0xffffffff,%r12d
  mov    (%rax),%edx
  mov    D105(%rip),%rax
  mov    %edx,(%rax)
  jmp    L114
  nopl   (%rax)
L49:
  mov    %ebp,%edi
  mov    $0xffffffff,%r12d
  call   <close@plt>
  mov    D105(%rip),%rax
  mov    0x10(%rsp),%edx
  mov    %edx,(%rax)
  jmp    L114
L38:
  mov    %ebp,%edi
  mov    $0xffffffff,%r12d
  call   <close@plt>
  jmp    L114
L9:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int connect_nb(int fd, struct sockaddr *dest, socklen_t len, int timeout) {
  int ret, flags = 1, err;
  unsigned l;
  fd_set rfds, wfds;
  struct timeval tv;
  if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&flags, sizeof(flags)) < 0)
    return -1;
  flags = fcntl(fd, F_GETFL, 0);
  fcntl(fd, F_SETFL, flags | O_NONBLOCK);
  ret = connect(fd, dest, len);
  if ((ret < 0) && (errno != EINPROGRESS))
    return -1;
  if (ret != 0) {
    FD_ZERO(&rfds);
    FD_SET(fd, &rfds);
    FD_ZERO(&wfds);
    FD_SET(fd, &wfds);
    tv.tv_sec = timeout;
    tv.tv_usec = 0;
    if (select(fd + 1, &rfds, &wfds, NULL, &tv) == 0) {
      errno = ETIMEDOUT;
      return -1;
    }
    if (FD_ISSET(fd, &rfds) || FD_ISSET(fd, &wfds)) {
      l = sizeof(err);
      if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&err, &l) < 0) {
        close(fd);
        return -1;
      }
      if (err != 0) {
        close(fd);
        errno = err;
        return -1;
      }
      fcntl(fd, F_SETFL, flags);
      return 0;
    }
  }
  errno = EIO;
  return -1;
}
```