user: 请从给定的汇编指令推导出C源代码:

```asm
<poll>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %rdi,0x28(%rsp)
  mov    %rsi,0x20(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L95
  test   %edx,%edx
  je     L109
  jle    L21
  movslq %edx,%rax
  mov    %edx,%ecx
  imul   $0x10624dd3,%rax,%rax
  sar    $0x1f,%ecx
  sar    $0x26,%rax
  sub    %ecx,%eax
  imul   $0x3e8,%eax,%ecx
  movd   %eax,%xmm0
  lea    0x50(%rsp),%rax
  mov    %rax,0x30(%rsp)
  sub    %ecx,%edx
  imul   $0x3e8,%edx,%edx
  movd   %edx,%xmm1
  punpckldq %xmm1,%xmm0
  movq   %xmm0,0x50(%rsp)
L70:
  lea    0x44(%rsp),%r13
  lea    0x48(%rsp),%r14
  mov    %r13,%rdi
  call   <FD_ZERO@plt>
  mov    %r14,%rdi
  call   <FD_ZERO@plt>
  lea    0x4c(%rsp),%rax
  mov    %rax,%rdi
  mov    %rax,0x8(%rsp)
  call   <FD_ZERO@plt>
  mov    0x20(%rsp),%rax
  test   %rax,%rax
  je     L208
  mov    0x28(%rsp),%rbx
  xor    %r12d,%r12d
  mov    $0xffffffff,%ecx
  mov    %rax,%rbp
  mov    %r13,0x10(%rsp)
  mov    %r12,%r13
  mov    %ecx,%r12d
  mov    %rbx,0x38(%rsp)
  mov    %r14,0x18(%rsp)
  jmp    L199
  nopl   0x0(%rax,%rax,1)
L247:
  mov    D57(%rip),%r8
  mov    D94(%rip),%rdx
  mov    (%r8),%eax
  or     (%rdx),%eax
  test   %esi,%eax
  jne    L50
L144:
  cmp    %edi,%r12d
  jg     L161
  mov    D115(%rip),%rcx
  mov    D94(%rip),%rdx
  mov    (%r15),%eax
  or     (%r14),%eax
  or     (%r8),%eax
  or     (%rcx),%eax
  mov    D98(%rip),%rcx
  or     (%rdx),%eax
  mov    D148(%rip),%rdx
  or     (%rcx),%eax
  or     (%rdx),%eax
  and    0x4(%rbx),%eax
  je     L161
  mov    D177(%rip),%rax
  cmp    %edi,(%rax)
  jl     L246
  mov    %edi,%r12d
  nopl   0x0(%rax)
L161:
  add    $0x1,%r13
  add    $0xc,%rbx
  cmp    %r13,%rbp
  je     L198
L199:
  mov    (%rbx),%edi
  test   %edi,%edi
  js     L161
  mov    D59(%rip),%r15
  mov    D115(%rip),%rcx
  mov    0x4(%rbx),%esi
  mov    (%r15),%eax
  or     (%rcx),%eax
  test   %esi,%eax
  jne    L93
L287:
  mov    D20(%rip),%r14
  mov    D98(%rip),%rdx
  mov    D148(%rip),%rcx
  mov    (%r14),%eax
  or     (%rdx),%eax
  or     (%rcx),%eax
  test   %esi,%eax
  je     L247
  mov    0x18(%rsp),%rsi
  call   <FD_SET@plt>
  mov    0x4(%rbx),%esi
  mov    (%rbx),%edi
  jmp    L247
  nopl   0x0(%rax)
L109:
  movq   $0x0,0x50(%rsp)
  lea    0x50(%rsp),%rax
  mov    %rax,0x30(%rsp)
  jmp    L70
  nopl   0x0(%rax,%rax,1)
L93:
  mov    0x10(%rsp),%rsi
  call   <FD_SET@plt>
  mov    0x4(%rbx),%esi
  mov    (%rbx),%edi
  jmp    L287
  nopl   0x0(%rax)
L50:
  mov    0x8(%rsp),%rsi
  call   <FD_SET@plt>
  mov    (%rbx),%edi
  mov    D57(%rip),%r8
  jmp    L144
L198:
  mov    0x10(%rsp),%r13
  mov    0x18(%rsp),%r14
  mov    %r12d,%edi
  mov    0x30(%rsp),%r8
  mov    0x8(%rsp),%rcx
  add    $0x1,%edi
  mov    %r14,%rdx
  mov    %r13,%rsi
  mov    0x38(%rsp),%rbx
  call   <select@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  js     L28
  mov    0x20(%rsp),%rax
  mov    0x28(%rsp),%rcx
  xor    %r12d,%r12d
  mov    0x8(%rsp),%r15
  lea    (%rax,%rax,2),%rax
  lea    (%rcx,%rax,4),%rbp
  jmp    L146
  nopl   (%rax)
L252:
  movl   $0x0,0x8(%rbx)
L138:
  add    $0xc,%rbx
  cmp    %rbp,%rbx
  je     L28
L146:
  mov    (%rbx),%edi
  test   %edi,%edi
  js     L252
  mov    0x4(%rbx),%esi
  mov    %r15,%r8
  mov    %r14,%rcx
  mov    %r13,%rdx
  call   <compute_revents@plt>
  test   %eax,%eax
  je     L138
  mov    %eax,0x8(%rbx)
  add    $0xc,%rbx
  add    $0x1,%r12d
  cmp    %rbp,%rbx
  jne    L146
  nopl   0x0(%rax,%rax,1)
L28:
  mov    0x58(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L295
  add    $0x68,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L21:
  cmp    $0xffffffff,%edx
  jne    L55
  movq   $0x0,0x30(%rsp)
  jmp    L70
L246:
  mov    D3(%rip),%rax
  mov    $0xffffffff,%r12d
  mov    (%rax),%edx
  mov    D51(%rip),%rax
  mov    %edx,(%rax)
  jmp    L28
L208:
  mov    0x30(%rsp),%r8
  mov    0x8(%rsp),%rcx
  mov    %r14,%rdx
  xor    %edi,%edi
  mov    %r13,%rsi
  call   <select@plt>
  xor    %edx,%edx
  test   %eax,%eax
  cmovle %eax,%edx
  mov    %edx,%r12d
  jmp    L28
L55:
  mov    D145(%rip),%rax
  mov    $0xffffffff,%r12d
  mov    (%rax),%edx
  mov    D51(%rip),%rax
  mov    %edx,(%rax)
  jmp    L28
L95:
  mov    D182(%rip),%rax
  mov    $0xffffffff,%r12d
  mov    (%rax),%edx
  mov    D51(%rip),%rax
  mov    %edx,(%rax)
  jmp    L28
L295:
  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) {
    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 & (POLLIN | POLLRDNORM))
      FD_SET(pfd[i].fd, &rfds);
    if (pfd[i].events & (POLLOUT | POLLWRNORM | POLLWRBAND))
      FD_SET(pfd[i].fd, &wfds);
    if (pfd[i].events & (POLLPRI | POLLRDBAND))
      FD_SET(pfd[i].fd, &efds);
    if (pfd[i].fd >= maxfd && (pfd[i].events & (POLLIN | POLLOUT | POLLPRI | POLLRDNORM | POLLRDBAND | POLLWRNORM | POLLWRBAND))) {
      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++;
      }
    }
  return rc;
}
```