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

```asm
<poll>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x78,%rsp
  mov    %rdi,%r15
  mov    %rsi,%rbx
  mov    %edx,-0x94(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  cmpl   $0x0,D19(%rip)
  je     L285
L478:
  mov    D61(%rip),%rax
  mov    (%rax),%esi
  mov    D19(%rip),%edi
  call   <howmany@plt>
  mov    %eax,%r12d
  mov    %eax,%edi
  call   <alloca@plt>
  mov    %rax,-0x58(%rbp)
  mov    %r12d,%edi
  call   <alloca@plt>
  mov    %rax,%r13
  mov    %rax,-0x60(%rbp)
  mov    %r12d,%edi
  call   <alloca@plt>
  mov    %rax,%r14
  mov    %rax,-0x68(%rbp)
  mov    %r12d,%esi
  mov    -0x58(%rbp),%rdi
  call   <bzero@plt>
  mov    %r12d,%esi
  mov    %r13,%rdi
  call   <bzero@plt>
  mov    %r12d,%esi
  mov    %r14,%rdi
  call   <bzero@plt>
  lea    (%rbx,%rbx,2),%rax
  lea    (%r15,%rax,4),%r13
  cmp    %r13,%r15
  jae    L481
  mov    %r15,%rbx
  mov    $0x0,%r14d
  mov    %r15,-0xa0(%rbp)
  jmp    L230
L285:
  call   <getdtablesize@plt>
  mov    %eax,D124(%rip)
  jmp    L478
L25:
  mov    D61(%rip),%r15
  mov    (%r15),%esi
  call   <roundup@plt>
  mov    %eax,%edi
  mov    %eax,D124(%rip)
  mov    (%r15),%esi
  call   <howmany@plt>
  mov    %eax,%r15d
  mov    %eax,%edi
  call   <alloca@plt>
  mov    %rax,-0x80(%rbp)
  mov    %r15d,%edi
  call   <alloca@plt>
  mov    %rax,-0x88(%rbp)
  mov    %r15d,%edi
  call   <alloca@plt>
  mov    %rax,-0x90(%rbp)
  mov    %r15d,%ecx
  sub    %r12d,%ecx
  movslq %r12d,%rdx
  mov    -0x80(%rbp),%rsi
  mov    %rdx,-0x70(%rbp)
  add    %rdx,%rsi
  mov    %rsi,%rdi
  mov    %ecx,-0x78(%rbp)
  mov    %ecx,%esi
  call   <bzero@plt>
  mov    -0x88(%rbp),%r9
  add    -0x70(%rbp),%r9
  mov    %r9,%rdi
  mov    -0x78(%rbp),%esi
  call   <bzero@plt>
  mov    -0x70(%rbp),%rdx
  add    -0x90(%rbp),%rdx
  mov    %rdx,%rdi
  mov    -0x78(%rbp),%esi
  call   <bzero@plt>
  mov    %r12d,%edx
  mov    -0x58(%rbp),%rsi
  mov    -0x80(%rbp),%rdi
  call   <memcpy@plt>
  mov    %rax,-0x58(%rbp)
  mov    %r12d,%edx
  mov    -0x60(%rbp),%rsi
  mov    -0x88(%rbp),%rdi
  call   <memcpy@plt>
  mov    %rax,-0x60(%rbp)
  mov    %r12d,%edx
  mov    -0x68(%rbp),%rsi
  mov    -0x90(%rbp),%rdi
  call   <memcpy@plt>
  mov    %rax,-0x68(%rbp)
  mov    %r15d,%r12d
  jmp    L55
L202:
  mov    0x4(%rbx),%edi
  mov    -0x58(%rbp),%rsi
  call   <FD_SET@plt>
  jmp    L171
L96:
  mov    0x4(%rbx),%edi
  mov    -0x60(%rbp),%rsi
  call   <FD_SET@plt>
  jmp    L482
L386:
  mov    0x4(%rbx),%edi
  mov    -0x68(%rbp),%rsi
  call   <FD_SET@plt>
  jmp    L116
L100:
  add    $0xc,%rbx
  cmp    %r13,%rbx
  jae    L212
L230:
  movl   $0x0,(%rbx)
  mov    0x4(%rbx),%edi
  test   %edi,%edi
  js     L100
  cmp    D124(%rip),%edi
  jge    L25
L55:
  mov    0x8(%rbx),%eax
  mov    D124(%rip),%rdx
  and    (%rdx),%eax
  jne    L202
L171:
  mov    0x8(%rbx),%eax
  mov    D298(%rip),%rdx
  and    (%rdx),%eax
  jne    L96
L482:
  mov    0x8(%rbx),%eax
  mov    D25(%rip),%rdx
  and    (%rdx),%eax
  jne    L386
L116:
  mov    0x4(%rbx),%edx
  cmp    %r14d,%edx
  jle    L100
  mov    D124(%rip),%rax
  mov    (%rax),%eax
  mov    D298(%rip),%rcx
  or     (%rcx),%eax
  mov    D25(%rip),%rcx
  or     (%rcx),%eax
  and    0x8(%rbx),%eax
  cmovne %edx,%r14d
  jmp    L100
L212:
  mov    -0xa0(%rbp),%r15
L236:
  mov    -0x94(%rbp),%ecx
  movslq %ecx,%rax
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  mov    %ecx,%edx
  sar    $0x1f,%edx
  sub    %edx,%eax
  mov    %eax,-0x48(%rbp)
  imul   $0x3e8,%eax,%eax
  mov    %ecx,%edx
  sub    %eax,%edx
  imul   $0x3e8,%edx,%eax
  mov    %eax,-0x44(%rbp)
  lea    -0x48(%rbp),%rdx
  cmp    $0xffffffff,%ecx
  mov    $0x0,%eax
  cmovne %rdx,%rax
  mov    %rax,-0x70(%rbp)
  lea    -0x40(%rbp),%rax
  mov    %rax,-0x78(%rbp)
L405:
  lea    0x1(%r14),%edi
  mov    -0x70(%rbp),%r8
  mov    -0x68(%rbp),%rcx
  mov    -0x60(%rbp),%rdx
  mov    -0x58(%rbp),%rsi
  call   <select@plt>
  mov    %eax,%r14d
  cmp    $0xffffffff,%eax
  jne    L226
  mov    D76(%rip),%rdx
  mov    D269(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  je     L334
L231:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L213
  mov    %r14d,%eax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L481:
  mov    $0x0,%r14d
  jmp    L236
L334:
  mov    %r12d,%edi
  call   <alloca@plt>
  mov    %rax,-0x80(%rbp)
  mov    %r12d,%edi
  call   <alloca@plt>
  mov    %rax,-0x88(%rbp)
  mov    %r12d,%edi
  call   <alloca@plt>
  mov    %rax,-0x90(%rbp)
  mov    %r12d,%esi
  mov    -0x58(%rbp),%rdi
  call   <bzero@plt>
  mov    %r12d,%esi
  mov    -0x60(%rbp),%rdi
  call   <bzero@plt>
  mov    %r12d,%esi
  mov    -0x68(%rbp),%rdi
  call   <bzero@plt>
  movl   $0x0,-0x40(%rbp)
  movl   $0x0,-0x3c(%rbp)
  cmp    %r13,%r15
  jae    L405
  mov    %r15,%rbx
  jmp    L242
L291:
  mov    0x4(%rbx),%edi
  mov    -0x80(%rbp),%rsi
  call   <FD_SET@plt>
  jmp    L237
L474:
  mov    0x4(%rbx),%edi
  mov    -0x88(%rbp),%rsi
  call   <FD_SET@plt>
  jmp    L270
L284:
  mov    0x4(%rbx),%edi
  mov    -0x90(%rbp),%rsi
  call   <FD_SET@plt>
  jmp    L459
L391:
  mov    0x4(%rbx),%edi
  mov    -0x58(%rbp),%rsi
  call   <FD_SET@plt>
  jmp    L406
L225:
  mov    0x4(%rbx),%edi
  mov    -0x60(%rbp),%rsi
  call   <FD_SET@plt>
  jmp    L427
L485:
  mov    0x4(%rbx),%eax
  cmp    %eax,%r14d
  cmovl  %eax,%r14d
L87:
  add    $0xc,%rbx
  cmp    %r13,%rbx
  jae    L405
L242:
  cmpl   $0xffffffff,0x4(%rbx)
  je     L87
  mov    D124(%rip),%rax
  mov    (%rax),%eax
  mov    D298(%rip),%rdx
  or     (%rdx),%eax
  mov    D25(%rip),%rdx
  or     (%rdx),%eax
  and    0x8(%rbx),%eax
  je     L87
  mov    (%rbx),%eax
  mov    D48(%rip),%rdx
  and    (%rdx),%eax
  jne    L87
  mov    %r12d,%esi
  mov    -0x80(%rbp),%rdi
  call   <bzero@plt>
  mov    %r12d,%esi
  mov    -0x88(%rbp),%rdi
  call   <bzero@plt>
  mov    %r12d,%esi
  mov    -0x90(%rbp),%rdi
  call   <bzero@plt>
  mov    0x8(%rbx),%eax
  mov    D124(%rip),%rdx
  and    (%rdx),%eax
  jne    L291
L237:
  mov    0x8(%rbx),%eax
  mov    D298(%rip),%rdx
  and    (%rdx),%eax
  jne    L474
L270:
  mov    0x8(%rbx),%eax
  mov    D25(%rip),%rdx
  and    (%rdx),%eax
  jne    L284
L459:
  mov    0x4(%rbx),%eax
  lea    0x1(%rax),%edi
  mov    -0x78(%rbp),%r8
  mov    -0x90(%rbp),%rcx
  mov    -0x88(%rbp),%rdx
  mov    -0x80(%rbp),%rsi
  call   <select@plt>
  cmp    $0xffffffff,%eax
  je     L123
  mov    0x8(%rbx),%eax
  mov    D124(%rip),%rdx
  and    (%rdx),%eax
  jne    L391
L406:
  mov    0x8(%rbx),%eax
  mov    D298(%rip),%rdx
  and    (%rdx),%eax
  jne    L225
L427:
  mov    0x8(%rbx),%eax
  mov    D25(%rip),%rdx
  and    (%rdx),%eax
  je     L485
  mov    0x4(%rbx),%edi
  mov    -0x68(%rbp),%rsi
  call   <FD_SET@plt>
  jmp    L485
L123:
  mov    D76(%rip),%rdx
  mov    D269(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  jne    L87
  mov    D48(%rip),%rax
  mov    (%rax),%eax
  or     %eax,(%rbx)
  jmp    L87
L226:
  test   %eax,%eax
  jle    L231
  cmp    %r13,%r15
  jae    L231
  mov    -0x60(%rbp),%rbx
  mov    -0x68(%rbp),%r12
  jmp    L255
L7:
  add    $0xc,%r15
  cmp    %r13,%r15
  jae    L231
L255:
  mov    0x4(%r15),%edi
  test   %edi,%edi
  js     L7
  mov    -0x58(%rbp),%rsi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L197
  mov    D124(%rip),%rax
  mov    (%rax),%eax
  or     %eax,(%r15)
L197:
  mov    0x4(%r15),%edi
  mov    %rbx,%rsi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L319
  mov    D298(%rip),%rax
  mov    (%rax),%eax
  or     %eax,(%r15)
L319:
  mov    0x4(%r15),%edi
  mov    %r12,%rsi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L7
  mov    D25(%rip),%rax
  mov    (%rax),%eax
  or     %eax,(%r15)
  jmp    L7
L213:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int poll(struct pollfd *fds, nfds_t nfds, int timeout) {
  static int max_fd_size;
  struct timeval tv;
  fd_set *rset, *wset, *xset;
  struct pollfd *f;
  int ready;
  int maxfd = 0;
  int bytes;
  if (!max_fd_size)
    max_fd_size = getdtablesize();
  bytes = howmany(max_fd_size, __NFDBITS);
  rset = alloca(bytes);
  wset = alloca(bytes);
  xset = alloca(bytes);
  bzero(rset, bytes);
  bzero(wset, bytes);
  bzero(xset, bytes);
  for (f = fds; f < &fds[nfds]; ++f) {
    f->revents = 0;
    if (f->fd >= 0) {
      if (f->fd >= max_fd_size) {
        fd_set *nrset, *nwset, *nxset;
        int nbytes;
        max_fd_size = roundup(f->fd, __NFDBITS);
        nbytes = howmany(max_fd_size, __NFDBITS);
        nrset = alloca(nbytes);
        nwset = alloca(nbytes);
        nxset = alloca(nbytes);
        bzero((char *)nrset + bytes, nbytes - bytes);
        bzero((char *)nwset + bytes, nbytes - bytes);
        bzero((char *)nxset + bytes, nbytes - bytes);
        rset = memcpy(nrset, rset, bytes);
        wset = memcpy(nwset, wset, bytes);
        xset = memcpy(nxset, xset, bytes);
        bytes = nbytes;
      }
      if (f->events & POLLIN)
        FD_SET(f->fd, rset);
      if (f->events & POLLOUT)
        FD_SET(f->fd, wset);
      if (f->events & POLLPRI)
        FD_SET(f->fd, xset);
      if (f->fd > maxfd && (f->events & (POLLIN | POLLOUT | POLLPRI)))
        maxfd = f->fd;
    }
  }
  tv.tv_sec = timeout / 1000;
  tv.tv_usec = (timeout % 1000) * 1000;
  while (1) {
    ready = select(maxfd + 1, rset, wset, xset, timeout == -1 ? NULL : &tv);
    if (ready == -1 && errno == EBADF) {
      fd_set *sngl_rset = alloca(bytes);
      fd_set *sngl_wset = alloca(bytes);
      fd_set *sngl_xset = alloca(bytes);
      struct timeval sngl_tv;
      bzero(rset, bytes);
      bzero(wset, bytes);
      bzero(xset, bytes);
      sngl_tv.tv_sec = 0;
      sngl_tv.tv_usec = 0;
      maxfd = -1;
      ready = 0;
      for (f = fds; f < &fds[nfds]; ++f)
        if (f->fd != -1 && (f->events & (POLLIN | POLLOUT | POLLPRI)) && (f->revents & POLLNVAL) == 0) {
          int n;
          bzero(sngl_rset, bytes);
          bzero(sngl_wset, bytes);
          bzero(sngl_xset, bytes);
          if (f->events & POLLIN)
            FD_SET(f->fd, sngl_rset);
          if (f->events & POLLOUT)
            FD_SET(f->fd, sngl_wset);
          if (f->events & POLLPRI)
            FD_SET(f->fd, sngl_xset);
          n = select(f->fd + 1, sngl_rset, sngl_wset, sngl_xset, &sngl_tv);
          if (n != -1) {
            if (f->events & POLLIN)
              FD_SET(f->fd, rset);
            if (f->events & POLLOUT)
              FD_SET(f->fd, wset);
            if (f->events & POLLPRI)
              FD_SET(f->fd, xset);
            if (f->fd > maxfd)
              maxfd = f->fd;
            if (n > 0)
              ++ready;
          } else if (errno == EBADF)
            f->revents |= POLLNVAL;
        }
      continue;
    }
    break;
  }
  if (ready > 0)
    for (f = fds; f < &fds[nfds]; ++f) {
      if (f->fd >= 0) {
        if (FD_ISSET(f->fd, rset))
          f->revents |= POLLIN;
        if (FD_ISSET(f->fd, wset))
          f->revents |= POLLOUT;
        if (FD_ISSET(f->fd, xset))
          f->revents |= POLLPRI;
      }
    }
  return ready;
}
```