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

```asm
<poll>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,(%rsp)
  mov    %rsi,%r13
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  jne    L285
  test   %rsi,%rsi
  jne    L259
L285:
  test   %edx,%edx
  jne    L19
  movl   $0x0,0x20(%rsp)
  movl   $0x0,0x24(%rsp)
  lea    0x20(%rsp),%rax
  mov    %rax,0x8(%rsp)
L190:
  lea    0x14(%rsp),%rdi
  call   <FD_ZERO@plt>
  lea    0x18(%rsp),%rdi
  call   <FD_ZERO@plt>
  lea    0x1c(%rsp),%rdi
  call   <FD_ZERO@plt>
  test   %r13,%r13
  je     L261
  mov    (%rsp),%rbx
  mov    $0x0,%r12d
  mov    $0xffffffff,%r14d
  lea    0x1c(%rsp),%r15
  jmp    L114
L259:
  mov    D32(%rip),%rax
  mov    (%rax),%edx
  mov    D29(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%r14d
  jmp    L35
L19:
  jle    L298
  movslq %edx,%rax
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  mov    %eax,0x20(%rsp)
  imul   $0x3e8,%eax,%eax
  sub    %eax,%edx
  imul   $0x3e8,%edx,%edx
  mov    %edx,0x24(%rsp)
  lea    0x20(%rsp),%rax
  mov    %rax,0x8(%rsp)
  jmp    L190
L298:
  cmp    $0xffffffff,%edx
  jne    L103
  movq   $0x0,0x8(%rsp)
  jmp    L190
L103:
  mov    D45(%rip),%rax
  mov    (%rax),%edx
  mov    D29(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%r14d
  jmp    L35
L260:
  lea    0x14(%rsp),%rsi
  call   <FD_SET@plt>
  jmp    L256
L169:
  lea    0x18(%rsp),%rsi
  mov    0x0(%rbp),%edi
  call   <FD_SET@plt>
  jmp    L224
L73:
  mov    %r15,%rsi
  mov    0x0(%rbp),%edi
  call   <FD_SET@plt>
  jmp    L72
L218:
  mov    D57(%rip),%rax
  mov    (%rax),%edx
  mov    D29(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%r14d
L35:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L179
  mov    %r14d,%eax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L254:
  add    $0x1,%r12
  add    $0xc,%rbx
  cmp    %r12,%r13
  je     L137
L114:
  mov    %rbx,%rbp
  mov    (%rbx),%edi
  test   %edi,%edi
  js     L254
  testb  $0x41,0x4(%rbx)
  jne    L260
L256:
  testl  $0x304,0x4(%rbp)
  jne    L169
L224:
  testb  $0x82,0x4(%rbp)
  jne    L73
L72:
  mov    0x0(%rbp),%eax
  cmp    %r14d,%eax
  jl     L254
  testl  $0x3c7,0x4(%rbp)
  je     L254
  mov    D12(%rip),%rdx
  cmp    (%rdx),%eax
  jg     L218
  mov    %eax,%r14d
  jmp    L254
L261:
  lea    0x1c(%rsp),%rcx
  lea    0x18(%rsp),%rdx
  lea    0x14(%rsp),%rsi
  mov    0x8(%rsp),%r8
  mov    $0x0,%edi
  call   <select@plt>
  test   %eax,%eax
  mov    $0x0,%edx
  cmovle %eax,%edx
  mov    %edx,%r14d
  jmp    L35
L121:
  mov    %eax,0x8(%r12)
  add    $0x1,%rbp
  add    $0xc,%rbx
  cmp    %rbp,%r13
  jbe    L35
L241:
  mov    %rbx,%r12
  mov    (%rbx),%edi
  mov    %r15d,%eax
  test   %edi,%edi
  js     L121
  lea    0x18(%rsp),%rcx
  lea    0x14(%rsp),%rdx
  mov    0x4(%rbx),%esi
  lea    0x1c(%rsp),%r8
  call   <compute_revents@plt>
  cmp    $0x1,%eax
  sbb    $0xffffffff,%r14d
  jmp    L121
L137:
  lea    0x1c(%rsp),%rcx
  lea    0x18(%rsp),%rdx
  lea    0x14(%rsp),%rsi
  lea    0x1(%r14),%edi
  mov    0x8(%rsp),%r8
  call   <select@plt>
  mov    %eax,%r14d
  test   %eax,%eax
  js     L35
  mov    (%rsp),%rbx
  mov    $0x0,%ebp
  mov    $0x0,%r14d
  mov    $0x0,%r15d
  jmp    L241
L179:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int poll(struct pollfd *pfd, nfds_t nfd, int timeout) {
  fd_set rfds, wfds, efds;
  struct timeval tv;
  struct timeval *ptv;
  int maxfd, rc;
  nfds_t i;
  if (!pfd && nfd) {
    errno = EFAULT;
    return -1;
  }
  if (timeout == 0) {
    ptv = &tv;
    ptv->tv_sec = 0;
    ptv->tv_usec = 0;
  } else if (timeout > 0) {
    ptv = &tv;
    ptv->tv_sec = timeout / 1000;
    ptv->tv_usec = (timeout % 1000) * 1000;
  } else if (timeout == (-1))
    ptv = NULL;
  else {
    errno = EINVAL;
    return -1;
  }
  maxfd = -1;
  FD_ZERO(&rfds);
  FD_ZERO(&wfds);
  FD_ZERO(&efds);
  for (i = 0; i < nfd; i++) {
    if (pfd[i].fd < 0)
      continue;
    if (pfd[i].events & (0x0001 | 0x0040))
      FD_SET(pfd[i].fd, &rfds);
    if (pfd[i].events & (0x0004 | 0x0100 | 0x0200))
      FD_SET(pfd[i].fd, &wfds);
    if (pfd[i].events & (0x0002 | 0x0080))
      FD_SET(pfd[i].fd, &efds);
    if (pfd[i].fd >= maxfd && (pfd[i].events & (0x0001 | 0x0004 | 0x0002 | 0x0040 | 0x0080 | 0x0100 | 0x0200))) {
      maxfd = pfd[i].fd;
      if (maxfd > FD_SETSIZE) {
        errno = EOVERFLOW;
        return -1;
      }
    }
  }
  rc = select(maxfd + 1, &rfds, &wfds, &efds, ptv);
  if (rc < 0)
    return rc;
  rc = 0;
  for (i = 0; i < nfd; i++)
    if (pfd[i].fd < 0)
      pfd[i].revents = 0;
    else {
      int happened = compute_revents(pfd[i].fd, pfd[i].events, &rfds, &wfds, &efds);
      if (happened) {
        pfd[i].revents = happened;
        rc++;
      } else {
        pfd[i].revents = 0;
      }
    }
  return rc;
}
```