#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct timeval {
  int tv_sec;
  int tv_usec;
};
struct pollfd {
  int revents;
  int fd;
  int events;
};
typedef size_t nfds_t;
typedef char fd_set;

/* Variables and functions */
scalar_t__ EBADF;
scalar_t__ FD_ISSET(int, char *);
int /*<<< orphan*/ FD_SET(int, char *);
int POLLIN;
int POLLNVAL;
int POLLOUT;
int POLLPRI;
int /*<<< orphan*/ __NFDBITS;
char *alloca(int);
scalar_t__ errno;
int getdtablesize();
int howmany(int, int /*<<< orphan*/);
char *memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int roundup(int, int /*<<< orphan*/);
int select(int, char *, char *, char *, struct timeval *);
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);
  memset(rset, 0, bytes);
  memset(wset, 0, bytes);
  memset(xset, 0, 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);
        memset((char *)nrset + bytes, 0, nbytes - bytes);
        memset((char *)nwset + bytes, 0, nbytes - bytes);
        memset((char *)nxset + bytes, 0, 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;
      memset(rset, 0, bytes);
      memset(wset, 0, bytes);
      memset(xset, 0, 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;
          memset(sngl_rset, 0, bytes);
          memset(sngl_wset, 0, bytes);
          memset(sngl_xset, 0, 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;
}


x86 assembly (clang, -O0):
<poll>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x48(%rbp)
cmpl   $0x0,0x2ebc(%rip)
jne    11c7 <poll+0x37>
mov    $0x0,%al
call   10b0 <getdtablesize@plt>
mov    %eax,0x2ea9(%rip)
mov    0x2ea3(%rip),%edi
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
call   1060 <howmany@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%edi
call   1070 <alloca@plt>
mov    %rax,-0x28(%rbp)
mov    -0x4c(%rbp),%edi
call   1070 <alloca@plt>
mov    %rax,-0x30(%rbp)
mov    -0x4c(%rbp),%edi
call   1070 <alloca@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x4c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x30(%rbp),%rdi
mov    -0x4c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x38(%rbp),%rdi
mov    -0x4c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rcx
imul   $0xc,-0x10(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    1435 <poll+0x2a5>
mov    -0x40(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x40(%rbp),%rax
cmpl   $0x0,0x4(%rax)
jl     141f <poll+0x28f>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%eax
cmp    0x2dfe(%rip),%eax
jl     1358 <poll+0x1c8>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    0x2d22(%rip),%rax
mov    (%rax),%esi
call   1030 <roundup@plt>
mov    %eax,0x2ddd(%rip)
mov    0x2dd7(%rip),%edi
mov    0x2d08(%rip),%rax
mov    (%rax),%esi
call   1060 <howmany@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%edi
call   1070 <alloca@plt>
mov    %rax,-0x58(%rbp)
mov    -0x6c(%rbp),%edi
call   1070 <alloca@plt>
mov    %rax,-0x60(%rbp)
mov    -0x6c(%rbp),%edi
call   1070 <alloca@plt>
mov    %rax,-0x68(%rbp)
mov    -0x58(%rbp),%rdi
movslq -0x4c(%rbp),%rax
add    %rax,%rdi
mov    -0x6c(%rbp),%edx
sub    -0x4c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x60(%rbp),%rdi
movslq -0x4c(%rbp),%rax
add    %rax,%rdi
mov    -0x6c(%rbp),%edx
sub    -0x4c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x68(%rbp),%rdi
movslq -0x4c(%rbp),%rax
add    %rax,%rdi
mov    -0x6c(%rbp),%edx
sub    -0x4c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x4c(%rbp),%edx
call   1080 <memcpy@plt>
mov    %rax,-0x28(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x4c(%rbp),%edx
call   1080 <memcpy@plt>
mov    %rax,-0x30(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x4c(%rbp),%edx
call   1080 <memcpy@plt>
mov    %rax,-0x38(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x2c6a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1381 <poll+0x1f1>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x28(%rbp),%rsi
call   10a0 <FD_SET@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x2c69(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     13aa <poll+0x21a>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x30(%rbp),%rsi
call   10a0 <FD_SET@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x2c30(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     13d3 <poll+0x243>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x38(%rbp),%rsi
call   10a0 <FD_SET@plt>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%eax
cmp    -0x48(%rbp),%eax
jle    141a <poll+0x28a>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x2bdf(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2bfe(%rip),%rdx
or     (%rdx),%ecx
mov    0x2be5(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     141a <poll+0x28a>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x48(%rbp)
jmp    141f <poll+0x28f>
jmp    1424 <poll+0x294>
mov    -0x40(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x40(%rbp)
jmp    1234 <poll+0xa4>
mov    -0x14(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
imul   $0x3e8,%edx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0xa0(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    149c <poll+0x30c>
xor    %eax,%eax
mov    %rax,-0xc0(%rbp)
jmp    14ac <poll+0x31c>
lea    -0x20(%rbp),%rax
mov    %rax,-0xc0(%rbp)
jmp    14ac <poll+0x31c>
mov    -0xa0(%rbp),%rcx
mov    -0xa8(%rbp),%rdx
mov    -0xb0(%rbp),%rsi
mov    -0xb4(%rbp),%edi
mov    -0xc0(%rbp),%r8
call   1090 <select@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jne    17c4 <poll+0x634>
mov    0x2ad9(%rip),%rax
mov    (%rax),%rax
mov    0x2ac7(%rip),%rcx
cmp    (%rcx),%rax
jne    17c4 <poll+0x634>
mov    -0x4c(%rbp),%edi
call   1070 <alloca@plt>
mov    %rax,-0x78(%rbp)
mov    -0x4c(%rbp),%edi
call   1070 <alloca@plt>
mov    %rax,-0x80(%rbp)
mov    -0x4c(%rbp),%edi
call   1070 <alloca@plt>
mov    %rax,-0x88(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x4c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x30(%rbp),%rdi
mov    -0x4c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x38(%rbp),%rdi
mov    -0x4c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0x0,-0x90(%rbp)
movl   $0x0,-0x8c(%rbp)
movl   $0xffffffff,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rcx
imul   $0xc,-0x10(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    17bf <poll+0x62f>
mov    -0x40(%rbp),%rax
cmpl   $0xffffffff,0x4(%rax)
je     17a9 <poll+0x619>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x2a26(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2a45(%rip),%rdx
or     (%rdx),%ecx
mov    0x2a2c(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     17a9 <poll+0x619>
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
mov    0x2a02(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    17a9 <poll+0x619>
mov    -0x78(%rbp),%rdi
mov    -0x4c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x80(%rbp),%rdi
mov    -0x4c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x88(%rbp),%rdi
mov    -0x4c(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x29b4(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1637 <poll+0x4a7>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x78(%rbp),%rsi
call   10a0 <FD_SET@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x29b3(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1660 <poll+0x4d0>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x80(%rbp),%rsi
call   10a0 <FD_SET@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x297a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     168c <poll+0x4fc>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x88(%rbp),%rsi
call   10a0 <FD_SET@plt>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
add    $0x1,%edi
mov    -0x78(%rbp),%rsi
mov    -0x80(%rbp),%rdx
mov    -0x88(%rbp),%rcx
lea    -0x90(%rbp),%r8
call   1090 <select@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0xffffffff,-0x94(%rbp)
je     1774 <poll+0x5e4>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x28fe(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     16ed <poll+0x55d>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x28(%rbp),%rsi
call   10a0 <FD_SET@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x28fd(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1716 <poll+0x586>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x30(%rbp),%rsi
call   10a0 <FD_SET@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x28c4(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     173f <poll+0x5af>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x38(%rbp),%rsi
call   10a0 <FD_SET@plt>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%eax
cmp    -0x48(%rbp),%eax
jle    1759 <poll+0x5c9>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x94(%rbp)
jle    176f <poll+0x5df>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    17a4 <poll+0x614>
mov    0x2845(%rip),%rax
mov    (%rax),%rax
mov    0x2833(%rip),%rcx
cmp    (%rcx),%rax
jne    179f <poll+0x60f>
mov    0x2843(%rip),%rax
mov    (%rax),%ecx
mov    -0x40(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
jmp    17a4 <poll+0x614>
jmp    17a9 <poll+0x619>
jmp    17ae <poll+0x61e>
mov    -0x40(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x40(%rbp)
jmp    1575 <poll+0x3e5>
jmp    1457 <poll+0x2c7>
jmp    17c9 <poll+0x639>
cmpl   $0x0,-0x44(%rbp)
jle    18a3 <poll+0x713>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rcx
imul   $0xc,-0x10(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    189e <poll+0x70e>
mov    -0x40(%rbp),%rax
cmpl   $0x0,0x4(%rax)
jl     1888 <poll+0x6f8>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x28(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     182d <poll+0x69d>
mov    0x27ad(%rip),%rax
mov    (%rax),%ecx
mov    -0x40(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x30(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1858 <poll+0x6c8>
mov    0x27aa(%rip),%rax
mov    (%rax),%ecx
mov    -0x40(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x38(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1883 <poll+0x6f3>
mov    0x276f(%rip),%rax
mov    (%rax),%ecx
mov    -0x40(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
jmp    1888 <poll+0x6f8>
jmp    188d <poll+0x6fd>
mov    -0x40(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x40(%rbp)
jmp    17db <poll+0x64b>
jmp    18a3 <poll+0x713>
mov    -0x44(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<poll>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %edx,0x44(%rsp)
mov    %rsi,0x30(%rsp)
mov    %rdi,%rbp
mov    0x2ec0(%rip),%edi
test   %edi,%edi
jne    11c3 <poll+0x33>
xor    %eax,%eax
call   10b0 <getdtablesize@plt>
mov    %eax,%edi
mov    %eax,0x2ead(%rip)
mov    0x2dde(%rip),%rax
mov    (%rax),%esi
call   1060 <howmany@plt>
mov    %eax,%r13d
mov    %eax,%edi
call   1070 <alloca@plt>
mov    %rax,%rbx
mov    %r13d,%edi
call   1070 <alloca@plt>
mov    %rax,%r14
mov    %r13d,%edi
call   1070 <alloca@plt>
mov    %rax,%r12
xor    %r15d,%r15d
mov    %rbx,0x18(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r13d,%edx
call   1050 <memset@plt>
mov    %r14,0x10(%rsp)
mov    %r14,%rdi
xor    %esi,%esi
mov    %r13d,%edx
call   1050 <memset@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    %r13d,0xc(%rsp)
mov    %r13d,%edx
call   1050 <memset@plt>
mov    0x30(%rsp),%rcx
lea    (%rcx,%rcx,2),%rax
lea    0x0(,%rax,4),%rax
add    %rbp,%rax
test   %rcx,%rcx
mov    %rbp,0x48(%rsp)
mov    %rax,0x20(%rsp)
jle    13ea <poll+0x25a>
xor    %r15d,%r15d
mov    0x2d72(%rip),%rbx
mov    0x2d93(%rip),%r13
mov    %rbp,%r14
jmp    1282 <poll+0xf2>
nopw   0x0(%rax,%rax,1)
mov    0x20(%rsp),%rax
add    $0xc,%r14
cmp    %rax,%r14
jae    13ea <poll+0x25a>
movl   $0x0,(%r14)
mov    0x4(%r14),%edi
test   %edi,%edi
js     1275 <poll+0xe5>
cmp    0x2dd9(%rip),%edi
jl     1378 <poll+0x1e8>
mov    0x2d04(%rip),%rbx
mov    %r12,0x28(%rsp)
mov    (%rbx),%esi
call   1030 <roundup@plt>
mov    %eax,0x2dba(%rip)
mov    (%rbx),%esi
mov    %eax,%edi
call   1060 <howmany@plt>
mov    %r15d,0x38(%rsp)
mov    %eax,%r13d
mov    %eax,%edi
call   1070 <alloca@plt>
mov    %rax,%rbp
mov    %rax,0x58(%rsp)
mov    %r13d,%edi
call   1070 <alloca@plt>
mov    %rax,%r12
mov    %r13d,%edi
call   1070 <alloca@plt>
mov    %rax,%r15
movslq 0xc(%rsp),%rbx
lea    (%rbx,%rbp,1),%rdi
mov    %r13d,%ebp
sub    %ebx,%ebp
xor    %esi,%esi
mov    %ebp,%edx
call   1050 <memset@plt>
lea    (%r12,%rbx,1),%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
add    %r15,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1050 <memset@plt>
mov    0x58(%rsp),%rdi
mov    0x48(%rsp),%rbp
mov    0x18(%rsp),%rsi
mov    %ebx,%edx
call   1080 <memcpy@plt>
mov    %rax,0x18(%rsp)
mov    %r12,%rdi
mov    0x10(%rsp),%rsi
mov    %ebx,%edx
call   1080 <memcpy@plt>
mov    %rax,0x10(%rsp)
mov    %r15,%rdi
mov    0x28(%rsp),%rsi
mov    %ebx,%edx
call   1080 <memcpy@plt>
mov    %rax,%r12
mov    %r13d,0xc(%rsp)
mov    0x2c8c(%rip),%r13
mov    0x2c5d(%rip),%rbx
mov    0x38(%rsp),%r15d
mov    0x8(%r14),%eax
test   %eax,(%rbx)
je     1392 <poll+0x202>
mov    0x4(%r14),%edi
mov    0x18(%rsp),%rsi
call   10a0 <FD_SET@plt>
mov    0x8(%r14),%eax
test   %eax,0x0(%r13)
je     13aa <poll+0x21a>
mov    0x4(%r14),%edi
mov    0x10(%rsp),%rsi
call   10a0 <FD_SET@plt>
mov    0x8(%r14),%eax
mov    0x2c37(%rip),%rcx
test   %eax,(%rcx)
je     13c1 <poll+0x231>
mov    0x4(%r14),%edi
mov    %r12,%rsi
call   10a0 <FD_SET@plt>
mov    0x4(%r14),%eax
cmp    %r15d,%eax
jle    1270 <poll+0xe0>
mov    0x0(%r13),%ecx
or     (%rbx),%ecx
mov    0x2c0d(%rip),%rdx
or     (%rdx),%ecx
test   %ecx,0x8(%r14)
cmovne %eax,%r15d
jmp    1270 <poll+0xe0>
movslq 0x44(%rsp),%rax
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
mov    %ecx,0x50(%rsp)
imul   $0x3e8,%ecx,%ecx
mov    %eax,%edx
sub    %ecx,%edx
imul   $0x3e8,%edx,%ecx
mov    %ecx,0x54(%rsp)
xor    %edx,%edx
cmp    $0xffffffff,%eax
lea    0x50(%rsp),%rbx
cmove  %rdx,%rbx
add    $0x1,%r15d
mov    %r15d,%edi
mov    0x18(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    %r12,0x28(%rsp)
mov    %r12,%rcx
mov    %rbx,%r8
call   1090 <select@plt>
mov    %eax,%r13d
cmp    $0xffffffff,%eax
je     14f1 <poll+0x361>
test   %r13d,%r13d
jle    1734 <poll+0x5a4>
cmpq   $0x0,0x30(%rsp)
jle    1734 <poll+0x5a4>
mov    0x2b76(%rip),%r14
mov    0x2b7f(%rip),%r15
mov    0x2b50(%rip),%r12
mov    0x20(%rsp),%rcx
jmp    149d <poll+0x30d>
nopw   0x0(%rax,%rax,1)
add    $0xc,%rbp
cmp    %rcx,%rbp
jae    1734 <poll+0x5a4>
mov    0x4(%rbp),%edi
test   %edi,%edi
js     1490 <poll+0x300>
mov    0x18(%rsp),%rsi
call   1040 <FD_ISSET@plt>
test   %rax,%rax
je     14ba <poll+0x32a>
mov    (%r12),%eax
or     %eax,0x0(%rbp)
mov    0x4(%rbp),%edi
mov    0x10(%rsp),%rsi
call   1040 <FD_ISSET@plt>
test   %rax,%rax
je     14d2 <poll+0x342>
mov    (%r15),%eax
or     %eax,0x0(%rbp)
mov    0x4(%rbp),%edi
mov    0x28(%rsp),%rsi
call   1040 <FD_ISSET@plt>
test   %rax,%rax
mov    0x20(%rsp),%rcx
je     1490 <poll+0x300>
mov    (%r14),%eax
or     %eax,0x0(%rbp)
jmp    1490 <poll+0x300>
mov    %rbx,0x38(%rsp)
jmp    1534 <poll+0x3a4>
nopl   0x0(%rax,%rax,1)
mov    $0xffffffff,%r12d
add    $0x1,%r12d
mov    %r12d,%edi
mov    0x18(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    0x28(%rsp),%rcx
mov    0x38(%rsp),%r8
call   1090 <select@plt>
cmp    $0xffffffff,%eax
mov    0x48(%rsp),%rbp
jne    1746 <poll+0x5b6>
mov    0x2a85(%rip),%rax
mov    (%rax),%rax
mov    0x2a73(%rip),%rcx
cmp    (%rcx),%rax
jne    172e <poll+0x59e>
mov    0xc(%rsp),%r12d
mov    %r12d,%edi
call   1070 <alloca@plt>
mov    %rax,%r13
mov    %r12d,%edi
call   1070 <alloca@plt>
mov    %rax,%r14
mov    %r12d,%edi
call   1070 <alloca@plt>
mov    %rax,%r15
mov    0x18(%rsp),%rdi
xor    %esi,%esi
mov    %r12d,%edx
call   1050 <memset@plt>
mov    0x10(%rsp),%rdi
xor    %esi,%esi
mov    %r12d,%edx
call   1050 <memset@plt>
mov    0x28(%rsp),%rdi
xor    %esi,%esi
mov    %r12d,%edx
call   1050 <memset@plt>
movq   $0x0,0x60(%rsp)
cmpq   $0x0,0x30(%rsp)
jle    1500 <poll+0x370>
mov    $0xffffffff,%r12d
mov    0x20(%rsp),%rcx
mov    0x2a08(%rip),%rbx
jmp    15ed <poll+0x45d>
mov    0x4(%rbp),%eax
cmp    %r12d,%eax
cmovg  %eax,%r12d
mov    0x20(%rsp),%rcx
nopl   0x0(%rax)
add    $0xc,%rbp
cmp    %rcx,%rbp
jae    1506 <poll+0x376>
cmpl   $0xffffffff,0x4(%rbp)
je     15e0 <poll+0x450>
mov    0x29fe(%rip),%rax
mov    (%rax),%eax
or     (%rbx),%eax
mov    0x29e3(%rip),%rdx
or     (%rdx),%eax
test   %eax,0x8(%rbp)
je     15e0 <poll+0x450>
mov    0x29c5(%rip),%rax
mov    (%rax),%eax
test   %eax,0x0(%rbp)
jne    15e0 <poll+0x450>
mov    %r13,%rdi
xor    %esi,%esi
mov    0xc(%rsp),%ebx
mov    %ebx,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    %ebx,%edx
mov    0x298c(%rip),%rbx
call   1050 <memset@plt>
mov    0x8(%rbp),%eax
test   %eax,(%rbx)
je     165e <poll+0x4ce>
mov    0x4(%rbp),%edi
mov    %r13,%rsi
call   10a0 <FD_SET@plt>
mov    0x8(%rbp),%eax
mov    0x2993(%rip),%rcx
test   %eax,(%rcx)
je     1677 <poll+0x4e7>
mov    0x4(%rbp),%edi
mov    %r14,%rsi
call   10a0 <FD_SET@plt>
mov    0x8(%rbp),%eax
mov    0x296a(%rip),%rcx
test   %eax,(%rcx)
je     168d <poll+0x4fd>
mov    0x4(%rbp),%edi
mov    %r15,%rsi
call   10a0 <FD_SET@plt>
mov    0x4(%rbp),%edi
add    $0x1,%edi
mov    %r13,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
lea    0x60(%rsp),%r8
call   1090 <select@plt>
cmp    $0xffffffff,%eax
je     16fe <poll+0x56e>
mov    0x8(%rbp),%eax
test   %eax,(%rbx)
je     16c2 <poll+0x532>
mov    0x4(%rbp),%edi
mov    0x18(%rsp),%rsi
call   10a0 <FD_SET@plt>
mov    0x8(%rbp),%eax
mov    0x292f(%rip),%rcx
test   %eax,(%rcx)
je     16dd <poll+0x54d>
mov    0x4(%rbp),%edi
mov    0x10(%rsp),%rsi
call   10a0 <FD_SET@plt>
mov    0x8(%rbp),%eax
mov    0x2904(%rip),%rcx
test   %eax,(%rcx)
je     15ca <poll+0x43a>
mov    0x4(%rbp),%edi
mov    0x28(%rsp),%rsi
call   10a0 <FD_SET@plt>
jmp    15ca <poll+0x43a>
mov    0x28bb(%rip),%rax
mov    (%rax),%rax
mov    0x28a9(%rip),%rcx
cmp    (%rcx),%rax
mov    0x20(%rsp),%rcx
jne    15e0 <poll+0x450>
mov    0x28b4(%rip),%rax
mov    (%rax),%eax
or     %eax,0x0(%rbp)
jmp    15e0 <poll+0x450>
mov    $0xffffffff,%r13d
mov    %r13d,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r13d
test   %r13d,%r13d
jg     145f <poll+0x2cf>
jmp    1734 <poll+0x5a4>

LLVM IR (-O0):
%struct.pollfd = type { i32, i32, i32 }
%struct.timeval = type { i32, i32 }
@poll.max_fd_size = internal global i32 0
@__NFDBITS = global i32 0
@POLLIN = global i32 0
@POLLOUT = global i32 0
@POLLPRI = global i32 0
@errno = global i64 0
@EBADF = global i64 0
@POLLNVAL = global i32 0
define i32 @poll(%struct.pollfd* %0, i64 %1, i32 %2) {
%4 = alloca %struct.pollfd*
%5 = alloca i64
%6 = alloca i32
%7 = alloca %struct.timeval
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca %struct.pollfd*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca %struct.timeval
%23 = alloca i32
store %struct.pollfd* %0, %struct.pollfd** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
store i32 0, i32* %13
%24 = load i32, i32* @poll.max_fd_size
%25 = icmp ne i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %3
%27 = call i32 (...) @getdtablesize()
store i32 %27, i32* @poll.max_fd_size
br label %28
28: ; preds = %26, %3
%29 = load i32, i32* @poll.max_fd_size
%30 = load i32, i32* @__NFDBITS
%31 = call i32 @howmany(i32 %29, i32 %30)
store i32 %31, i32* %14
%32 = load i32, i32* %14
%33 = call i8* @alloca(i32 %32)
store i8* %33, i8** %8
%34 = load i32, i32* %14
%35 = call i8* @alloca(i32 %34)
store i8* %35, i8** %9
%36 = load i32, i32* %14
%37 = call i8* @alloca(i32 %36)
store i8* %37, i8** %10
%38 = load i8*, i8** %8
%39 = load i32, i32* %14
%40 = call i32 @memset(i8* %38, i32 0, i32 %39)
%41 = load i8*, i8** %9
%42 = load i32, i32* %14
%43 = call i32 @memset(i8* %41, i32 0, i32 %42)
%44 = load i8*, i8** %10
%45 = load i32, i32* %14
%46 = call i32 @memset(i8* %44, i32 0, i32 %45)
%47 = load %struct.pollfd*, %struct.pollfd** %4
store %struct.pollfd* %47, %struct.pollfd** %11
br label %48
48: ; preds = %181, %28
%49 = load %struct.pollfd*, %struct.pollfd** %11
%50 = load %struct.pollfd*, %struct.pollfd** %4
%51 = load i64, i64* %5
%52 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %50, i64 %51
%53 = icmp ult %struct.pollfd* %49, %52
br i1 %53, label %54, label %184
54: ; preds = %48
%55 = load %struct.pollfd*, %struct.pollfd** %11
%56 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %55, i32 0, i32 0
store i32 0, i32* %56
%57 = load %struct.pollfd*, %struct.pollfd** %11
%58 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %57, i32 0, i32 1
%59 = load i32, i32* %58
%60 = icmp sge i32 %59, 0
br i1 %60, label %61, label %180
61: ; preds = %54
%62 = load %struct.pollfd*, %struct.pollfd** %11
%63 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %62, i32 0, i32 1
%64 = load i32, i32* %63
%65 = load i32, i32* @poll.max_fd_size
%66 = icmp sge i32 %64, %65
br i1 %66, label %67, label %119
67: ; preds = %61
%68 = load %struct.pollfd*, %struct.pollfd** %11
%69 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %68, i32 0, i32 1
%70 = load i32, i32* %69
%71 = load i32, i32* @__NFDBITS
%72 = call i32 @roundup(i32 %70, i32 %71)
store i32 %72, i32* @poll.max_fd_size
%73 = load i32, i32* @poll.max_fd_size
%74 = load i32, i32* @__NFDBITS
%75 = call i32 @howmany(i32 %73, i32 %74)
store i32 %75, i32* %18
%76 = load i32, i32* %18
%77 = call i8* @alloca(i32 %76)
store i8* %77, i8** %15
%78 = load i32, i32* %18
%79 = call i8* @alloca(i32 %78)
store i8* %79, i8** %16
%80 = load i32, i32* %18
%81 = call i8* @alloca(i32 %80)
store i8* %81, i8** %17
%82 = load i8*, i8** %15
%83 = load i32, i32* %14
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %82, i64 %84
%86 = load i32, i32* %18
%87 = load i32, i32* %14
%88 = sub nsw i32 %86, %87
%89 = call i32 @memset(i8* %85, i32 0, i32 %88)
%90 = load i8*, i8** %16
%91 = load i32, i32* %14
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %90, i64 %92
%94 = load i32, i32* %18
%95 = load i32, i32* %14
%96 = sub nsw i32 %94, %95
%97 = call i32 @memset(i8* %93, i32 0, i32 %96)
%98 = load i8*, i8** %17
%99 = load i32, i32* %14
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %98, i64 %100
%102 = load i32, i32* %18
%103 = load i32, i32* %14
%104 = sub nsw i32 %102, %103
%105 = call i32 @memset(i8* %101, i32 0, i32 %104)
%106 = load i8*, i8** %15
%107 = load i8*, i8** %8
%108 = load i32, i32* %14
%109 = call i8* @memcpy(i8* %106, i8* %107, i32 %108)
store i8* %109, i8** %8
%110 = load i8*, i8** %16
%111 = load i8*, i8** %9
%112 = load i32, i32* %14
%113 = call i8* @memcpy(i8* %110, i8* %111, i32 %112)
store i8* %113, i8** %9
%114 = load i8*, i8** %17
%115 = load i8*, i8** %10
%116 = load i32, i32* %14
%117 = call i8* @memcpy(i8* %114, i8* %115, i32 %116)
store i8* %117, i8** %10
%118 = load i32, i32* %18
store i32 %118, i32* %14
br label %119
119: ; preds = %67, %61
%120 = load %struct.pollfd*, %struct.pollfd** %11
%121 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %120, i32 0, i32 2
%122 = load i32, i32* %121
%123 = load i32, i32* @POLLIN
%124 = and i32 %122, %123
%125 = icmp ne i32 %124, 0
br i1 %125, label %126, label %132
126: ; preds = %119
%127 = load %struct.pollfd*, %struct.pollfd** %11
%128 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %127, i32 0, i32 1
%129 = load i32, i32* %128
%130 = load i8*, i8** %8
%131 = call i32 @FD_SET(i32 %129, i8* %130)
br label %132
132: ; preds = %126, %119
%133 = load %struct.pollfd*, %struct.pollfd** %11
%134 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %133, i32 0, i32 2
%135 = load i32, i32* %134
%136 = load i32, i32* @POLLOUT
%137 = and i32 %135, %136
%138 = icmp ne i32 %137, 0
br i1 %138, label %139, label %145
139: ; preds = %132
%140 = load %struct.pollfd*, %struct.pollfd** %11
%141 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %140, i32 0, i32 1
%142 = load i32, i32* %141
%143 = load i8*, i8** %9
%144 = call i32 @FD_SET(i32 %142, i8* %143)
br label %145
145: ; preds = %139, %132
%146 = load %struct.pollfd*, %struct.pollfd** %11
%147 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %146, i32 0, i32 2
%148 = load i32, i32* %147
%149 = load i32, i32* @POLLPRI
%150 = and i32 %148, %149
%151 = icmp ne i32 %150, 0
br i1 %151, label %152, label %158
152: ; preds = %145
%153 = load %struct.pollfd*, %struct.pollfd** %11
%154 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %153, i32 0, i32 1
%155 = load i32, i32* %154
%156 = load i8*, i8** %10
%157 = call i32 @FD_SET(i32 %155, i8* %156)
br label %158
158: ; preds = %152, %145
%159 = load %struct.pollfd*, %struct.pollfd** %11
%160 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %159, i32 0, i32 1
%161 = load i32, i32* %160
%162 = load i32, i32* %13
%163 = icmp sgt i32 %161, %162
br i1 %163, label %164, label %179
164: ; preds = %158
%165 = load %struct.pollfd*, %struct.pollfd** %11
%166 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %165, i32 0, i32 2
%167 = load i32, i32* %166
%168 = load i32, i32* @POLLIN
%169 = load i32, i32* @POLLOUT
%170 = or i32 %168, %169
%171 = load i32, i32* @POLLPRI
%172 = or i32 %170, %171
%173 = and i32 %167, %172
%174 = icmp ne i32 %173, 0
br i1 %174, label %175, label %179
175: ; preds = %164
%176 = load %struct.pollfd*, %struct.pollfd** %11
%177 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %176, i32 0, i32 1
%178 = load i32, i32* %177
store i32 %178, i32* %13
br label %179
179: ; preds = %175, %164, %158
br label %180
180: ; preds = %179, %54
br label %181
181: ; preds = %180
%182 = load %struct.pollfd*, %struct.pollfd** %11
%183 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %182, i32 1
store %struct.pollfd* %183, %struct.pollfd** %11
br label %48
184: ; preds = %48
%185 = load i32, i32* %6
%186 = sdiv i32 %185, 1000
%187 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
store i32 %186, i32* %187
%188 = load i32, i32* %6
%189 = srem i32 %188, 1000
%190 = mul nsw i32 %189, 1000
%191 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
store i32 %190, i32* %191
br label %192
192: ; preds = %184, %390
%193 = load i32, i32* %13
%194 = add nsw i32 %193, 1
%195 = load i8*, i8** %8
%196 = load i8*, i8** %9
%197 = load i8*, i8** %10
%198 = load i32, i32* %6
%199 = icmp eq i32 %198, -1
br i1 %199, label %200, label %201
200: ; preds = %192
br label %202
201: ; preds = %192
br label %202
202: ; preds = %201, %200
%203 = phi %struct.timeval* [ null, %200 ], [ %7, %201 ]
%204 = call i32 @select(i32 %194, i8* %195, i8* %196, i8* %197, %struct.timeval* %203)
store i32 %204, i32* %12
%205 = load i32, i32* %12
%206 = icmp eq i32 %205, -1
br i1 %206, label %207, label %391
207: ; preds = %202
%208 = load i64, i64* @errno
%209 = load i64, i64* @EBADF
%210 = icmp eq i64 %208, %209
br i1 %210, label %211, label %391
211: ; preds = %207
%212 = load i32, i32* %14
%213 = call i8* @alloca(i32 %212)
store i8* %213, i8** %19
%214 = load i32, i32* %14
%215 = call i8* @alloca(i32 %214)
store i8* %215, i8** %20
%216 = load i32, i32* %14
%217 = call i8* @alloca(i32 %216)
store i8* %217, i8** %21
%218 = load i8*, i8** %8
%219 = load i32, i32* %14
%220 = call i32 @memset(i8* %218, i32 0, i32 %219)
%221 = load i8*, i8** %9
%222 = load i32, i32* %14
%223 = call i32 @memset(i8* %221, i32 0, i32 %222)
%224 = load i8*, i8** %10
%225 = load i32, i32* %14
%226 = call i32 @memset(i8* %224, i32 0, i32 %225)
%227 = getelementptr inbounds %struct.timeval, %struct.timeval* %22, i32 0, i32 0
store i32 0, i32* %227
%228 = getelementptr inbounds %struct.timeval, %struct.timeval* %22, i32 0, i32 1
store i32 0, i32* %228
store i32 -1, i32* %13
store i32 0, i32* %12
%229 = load %struct.pollfd*, %struct.pollfd** %4
store %struct.pollfd* %229, %struct.pollfd** %11
br label %230
230: ; preds = %387, %211
%231 = load %struct.pollfd*, %struct.pollfd** %11
%232 = load %struct.pollfd*, %struct.pollfd** %4
%233 = load i64, i64* %5
%234 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %232, i64 %233
%235 = icmp ult %struct.pollfd* %231, %234
br i1 %235, label %236, label %390
236: ; preds = %230
%237 = load %struct.pollfd*, %struct.pollfd** %11
%238 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %237, i32 0, i32 1
%239 = load i32, i32* %238
%240 = icmp ne i32 %239, -1
br i1 %240, label %241, label %386
241: ; preds = %236
%242 = load %struct.pollfd*, %struct.pollfd** %11
%243 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %242, i32 0, i32 2
%244 = load i32, i32* %243
%245 = load i32, i32* @POLLIN
%246 = load i32, i32* @POLLOUT
%247 = or i32 %245, %246
%248 = load i32, i32* @POLLPRI
%249 = or i32 %247, %248
%250 = and i32 %244, %249
%251 = icmp ne i32 %250, 0
br i1 %251, label %252, label %386
252: ; preds = %241
%253 = load %struct.pollfd*, %struct.pollfd** %11
%254 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %253, i32 0, i32 0
%255 = load i32, i32* %254
%256 = load i32, i32* @POLLNVAL
%257 = and i32 %255, %256
%258 = icmp eq i32 %257, 0
br i1 %258, label %259, label %386
259: ; preds = %252
%260 = load i8*, i8** %19
%261 = load i32, i32* %14
%262 = call i32 @memset(i8* %260, i32 0, i32 %261)
%263 = load i8*, i8** %20
%264 = load i32, i32* %14
%265 = call i32 @memset(i8* %263, i32 0, i32 %264)
%266 = load i8*, i8** %21
%267 = load i32, i32* %14
%268 = call i32 @memset(i8* %266, i32 0, i32 %267)
%269 = load %struct.pollfd*, %struct.pollfd** %11
%270 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %269, i32 0, i32 2
%271 = load i32, i32* %270
%272 = load i32, i32* @POLLIN
%273 = and i32 %271, %272
%274 = icmp ne i32 %273, 0
br i1 %274, label %275, label %281
275: ; preds = %259
%276 = load %struct.pollfd*, %struct.pollfd** %11
%277 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %276, i32 0, i32 1
%278 = load i32, i32* %277
%279 = load i8*, i8** %19
%280 = call i32 @FD_SET(i32 %278, i8* %279)
br label %281
281: ; preds = %275, %259
%282 = load %struct.pollfd*, %struct.pollfd** %11
%283 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %282, i32 0, i32 2
%284 = load i32, i32* %283
%285 = load i32, i32* @POLLOUT
%286 = and i32 %284, %285
%287 = icmp ne i32 %286, 0
br i1 %287, label %288, label %294
288: ; preds = %281
%289 = load %struct.pollfd*, %struct.pollfd** %11
%290 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %289, i32 0, i32 1
%291 = load i32, i32* %290
%292 = load i8*, i8** %20
%293 = call i32 @FD_SET(i32 %291, i8* %292)
br label %294
294: ; preds = %288, %281
%295 = load %struct.pollfd*, %struct.pollfd** %11
%296 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %295, i32 0, i32 2
%297 = load i32, i32* %296
%298 = load i32, i32* @POLLPRI
%299 = and i32 %297, %298
%300 = icmp ne i32 %299, 0
br i1 %300, label %301, label %307
301: ; preds = %294
%302 = load %struct.pollfd*, %struct.pollfd** %11
%303 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %302, i32 0, i32 1
%304 = load i32, i32* %303
%305 = load i8*, i8** %21
%306 = call i32 @FD_SET(i32 %304, i8* %305)
br label %307
307: ; preds = %301, %294
%308 = load %struct.pollfd*, %struct.pollfd** %11
%309 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %308, i32 0, i32 1
%310 = load i32, i32* %309
%311 = add nsw i32 %310, 1
%312 = load i8*, i8** %19
%313 = load i8*, i8** %20
%314 = load i8*, i8** %21
%315 = call i32 @select(i32 %311, i8* %312, i8* %313, i8* %314, %struct.timeval* %22)
store i32 %315, i32* %23
%316 = load i32, i32* %23
%317 = icmp ne i32 %316, -1
br i1 %317, label %318, label %374
318: ; preds = %307
%319 = load %struct.pollfd*, %struct.pollfd** %11
%320 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %319, i32 0, i32 2
%321 = load i32, i32* %320
%322 = load i32, i32* @POLLIN
%323 = and i32 %321, %322
%324 = icmp ne i32 %323, 0
br i1 %324, label %325, label %331
325: ; preds = %318
%326 = load %struct.pollfd*, %struct.pollfd** %11
%327 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %326, i32 0, i32 1
%328 = load i32, i32* %327
%329 = load i8*, i8** %8
%330 = call i32 @FD_SET(i32 %328, i8* %329)
br label %331
331: ; preds = %325, %318
%332 = load %struct.pollfd*, %struct.pollfd** %11
%333 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %332, i32 0, i32 2
%334 = load i32, i32* %333
%335 = load i32, i32* @POLLOUT
%336 = and i32 %334, %335
%337 = icmp ne i32 %336, 0
br i1 %337, label %338, label %344
338: ; preds = %331
%339 = load %struct.pollfd*, %struct.pollfd** %11
%340 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %339, i32 0, i32 1
%341 = load i32, i32* %340
%342 = load i8*, i8** %9
%343 = call i32 @FD_SET(i32 %341, i8* %342)
br label %344
344: ; preds = %338, %331
%345 = load %struct.pollfd*, %struct.pollfd** %11
%346 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %345, i32 0, i32 2
%347 = load i32, i32* %346
%348 = load i32, i32* @POLLPRI
%349 = and i32 %347, %348
%350 = icmp ne i32 %349, 0
br i1 %350, label %351, label %357
351: ; preds = %344
%352 = load %struct.pollfd*, %struct.pollfd** %11
%353 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %352, i32 0, i32 1
%354 = load i32, i32* %353
%355 = load i8*, i8** %10
%356 = call i32 @FD_SET(i32 %354, i8* %355)
br label %357
357: ; preds = %351, %344
%358 = load %struct.pollfd*, %struct.pollfd** %11
%359 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %358, i32 0, i32 1
%360 = load i32, i32* %359
%361 = load i32, i32* %13
%362 = icmp sgt i32 %360, %361
br i1 %362, label %363, label %367
363: ; preds = %357
%364 = load %struct.pollfd*, %struct.pollfd** %11
%365 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %364, i32 0, i32 1
%366 = load i32, i32* %365
store i32 %366, i32* %13
br label %367
367: ; preds = %363, %357
%368 = load i32, i32* %23
%369 = icmp sgt i32 %368, 0
br i1 %369, label %370, label %373
370: ; preds = %367
%371 = load i32, i32* %12
%372 = add nsw i32 %371, 1
store i32 %372, i32* %12
br label %373
373: ; preds = %370, %367
br label %385
374: ; preds = %307
%375 = load i64, i64* @errno
%376 = load i64, i64* @EBADF
%377 = icmp eq i64 %375, %376
br i1 %377, label %378, label %384
378: ; preds = %374
%379 = load i32, i32* @POLLNVAL
%380 = load %struct.pollfd*, %struct.pollfd** %11
%381 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %380, i32 0, i32 0
%382 = load i32, i32* %381
%383 = or i32 %382, %379
store i32 %383, i32* %381
br label %384
384: ; preds = %378, %374
br label %385
385: ; preds = %384, %373
br label %386
386: ; preds = %385, %252, %241, %236
br label %387
387: ; preds = %386
%388 = load %struct.pollfd*, %struct.pollfd** %11
%389 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %388, i32 1
store %struct.pollfd* %389, %struct.pollfd** %11
br label %230
390: ; preds = %230
br label %192
391: ; preds = %207, %202
br label %392
392: ; preds = %391
%393 = load i32, i32* %12
%394 = icmp sgt i32 %393, 0
br i1 %394, label %395, label %453
395: ; preds = %392
%396 = load %struct.pollfd*, %struct.pollfd** %4
store %struct.pollfd* %396, %struct.pollfd** %11
br label %397
397: ; preds = %449, %395
%398 = load %struct.pollfd*, %struct.pollfd** %11
%399 = load %struct.pollfd*, %struct.pollfd** %4
%400 = load i64, i64* %5
%401 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %399, i64 %400
%402 = icmp ult %struct.pollfd* %398, %401
br i1 %402, label %403, label %452
403: ; preds = %397
%404 = load %struct.pollfd*, %struct.pollfd** %11
%405 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %404, i32 0, i32 1
%406 = load i32, i32* %405
%407 = icmp sge i32 %406, 0
br i1 %407, label %408, label %448
408: ; preds = %403
%409 = load %struct.pollfd*, %struct.pollfd** %11
%410 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %409, i32 0, i32 1
%411 = load i32, i32* %410
%412 = load i8*, i8** %8
%413 = call i64 @FD_ISSET(i32 %411, i8* %412)
%414 = icmp ne i64 %413, 0
br i1 %414, label %415, label %421
415: ; preds = %408
%416 = load i32, i32* @POLLIN
%417 = load %struct.pollfd*, %struct.pollfd** %11
%418 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %417, i32 0, i32 0
%419 = load i32, i32* %418
%420 = or i32 %419, %416
store i32 %420, i32* %418
br label %421
421: ; preds = %415, %408
%422 = load %struct.pollfd*, %struct.pollfd** %11
%423 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %422, i32 0, i32 1
%424 = load i32, i32* %423
%425 = load i8*, i8** %9
%426 = call i64 @FD_ISSET(i32 %424, i8* %425)
%427 = icmp ne i64 %426, 0
br i1 %427, label %428, label %434
428: ; preds = %421
%429 = load i32, i32* @POLLOUT
%430 = load %struct.pollfd*, %struct.pollfd** %11
%431 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %430, i32 0, i32 0
%432 = load i32, i32* %431
%433 = or i32 %432, %429
store i32 %433, i32* %431
br label %434
434: ; preds = %428, %421
%435 = load %struct.pollfd*, %struct.pollfd** %11
%436 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %435, i32 0, i32 1
%437 = load i32, i32* %436
%438 = load i8*, i8** %10
%439 = call i64 @FD_ISSET(i32 %437, i8* %438)
%440 = icmp ne i64 %439, 0
br i1 %440, label %441, label %447
441: ; preds = %434
%442 = load i32, i32* @POLLPRI
%443 = load %struct.pollfd*, %struct.pollfd** %11
%444 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %443, i32 0, i32 0
%445 = load i32, i32* %444
%446 = or i32 %445, %442
store i32 %446, i32* %444
br label %447
447: ; preds = %441, %434
br label %448
448: ; preds = %447, %403
br label %449
449: ; preds = %448
%450 = load %struct.pollfd*, %struct.pollfd** %11
%451 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %450, i32 1
store %struct.pollfd* %451, %struct.pollfd** %11
br label %397
452: ; preds = %397
br label %453
453: ; preds = %452, %392
%454 = load i32, i32* %12
ret i32 %454
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i32 }
%struct.timeval = type { i32, i32 }
@poll.max_fd_size = internal unnamed_addr global i32 0
@__NFDBITS = global i32 0
@POLLIN = global i32 0
@POLLOUT = global i32 0
@POLLPRI = global i32 0
@errno = global i64 0
@EBADF = global i64 0
@POLLNVAL = global i32 0
define i32 @poll(%struct.pollfd* %0, i64 %1, i32 %2) {
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = bitcast %struct.timeval* %4 to i8*
%7 = load i32, i32* @poll.max_fd_size
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 (...) @getdtablesize()
store i32 %10, i32* @poll.max_fd_size
br label %11
11: ; preds = %9, %3
%12 = phi i32 [ %10, %9 ], [ %7, %3 ]
%13 = load i32, i32* @__NFDBITS
%14 = tail call i32 @howmany(i32 %12, i32 %13)
%15 = tail call i8* @alloca(i32 %14)
%16 = tail call i8* @alloca(i32 %14)
%17 = tail call i8* @alloca(i32 %14)
%18 = tail call i32 @memset(i8* %15, i32 0, i32 %14)
%19 = tail call i32 @memset(i8* %16, i32 0, i32 %14)
%20 = tail call i32 @memset(i8* %17, i32 0, i32 %14)
%21 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %0, i64 %1
%22 = icmp sgt i64 %1, 0
br i1 %22, label %23, label %108
23: ; preds = %11, %100
%24 = phi i8* [ %105, %100 ], [ %15, %11 ]
%25 = phi i8* [ %104, %100 ], [ %16, %11 ]
%26 = phi i8* [ %103, %100 ], [ %17, %11 ]
%27 = phi %struct.pollfd* [ %106, %100 ], [ %0, %11 ]
%28 = phi i32 [ %102, %100 ], [ 0, %11 ]
%29 = phi i32 [ %101, %100 ], [ %14, %11 ]
%30 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %27, i64 0, i32 0
store i32 0, i32* %30
%31 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %27, i64 0, i32 1
%32 = load i32, i32* %31
%33 = icmp sgt i32 %32, -1
br i1 %33, label %34, label %100
34: ; preds = %23
%35 = load i32, i32* @poll.max_fd_size
%36 = icmp slt i32 %32, %35
br i1 %36, label %56, label %37
37: ; preds = %34
%38 = load i32, i32* @__NFDBITS
%39 = tail call i32 @roundup(i32 %32, i32 %38)
store i32 %39, i32* @poll.max_fd_size
%40 = load i32, i32* @__NFDBITS
%41 = tail call i32 @howmany(i32 %39, i32 %40)
%42 = tail call i8* @alloca(i32 %41)
%43 = tail call i8* @alloca(i32 %41)
%44 = tail call i8* @alloca(i32 %41)
%45 = sext i32 %29 to i64
%46 = getelementptr inbounds i8, i8* %42, i64 %45
%47 = sub nsw i32 %41, %29
%48 = tail call i32 @memset(i8* %46, i32 0, i32 %47)
%49 = getelementptr inbounds i8, i8* %43, i64 %45
%50 = tail call i32 @memset(i8* %49, i32 0, i32 %47)
%51 = getelementptr inbounds i8, i8* %44, i64 %45
%52 = tail call i32 @memset(i8* %51, i32 0, i32 %47)
%53 = tail call i8* @memcpy(i8* %42, i8* %24, i32 %29)
%54 = tail call i8* @memcpy(i8* %43, i8* %25, i32 %29)
%55 = tail call i8* @memcpy(i8* %44, i8* %26, i32 %29)
br label %56
56: ; preds = %37, %34
%57 = phi i32 [ %41, %37 ], [ %29, %34 ]
%58 = phi i8* [ %55, %37 ], [ %26, %34 ]
%59 = phi i8* [ %54, %37 ], [ %25, %34 ]
%60 = phi i8* [ %53, %37 ], [ %24, %34 ]
%61 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %27, i64 0, i32 2
%62 = load i32, i32* %61
%63 = load i32, i32* @POLLIN
%64 = and i32 %63, %62
%65 = icmp eq i32 %64, 0
br i1 %65, label %70, label %66
66: ; preds = %56
%67 = load i32, i32* %31
%68 = tail call i32 @FD_SET(i32 %67, i8* %60)
%69 = load i32, i32* %61
br label %70
70: ; preds = %66, %56
%71 = phi i32 [ %69, %66 ], [ %62, %56 ]
%72 = load i32, i32* @POLLOUT
%73 = and i32 %72, %71
%74 = icmp eq i32 %73, 0
br i1 %74, label %79, label %75
75: ; preds = %70
%76 = load i32, i32* %31
%77 = tail call i32 @FD_SET(i32 %76, i8* %59)
%78 = load i32, i32* %61
br label %79
79: ; preds = %75, %70
%80 = phi i32 [ %78, %75 ], [ %71, %70 ]
%81 = load i32, i32* @POLLPRI
%82 = and i32 %81, %80
%83 = icmp eq i32 %82, 0
br i1 %83, label %87, label %84
84: ; preds = %79
%85 = load i32, i32* %31
%86 = tail call i32 @FD_SET(i32 %85, i8* %58)
br label %87
87: ; preds = %84, %79
%88 = load i32, i32* %31
%89 = icmp sgt i32 %88, %28
br i1 %89, label %90, label %100
90: ; preds = %87
%91 = load i32, i32* %61
%92 = load i32, i32* @POLLIN
%93 = load i32, i32* @POLLOUT
%94 = or i32 %93, %92
%95 = load i32, i32* @POLLPRI
%96 = or i32 %94, %95
%97 = and i32 %96, %91
%98 = icmp eq i32 %97, 0
%99 = select i1 %98, i32 %28, i32 %88
br label %100
100: ; preds = %90, %23, %87
%101 = phi i32 [ %57, %87 ], [ %29, %23 ], [ %57, %90 ]
%102 = phi i32 [ %28, %87 ], [ %28, %23 ], [ %99, %90 ]
%103 = phi i8* [ %58, %87 ], [ %26, %23 ], [ %58, %90 ]
%104 = phi i8* [ %59, %87 ], [ %25, %23 ], [ %59, %90 ]
%105 = phi i8* [ %60, %87 ], [ %24, %23 ], [ %60, %90 ]
%106 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %27, i64 1
%107 = icmp ult %struct.pollfd* %106, %21
br i1 %107, label %23, label %108
108: ; preds = %100, %11
%109 = phi i32 [ %14, %11 ], [ %101, %100 ]
%110 = phi i32 [ 0, %11 ], [ %102, %100 ]
%111 = phi i8* [ %17, %11 ], [ %103, %100 ]
%112 = phi i8* [ %16, %11 ], [ %104, %100 ]
%113 = phi i8* [ %15, %11 ], [ %105, %100 ]
%114 = sdiv i32 %2, 1000
%115 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
store i32 %114, i32* %115
%116 = srem i32 %2, 1000
%117 = mul nsw i32 %116, 1000
%118 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
store i32 %117, i32* %118
%119 = icmp eq i32 %2, -1
%120 = select i1 %119, %struct.timeval* null, %struct.timeval* %4
%121 = add nsw i32 %110, 1
%122 = call i32 @select(i32 %121, i8* %113, i8* %112, i8* %111, %struct.timeval* %120)
%123 = icmp eq i32 %122, -1
br i1 %123, label %124, label %242
124: ; preds = %108
%125 = bitcast %struct.timeval* %5 to i8*
%126 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%127 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
br label %128
128: ; preds = %124, %237
%129 = load i64, i64* @errno
%130 = load i64, i64* @EBADF
%131 = icmp eq i64 %129, %130
br i1 %131, label %132, label %280
132: ; preds = %128
%133 = call i8* @alloca(i32 %109)
%134 = call i8* @alloca(i32 %109)
%135 = call i8* @alloca(i32 %109)
%136 = call i32 @memset(i8* %113, i32 0, i32 %109)
%137 = call i32 @memset(i8* %112, i32 0, i32 %109)
%138 = call i32 @memset(i8* %111, i32 0, i32 %109)
store i32 0, i32* %126
store i32 0, i32* %127
br i1 %22, label %139, label %237
139: ; preds = %132, %233
%140 = phi %struct.pollfd* [ %235, %233 ], [ %0, %132 ]
%141 = phi i32 [ %234, %233 ], [ -1, %132 ]
%142 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %140, i64 0, i32 1
%143 = load i32, i32* %142
%144 = icmp eq i32 %143, -1
br i1 %144, label %233, label %145
145: ; preds = %139
%146 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %140, i64 0, i32 2
%147 = load i32, i32* %146
%148 = load i32, i32* @POLLIN
%149 = load i32, i32* @POLLOUT
%150 = or i32 %149, %148
%151 = load i32, i32* @POLLPRI
%152 = or i32 %150, %151
%153 = and i32 %152, %147
%154 = icmp eq i32 %153, 0
br i1 %154, label %233, label %155
155: ; preds = %145
%156 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %140, i64 0, i32 0
%157 = load i32, i32* %156
%158 = load i32, i32* @POLLNVAL
%159 = and i32 %158, %157
%160 = icmp eq i32 %159, 0
br i1 %160, label %161, label %233
161: ; preds = %155
%162 = call i32 @memset(i8* %133, i32 0, i32 %109)
%163 = call i32 @memset(i8* %134, i32 0, i32 %109)
%164 = call i32 @memset(i8* %135, i32 0, i32 %109)
%165 = load i32, i32* %146
%166 = load i32, i32* @POLLIN
%167 = and i32 %166, %165
%168 = icmp eq i32 %167, 0
br i1 %168, label %173, label %169
169: ; preds = %161
%170 = load i32, i32* %142
%171 = call i32 @FD_SET(i32 %170, i8* %133)
%172 = load i32, i32* %146
br label %173
173: ; preds = %169, %161
%174 = phi i32 [ %172, %169 ], [ %165, %161 ]
%175 = load i32, i32* @POLLOUT
%176 = and i32 %175, %174
%177 = icmp eq i32 %176, 0
br i1 %177, label %182, label %178
178: ; preds = %173
%179 = load i32, i32* %142
%180 = call i32 @FD_SET(i32 %179, i8* %134)
%181 = load i32, i32* %146
br label %182
182: ; preds = %178, %173
%183 = phi i32 [ %181, %178 ], [ %174, %173 ]
%184 = load i32, i32* @POLLPRI
%185 = and i32 %184, %183
%186 = icmp eq i32 %185, 0
br i1 %186, label %190, label %187
187: ; preds = %182
%188 = load i32, i32* %142
%189 = call i32 @FD_SET(i32 %188, i8* %135)
br label %190
190: ; preds = %187, %182
%191 = load i32, i32* %142
%192 = add nsw i32 %191, 1
%193 = call i32 @select(i32 %192, i8* %133, i8* %134, i8* %135, %struct.timeval* %5)
%194 = icmp eq i32 %193, -1
br i1 %194, label %225, label %195
195: ; preds = %190
%196 = load i32, i32* %146
%197 = load i32, i32* @POLLIN
%198 = and i32 %197, %196
%199 = icmp eq i32 %198, 0
br i1 %199, label %204, label %200
200: ; preds = %195
%201 = load i32, i32* %142
%202 = call i32 @FD_SET(i32 %201, i8* %113)
%203 = load i32, i32* %146
br label %204
204: ; preds = %200, %195
%205 = phi i32 [ %203, %200 ], [ %196, %195 ]
%206 = load i32, i32* @POLLOUT
%207 = and i32 %206, %205
%208 = icmp eq i32 %207, 0
br i1 %208, label %213, label %209
209: ; preds = %204
%210 = load i32, i32* %142
%211 = call i32 @FD_SET(i32 %210, i8* %112)
%212 = load i32, i32* %146
br label %213
213: ; preds = %209, %204
%214 = phi i32 [ %212, %209 ], [ %205, %204 ]
%215 = load i32, i32* @POLLPRI
%216 = and i32 %215, %214
%217 = icmp eq i32 %216, 0
br i1 %217, label %221, label %218
218: ; preds = %213
%219 = load i32, i32* %142
%220 = call i32 @FD_SET(i32 %219, i8* %111)
br label %221
221: ; preds = %218, %213
%222 = load i32, i32* %142
%223 = icmp sgt i32 %222, %141
%224 = select i1 %223, i32 %222, i32 %141
br label %233
225: ; preds = %190
%226 = load i64, i64* @errno
%227 = load i64, i64* @EBADF
%228 = icmp eq i64 %226, %227
br i1 %228, label %229, label %233
229: ; preds = %225
%230 = load i32, i32* @POLLNVAL
%231 = load i32, i32* %156
%232 = or i32 %231, %230
store i32 %232, i32* %156
br label %233
233: ; preds = %221, %229, %225, %139, %145, %155
%234 = phi i32 [ %141, %155 ], [ %141, %145 ], [ %141, %139 ], [ %141, %229 ], [ %141, %225 ], [ %224, %221 ]
%235 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %140, i64 1
%236 = icmp ult %struct.pollfd* %235, %21
br i1 %236, label %139, label %237
237: ; preds = %233, %132
%238 = phi i32 [ -1, %132 ], [ %234, %233 ]
%239 = add nsw i32 %238, 1
%240 = call i32 @select(i32 %239, i8* %113, i8* %112, i8* %111, %struct.timeval* %120)
%241 = icmp eq i32 %240, -1
br i1 %241, label %128, label %242
242: ; preds = %237, %108
%243 = phi i32 [ %122, %108 ], [ %240, %237 ]
%244 = icmp sgt i32 %243, 0
%245 = and i1 %244, %22
br i1 %245, label %246, label %280
246: ; preds = %242, %277
%247 = phi %struct.pollfd* [ %278, %277 ], [ %0, %242 ]
%248 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %247, i64 0, i32 1
%249 = load i32, i32* %248
%250 = icmp sgt i32 %249, -1
br i1 %250, label %251, label %277
251: ; preds = %246
%252 = call i64 @FD_ISSET(i32 %249, i8* %113)
%253 = icmp eq i64 %252, 0
br i1 %253, label %259, label %254
254: ; preds = %251
%255 = load i32, i32* @POLLIN
%256 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %247, i64 0, i32 0
%257 = load i32, i32* %256
%258 = or i32 %257, %255
store i32 %258, i32* %256
br label %259
259: ; preds = %254, %251
%260 = load i32, i32* %248
%261 = call i64 @FD_ISSET(i32 %260, i8* %112)
%262 = icmp eq i64 %261, 0
br i1 %262, label %268, label %263
263: ; preds = %259
%264 = load i32, i32* @POLLOUT
%265 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %247, i64 0, i32 0
%266 = load i32, i32* %265
%267 = or i32 %266, %264
store i32 %267, i32* %265
br label %268
268: ; preds = %263, %259
%269 = load i32, i32* %248
%270 = call i64 @FD_ISSET(i32 %269, i8* %111)
%271 = icmp eq i64 %270, 0
br i1 %271, label %277, label %272
272: ; preds = %268
%273 = load i32, i32* @POLLPRI
%274 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %247, i64 0, i32 0
%275 = load i32, i32* %274
%276 = or i32 %275, %273
store i32 %276, i32* %274
br label %277
277: ; preds = %246, %272, %268
%278 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %247, i64 1
%279 = icmp ult %struct.pollfd* %278, %21
br i1 %279, label %246, label %280
280: ; preds = %128, %277, %242
%281 = phi i32 [ %243, %242 ], [ %243, %277 ], [ -1, %128 ]
ret i32 %281
}