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    L182
  test   %rsi,%rsi
  jne    L236
L182:
  test   %edx,%edx
  jne    L31
  movl   $0x0,0x20(%rsp)
  movl   $0x0,0x24(%rsp)
  lea    0x20(%rsp),%rax
  mov    %rax,0x8(%rsp)
L186:
  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     L29
  mov    (%rsp),%rbx
  mov    $0x0,%r12d
  mov    $0xffffffff,%r14d
  lea    0x1c(%rsp),%r15
  jmp    L193
L236:
  mov    D14(%rip),%rax
  mov    (%rax),%edx
  mov    D200(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%r12d
  jmp    L103
L31:
  jle    L245
  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    L186
L245:
  cmp    $0xffffffff,%edx
  jne    L220
  movq   $0x0,0x8(%rsp)
  jmp    L186
L220:
  mov    D177(%rip),%rax
  mov    (%rax),%edx
  mov    D200(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%r12d
  jmp    L103
L264:
  lea    0x14(%rsp),%rsi
  call   <FD_SET@plt>
  jmp    L93
L82:
  lea    0x18(%rsp),%rsi
  mov    0x0(%rbp),%edi
  call   <FD_SET@plt>
  jmp    L104
L178:
  mov    %r15,%rsi
  mov    0x0(%rbp),%edi
  call   <FD_SET@plt>
  jmp    L275
L122:
  mov    D113(%rip),%rax
  mov    (%rax),%edx
  mov    D200(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%r12d
L103:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L305
  mov    %r12d,%eax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L14:
  add    $0x1,%r12
  add    $0xc,%rbx
  cmp    %r12,%r13
  je     L280
L193:
  mov    %rbx,%rbp
  mov    (%rbx),%edi
  test   %edi,%edi
  js     L14
  mov    D37(%rip),%rax
  mov    (%rax),%eax
  mov    D119(%rip),%rdx
  or     (%rdx),%eax
  and    0x4(%rbx),%eax
  jne    L264
L93:
  mov    D201(%rip),%rax
  mov    (%rax),%eax
  mov    D59(%rip),%rdx
  or     (%rdx),%eax
  mov    D154(%rip),%rdx
  or     (%rdx),%eax
  and    0x4(%rbp),%eax
  jne    L82
L104:
  mov    D71(%rip),%rax
  mov    (%rax),%eax
  mov    D149(%rip),%rdx
  or     (%rdx),%eax
  and    0x4(%rbp),%eax
  jne    L178
L275:
  mov    0x0(%rbp),%edx
  cmp    %r14d,%edx
  jl     L14
  mov    D37(%rip),%rax
  mov    (%rax),%eax
  mov    D201(%rip),%rcx
  or     (%rcx),%eax
  mov    D71(%rip),%rcx
  or     (%rcx),%eax
  mov    D119(%rip),%rcx
  or     (%rcx),%eax
  mov    D149(%rip),%rcx
  or     (%rcx),%eax
  mov    D59(%rip),%rcx
  or     (%rcx),%eax
  mov    D154(%rip),%rcx
  or     (%rcx),%eax
  and    0x4(%rbp),%eax
  je     L14
  mov    D197(%rip),%rax
  cmp    (%rax),%edx
  jg     L122
  mov    %edx,%r14d
  jmp    L14
L29:
  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,%r12d
  jmp    L103
L234:
  lea    0x18(%rsp),%rcx
  lea    0x14(%rsp),%rdx
  mov    0x4(%rbx),%esi
  mov    %r15,%r8
  call   <compute_revents@plt>
  test   %eax,%eax
  je     L184
  mov    %eax,0x8(%rbx)
  add    $0x1,%r12d
L184:
  add    $0x1,%rbp
  add    $0xc,%rbx
  cmp    %rbp,%r13
  jbe    L103
L228:
  mov    (%rbx),%edi
  test   %edi,%edi
  jns    L234
  movl   $0x0,0x8(%rbx)
  jmp    L184
L280:
  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,%r12d
  test   %eax,%eax
  js     L103
  mov    (%rsp),%rbx
  mov    $0x0,%ebp
  mov    $0x0,%r12d
  lea    0x1c(%rsp),%r15
  jmp    L228
L305:
  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 & (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;
}
```