user: Converte this assembly snippet into its equivalent C code:

```asm
<usys_select>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  mov    %r9,%r13
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rsi,0x10(%rsp)
  lea    0x28(%rsp),%rbp
  lea    0x2c(%rsp),%rbx
  mov    %r8d,0x1c(%rsp)
  mov    %rbp,%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  call   <FD_ZERO@plt>
  mov    %rbx,%rdi
  call   <FD_ZERO@plt>
  imul   $0x3e8,%r14d,%eax
  mov    (%r12),%r14d
  movq   $0x0,0x38(%rsp)
  mov    %eax,0x30(%rsp)
  movslq 0x1c(%rsp),%rax
  test   %eax,%eax
  jle    L31
  mov    %r14d,%edi
  lea    (%r12,%rax,4),%r8
  mov    %r12,%rcx
  test   %edi,%edi
  jns    L30
  nopl   0x0(%rax)
L143:
  cmp    %edi,%r14d
  cmovl  %edi,%r14d
  add    $0x4,%rcx
  cmp    %r8,%rcx
  je     L31
L129:
  mov    (%rcx),%edi
  test   %edi,%edi
  js     L143
L30:
  mov    %rbp,%rsi
  mov    %r8,0x8(%rsp)
  mov    %rcx,(%rsp)
  call   <FD_SET@plt>
  mov    (%rsp),%rcx
  mov    0x8(%rsp),%r8
  mov    (%rcx),%eax
  cmp    %eax,%r14d
  cmovl  %eax,%r14d
  add    $0x4,%rcx
  cmp    %r8,%rcx
  jne    L129
L31:
  mov    0x90(%rsp),%edx
  test   %edx,%edx
  jle    L160
  movslq 0x90(%rsp),%rax
  mov    %r13,%rcx
  lea    0x0(%r13,%rax,4),%r8
  nopl   (%rax)
L28:
  mov    (%rcx),%edi
  test   %edi,%edi
  jns    L140
  cmp    %edi,%r14d
  cmovl  %edi,%r14d
  add    $0x4,%rcx
  cmp    %r8,%rcx
  jne    L28
L160:
  xor    %ecx,%ecx
  lea    0x1(%r14),%edi
  lea    0x30(%rsp),%r8
  mov    %rbx,%rdx
  mov    %rbp,%rsi
  call   <select@plt>
  test   %eax,%eax
  js     L68
  movslq 0x1c(%rsp),%rdx
  xor    %r14d,%r14d
  mov    %rdx,(%rsp)
  test   %edx,%edx
  jle    L111
L33:
  mov    (%r12,%r14,4),%edi
  mov    %rbp,%rsi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L72
  mov    $0x1,%eax
  mov    %r14d,%ecx
  shl    %cl,%eax
  or     %eax,(%r15)
L72:
  add    $0x1,%r14
  cmp    (%rsp),%r14
  jne    L33
L111:
  mov    0x90(%rsp),%eax
  xor    %r15d,%r15d
  movslq 0x90(%rsp),%rbp
  mov    $0x1,%r12d
  test   %eax,%eax
  jle    L68
  nopl   0x0(%rax)
L119:
  mov    0x0(%r13,%r15,4),%edi
  mov    %rbx,%rsi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L113
  mov    0x10(%rsp),%rdx
  mov    %r12d,%eax
  mov    %r15d,%ecx
  shl    %cl,%eax
  or     %eax,(%rdx)
L113:
  add    $0x1,%r15
  cmp    %r15,%rbp
  jne    L119
L68:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L86
  add    $0x58,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L140:
  mov    %rbx,%rsi
  mov    %r8,0x8(%rsp)
  mov    %rcx,(%rsp)
  call   <FD_SET@plt>
  mov    (%rsp),%rcx
  mov    0x8(%rsp),%r8
  mov    (%rcx),%eax
  cmp    %eax,%r14d
  cmovl  %eax,%r14d
  add    $0x4,%rcx
  cmp    %rcx,%r8
  jne    L28
  jmp    L160
L86:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
uint32_t usys_select(uint32_t *rmask, uint32_t *wmask, int time, int *reads, int nreads, int *writes, int nwrites) {
  int *sock_p, max_fd, err;
  fd_set readfds, writefds;
  struct timeval tv;
  FD_ZERO(&readfds);
  FD_ZERO(&writefds);
  tv.tv_sec = 0;
  tv.tv_usec = (time * 1000);
  sock_p = reads;
  max_fd = *sock_p;
  for (int i = 0; i < nreads; i++) {
    if (*sock_p >= 0)
      FD_SET(*sock_p, &readfds);
    if (*sock_p > max_fd)
      max_fd = *sock_p;
    sock_p++;
  }
  sock_p = writes;
  for (int i = 0; i < nwrites; i++) {
    if (*sock_p >= 0)
      FD_SET(*sock_p, &writefds);
    if (*sock_p > max_fd)
      max_fd = *sock_p;
    sock_p++;
  }
  err = select(max_fd + 1, &readfds, &writefds, NULL, &tv);
  if (err < 0)
    return 0;
  sock_p = reads;
  for (int i = 0; i < nreads; i++) {
    if (FD_ISSET(*sock_p, &readfds))
      *rmask |= (0x01 << i);
    sock_p++;
  }
  sock_p = writes;
  for (int i = 0; i < nwrites; i++) {
    if (FD_ISSET(*sock_p, &writefds))
      *wmask |= (0x01 << i);
    sock_p++;
  }
  return 0;
}
```