#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 sockaddr_storage {
  int /*<<< orphan*/ ss_family;
};
struct sockaddr {
  int dummy;
};
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  struct addrinfo *ai_next;
  int /*<<< orphan*/ ai_flags;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ FD_CLR(int, int /*<<< orphan*/ *);
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
scalar_t__ bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int /*<<< orphan*/ get_in_addr(struct sockaddr *);
int getaddrinfo(int /*<<< orphan*/ *, char *, struct addrinfo *,
                struct addrinfo **);
char *inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int listen(int, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(void) {
  fd_set master;
  fd_set read_fds;
  int fdmax;
  int listener;
  int newfd;
  struct sockaddr_storage remoteaddr;
  socklen_t addrlen;
  char buf[256];
  int nbytes;
  char remoteIP[INET6_ADDRSTRLEN];
  int yes = 1;
  int i, j, rv;
  struct addrinfo hints, *ai, *p;
  FD_ZERO(&master);
  FD_ZERO(&read_fds);
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_PASSIVE;
  if ((rv = getaddrinfo(NULL, "3490", &hints, &ai)) != 0) {
    fprintf(stderr, "selectserver: %s\n", gai_strerror(rv));
    exit(1);
  }
  for (p = ai; p != NULL; p = p->ai_next) {
    listener = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
    if (listener < 0)
      continue;
    setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
    if (bind(listener, p->ai_addr, p->ai_addrlen) < 0) {
      close(listener);
      continue;
    }
    break;
  }
  if (p == NULL) {
    fprintf(stderr, "selectserver: failed to bind\n");
    exit(2);
  }
  freeaddrinfo(ai);
  if (listen(listener, 10) == -1) {
    perror("listen");
    exit(3);
  }
  FD_SET(listener, &master);
  fdmax = listener;
  for (;;) {
    read_fds = master;
    if (select(fdmax + 1, &read_fds, NULL, NULL, NULL) == -1) {
      perror("select");
      exit(4);
    }
    for (i = 0; i <= fdmax; i++) {
      if (FD_ISSET(i, &read_fds)) {
        printf("Found something waiting %d \n", i);
        if (i == listener) {
          addrlen = sizeof remoteaddr;
          newfd = accept(listener, (struct sockaddr *)&remoteaddr, &addrlen);
          if (newfd == -1)
            perror("accept");
          else {
            FD_SET(newfd, &master);
            if (newfd > fdmax)
              fdmax = newfd;
            printf("selectserver: new connection from %s on "
                   "socket %d\n",
                   inet_ntop(remoteaddr.ss_family,
                             get_in_addr((struct sockaddr *)&remoteaddr),
                             remoteIP, INET6_ADDRSTRLEN),
                   newfd);
          }
        } else {
          if ((nbytes = recv(i, buf, sizeof buf, 0)) <= 0) {
            if (nbytes == 0)
              printf("selectserver: socket %d hung up\n", i);
            else
              perror("recv");
            close(i);
            FD_CLR(i, &master);
          } else {
            printf("Got some data %d %d %d\n", listener, i, fdmax);
            for (j = 0; j <= fdmax; j++) {
              if (FD_ISSET(j, &master)) {
                if (j != listener && j != i) {
                  if (send(j, buf, nbytes, 0) == -1)
                    perror("send");
                }
              }
            }
          }
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2d57(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x140(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x198(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x148(%rbp)
movl   $0x1,-0x14c(%rbp)
lea    -0x8(%rbp),%rdi
call   10e0 <FD_ZERO@plt>
lea    -0xc(%rbp),%rdi
call   10e0 <FD_ZERO@plt>
lea    -0x180(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   10b0 <memset@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x170(%rbp)
mov    0x2cbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x174(%rbp)
mov    0x2ccd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x160(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xce2(%rip),%rsi
lea    -0x180(%rbp),%rdx
lea    -0x188(%rbp),%rcx
call   1160 <getaddrinfo@plt>
mov    %eax,-0x158(%rbp)
cmp    $0x0,%eax
je     137b <main+0x10b>
mov    0x2c79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x19c(%rbp)
mov    -0x158(%rbp),%edi
call   10a0 <gai_strerror@plt>
mov    -0x19c(%rbp),%edi
mov    %rax,%rdx
lea    0xc9b(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    -0x188(%rbp),%rax
mov    %rax,-0x190(%rbp)
cmpq   $0x0,-0x190(%rbp)
je     1441 <main+0x1d1>
mov    -0x190(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x190(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x190(%rbp),%rax
mov    0x8(%rax),%edx
call   1190 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    13cc <main+0x15c>
jmp    142a <main+0x1ba>
mov    -0x14(%rbp),%edi
mov    0x2c12(%rip),%rax
mov    (%rax),%esi
mov    0x2bd1(%rip),%rax
mov    (%rax),%edx
lea    -0x14c(%rbp),%rcx
mov    $0x4,%r8d
call   1060 <setsockopt@plt>
mov    -0x14(%rbp),%edi
mov    -0x190(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x190(%rbp),%rax
mov    (%rax),%edx
call   1110 <bind@plt>
cmp    $0x0,%rax
jge    1425 <main+0x1b5>
mov    -0x14(%rbp),%edi
call   10c0 <close@plt>
jmp    142a <main+0x1ba>
jmp    1441 <main+0x1d1>
mov    -0x190(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x190(%rbp)
jmp    1389 <main+0x119>
cmpq   $0x0,-0x190(%rbp)
jne    1470 <main+0x200>
mov    0x2b6a(%rip),%rax
mov    (%rax),%edi
lea    0xbb8(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x2,%edi
call   1150 <exit@plt>
mov    -0x188(%rbp),%rdi
call   1180 <freeaddrinfo@plt>
mov    -0x14(%rbp),%edi
mov    $0xa,%esi
call   1100 <listen@plt>
cmp    $0xffffffff,%eax
jne    14a8 <main+0x238>
lea    0xb9c(%rip),%rdi
call   1120 <perror@plt>
mov    $0x3,%edi
call   1150 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1170 <FD_SET@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%edi
add    $0x1,%edi
lea    -0xc(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10f0 <select@plt>
cmp    $0xffffffff,%eax
jne    14f9 <main+0x289>
lea    0xb52(%rip),%rdi
call   1120 <perror@plt>
mov    $0x4,%edi
call   1150 <exit@plt>
movl   $0x0,-0x150(%rbp)
mov    -0x150(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1749 <main+0x4d9>
mov    -0x150(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1070 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1730 <main+0x4c0>
mov    -0x150(%rbp),%esi
lea    0xb0b(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x150(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    15e9 <main+0x379>
movl   $0x4,-0x24(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1130 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1583 <main+0x313>
lea    0xae7(%rip),%rdi
call   1120 <perror@plt>
jmp    15e4 <main+0x374>
mov    -0x18(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1170 <FD_SET@plt>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    15a1 <main+0x331>
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1a0(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <get_in_addr@plt>
mov    -0x1a0(%rbp),%edi
mov    -0x198(%rbp),%rdx
mov    %eax,%esi
mov    0x2a17(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rsi
mov    -0x18(%rbp),%edx
lea    0xa8a(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    172b <main+0x4bb>
mov    -0x150(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    %eax,-0x134(%rbp)
cmp    $0x0,%eax
jg     1662 <main+0x3f2>
cmpl   $0x0,-0x134(%rbp)
jne    1637 <main+0x3c7>
mov    -0x150(%rbp),%esi
lea    0xa6f(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    1643 <main+0x3d3>
lea    0xa7d(%rip),%rdi
call   1120 <perror@plt>
mov    -0x150(%rbp),%edi
call   10c0 <close@plt>
mov    -0x150(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1140 <FD_CLR@plt>
jmp    1726 <main+0x4b6>
mov    -0x14(%rbp),%esi
mov    -0x150(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xa4b(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x0,-0x154(%rbp)
mov    -0x154(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1721 <main+0x4b1>
mov    -0x154(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1070 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1708 <main+0x498>
mov    -0x154(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     1703 <main+0x493>
mov    -0x154(%rbp),%eax
cmp    -0x150(%rbp),%eax
je     1703 <main+0x493>
mov    -0x154(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    -0x134(%rbp),%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0xffffffff,%eax
jne    16fe <main+0x48e>
lea    0x9df(%rip),%rdi
call   1120 <perror@plt>
jmp    1703 <main+0x493>
jmp    1708 <main+0x498>
jmp    170d <main+0x49d>
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
jmp    1686 <main+0x416>
jmp    1726 <main+0x4b6>
jmp    172b <main+0x4bb>
jmp    1730 <main+0x4c0>
jmp    1735 <main+0x4c5>
mov    -0x150(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x150(%rbp)
jmp    1503 <main+0x293>
jmp    14ba <main+0x24a>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
mov    0x2d55(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
movl   $0x1,-0x3c(%rbp)
lea    -0x30(%rbp),%rdi
call   10e0 <FD_ZERO@plt>
lea    -0x2c(%rbp),%rdi
call   10e0 <FD_ZERO@plt>
lea    -0x80(%rbp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   10b0 <memset@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    0x2cd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    0x2ceb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
lea    0xd07(%rip),%rsi
lea    -0x48(%rbp),%rcx
xor    %edi,%edi
mov    %rbx,%rdx
call   1160 <getaddrinfo@plt>
test   %eax,%eax
jne    1335 <main+0xc5>
mov    -0x48(%rbp),%rbx
test   %rbx,%rbx
jne    1362 <main+0xf2>
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
lea    0xcf3(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x2,%edi
call   1150 <exit@plt>
mov    0x2c84(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   10a0 <gai_strerror@plt>
lea    0xcb9(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    0x2c7f(%rip),%r15
mov    0x2c40(%rip),%r13
lea    -0x3c(%rbp),%r14
jmp    1389 <main+0x119>
cs nopw 0x0(%rax,%rax,1)
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
je     1314 <main+0xa4>
mov    0x10(%rbx),%edi
mov    0x8(%rbx),%edx
mov    0xc(%rbx),%esi
call   1190 <socket@plt>
test   %eax,%eax
js     1380 <main+0x110>
mov    %eax,%r12d
mov    (%r15),%esi
mov    0x0(%r13),%edx
mov    %eax,%edi
mov    %r14,%rcx
mov    $0x4,%r8d
call   1060 <setsockopt@plt>
mov    (%rbx),%edx
mov    0x4(%rbx),%esi
mov    %r12d,%edi
call   1110 <bind@plt>
test   %rax,%rax
jns    13d1 <main+0x161>
mov    %r12d,%edi
call   10c0 <close@plt>
jmp    1380 <main+0x110>
mov    -0x48(%rbp),%rdi
call   1180 <freeaddrinfo@plt>
mov    %r12d,%edi
mov    $0xa,%esi
call   1100 <listen@plt>
cmp    $0xffffffff,%eax
jne    1402 <main+0x192>
lea    0xc42(%rip),%rdi
call   1120 <perror@plt>
mov    $0x3,%edi
call   1150 <exit@plt>
lea    -0x30(%rbp),%rsi
mov    %r12d,%edi
call   1170 <FD_SET@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0x1(%r12),%edi
lea    -0x2c(%rbp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10f0 <select@plt>
cmp    $0xffffffff,%eax
jne    1444 <main+0x1d4>
lea    0xc07(%rip),%rdi
call   1120 <perror@plt>
mov    $0x4,%edi
call   1150 <exit@plt>
lea    -0x2c(%rbp),%r13
mov    %r12d,%r14d
jmp    146e <main+0x1fe>
nopl   (%rax)
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0x1(%r14),%edi
mov    %r13,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10f0 <select@plt>
cmp    $0xffffffff,%eax
je     142e <main+0x1be>
test   %r14d,%r14d
js     1450 <main+0x1e0>
xor    %r15d,%r15d
jmp    148c <main+0x21c>
lea    -0x2c(%rbp),%r13
mov    -0x50(%rbp),%r14
lea    0x1(%r15),%eax
cmp    %r14d,%r15d
mov    %eax,%r15d
jge    1450 <main+0x1e0>
mov    %r15d,%edi
mov    %r13,%rsi
call   1070 <FD_ISSET@plt>
test   %rax,%rax
je     1480 <main+0x210>
lea    0xba0(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
cmp    %r12d,%r15d
jne    1530 <main+0x2c0>
movl   $0x4,-0x40(%rbp)
mov    %r12d,%edi
lea    -0x38(%rbp),%r13
mov    %r13,%rsi
lea    -0x40(%rbp),%rdx
call   1130 <accept@plt>
cmp    $0xffffffff,%eax
je     1608 <main+0x398>
mov    %eax,%ebx
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
call   1170 <FD_SET@plt>
cmp    %r14d,%ebx
cmovg  %ebx,%r14d
mov    %r13,%rdi
mov    %r14,%r13
mov    -0x38(%rbp),%r14d
call   1050 <get_in_addr@plt>
mov    0x2ae1(%rip),%rcx
mov    (%rcx),%ecx
mov    %r14d,%edi
mov    %r13,%r14
mov    %eax,%esi
mov    -0x58(%rbp),%rdx
call   1030 <inet_ntop@plt>
lea    0xb4e(%rip),%rdi
mov    %rax,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    -0x2c(%rbp),%r13
jmp    1480 <main+0x210>
xchg   %ax,%ax
mov    %r15d,%edi
lea    -0x180(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
test   %eax,%eax
jle    15cf <main+0x35f>
mov    %eax,%r13d
lea    0xb68(%rip),%rdi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1090 <printf@plt>
test   %r14d,%r14d
js     15ff <main+0x38f>
mov    %r14,-0x50(%rbp)
lea    0x1(%r14),%ebx
xor    %r14d,%r14d
jmp    158d <main+0x31d>
xchg   %ax,%ax
add    $0x1,%r14d
cmp    %r14d,%ebx
je     1478 <main+0x208>
mov    %r14d,%edi
lea    -0x30(%rbp),%rsi
call   1070 <FD_ISSET@plt>
test   %rax,%rax
je     1580 <main+0x310>
cmp    %r14d,%r12d
je     1580 <main+0x310>
cmp    %r14d,%r15d
je     1580 <main+0x310>
mov    %r14d,%edi
lea    -0x180(%rbp),%rsi
mov    %r13d,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0xffffffff,%eax
jne    1580 <main+0x310>
lea    0xb10(%rip),%rdi
call   1120 <perror@plt>
jmp    1580 <main+0x310>
jne    161d <main+0x3ad>
lea    0xac2(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
lea    -0x2c(%rbp),%r13
mov    %r15d,%edi
call   10c0 <close@plt>
mov    %r15d,%edi
lea    -0x30(%rbp),%rsi
call   1140 <FD_CLR@plt>
jmp    1480 <main+0x210>
lea    -0x2c(%rbp),%r13
jmp    1480 <main+0x210>
lea    0xa51(%rip),%rdi
call   1120 <perror@plt>
lea    -0x2c(%rbp),%r13
jmp    1480 <main+0x210>
lea    0xa97(%rip),%rdi
call   1120 <perror@plt>
jmp    15e2 <main+0x372>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [5 x i8] c"3490\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"selectserver: %s\0A\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [30 x i8] c"selectserver: failed to bind\0A\00"
@.str.3 = [7 x i8] c"listen\00"
@.str.4 = [7 x i8] c"select\00"
@.str.5 = [29 x i8] c"Found something waiting %d \0A\00"
@.str.6 = [7 x i8] c"accept\00"
@.str.7 = [51 x i8] c"selectserver: new connection from %s on socket %d\0A\00"
@.str.8 = [33 x i8] c"selectserver: socket %d hung up\0A\00"
@.str.9 = [5 x i8] c"recv\00"
@.str.10 = [24 x i8] c"Got some data %d %d %d\0A\00"
@.str.11 = [5 x i8] c"send\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.sockaddr_storage
%8 = alloca i32
%9 = alloca [256 x i8]
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca %struct.addrinfo
%18 = alloca %struct.addrinfo*
%19 = alloca %struct.addrinfo*
store i32 0, i32* %1
%20 = load i32, i32* @INET6_ADDRSTRLEN
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %11
%23 = alloca i8, i64 %21
store i64 %21, i64* %12
store i32 1, i32* %13
%24 = call i32 @FD_ZERO(i32* %2)
%25 = call i32 @FD_ZERO(i32* %3)
%26 = call i32 @memset(%struct.addrinfo* %17, i32 0, i32 40)
%27 = load i32, i32* @AF_UNSPEC
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %17, i32 0, i32 4
store i32 %27, i32* %28
%29 = load i32, i32* @SOCK_STREAM
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %17, i32 0, i32 3
store i32 %29, i32* %30
%31 = load i32, i32* @AI_PASSIVE
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %17, i32 0, i32 6
store i32 %31, i32* %32
%33 = call i32 @getaddrinfo(i32* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %17, %struct.addrinfo** %18)
store i32 %33, i32* %16
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %0
%36 = load i32, i32* @stderr
%37 = load i32, i32* %16
%38 = call i8* @gai_strerror(i32 %37)
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %0
%42 = load %struct.addrinfo*, %struct.addrinfo** %18
store %struct.addrinfo* %42, %struct.addrinfo** %19
br label %43
43: ; preds = %78, %41
%44 = load %struct.addrinfo*, %struct.addrinfo** %19
%45 = icmp ne %struct.addrinfo* %44, null
br i1 %45, label %46, label %82
46: ; preds = %43
%47 = load %struct.addrinfo*, %struct.addrinfo** %19
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %47, i32 0, i32 4
%49 = load i32, i32* %48
%50 = load %struct.addrinfo*, %struct.addrinfo** %19
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i32 0, i32 3
%52 = load i32, i32* %51
%53 = load %struct.addrinfo*, %struct.addrinfo** %19
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i32 0, i32 2
%55 = load i32, i32* %54
%56 = call i32 @socket(i32 %49, i32 %52, i32 %55)
store i32 %56, i32* %5
%57 = load i32, i32* %5
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %46
br label %78
60: ; preds = %46
%61 = load i32, i32* %5
%62 = load i32, i32* @SOL_SOCKET
%63 = load i32, i32* @SO_REUSEADDR
%64 = call i32 @setsockopt(i32 %61, i32 %62, i32 %63, i32* %13, i32 4)
%65 = load i32, i32* %5
%66 = load %struct.addrinfo*, %struct.addrinfo** %19
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %66, i32 0, i32 1
%68 = load i32, i32* %67
%69 = load %struct.addrinfo*, %struct.addrinfo** %19
%70 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %69, i32 0, i32 0
%71 = load i32, i32* %70
%72 = call i64 @bind(i32 %65, i32 %68, i32 %71)
%73 = icmp slt i64 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %60
%75 = load i32, i32* %5
%76 = call i32 @close(i32 %75)
br label %78
77: ; preds = %60
br label %82
78: ; preds = %74, %59
%79 = load %struct.addrinfo*, %struct.addrinfo** %19
%80 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %79, i32 0, i32 5
%81 = load %struct.addrinfo*, %struct.addrinfo** %80
store %struct.addrinfo* %81, %struct.addrinfo** %19
br label %43
82: ; preds = %77, %43
%83 = load %struct.addrinfo*, %struct.addrinfo** %19
%84 = icmp eq %struct.addrinfo* %83, null
br i1 %84, label %85, label %89
85: ; preds = %82
%86 = load i32, i32* @stderr
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%88 = call i32 @exit(i32 2)
unreachable
89: ; preds = %82
%90 = load %struct.addrinfo*, %struct.addrinfo** %18
%91 = call i32 @freeaddrinfo(%struct.addrinfo* %90)
%92 = load i32, i32* %5
%93 = call i32 @listen(i32 %92, i32 10)
%94 = icmp eq i32 %93, -1
br i1 %94, label %95, label %98
95: ; preds = %89
%96 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%97 = call i32 @exit(i32 3)
unreachable
98: ; preds = %89
%99 = load i32, i32* %5
%100 = call i32 @FD_SET(i32 %99, i32* %2)
%101 = load i32, i32* %5
store i32 %101, i32* %4
br label %102
102: ; preds = %212, %98
%103 = load i32, i32* %2
store i32 %103, i32* %3
%104 = load i32, i32* %4
%105 = add nsw i32 %104, 1
%106 = call i32 @select(i32 %105, i32* %3, i32* null, i32* null, i32* null)
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %111
108: ; preds = %102
%109 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%110 = call i32 @exit(i32 4)
unreachable
111: ; preds = %102
store i32 0, i32* %14
br label %112
112: ; preds = %209, %111
%113 = load i32, i32* %14
%114 = load i32, i32* %4
%115 = icmp sle i32 %113, %114
br i1 %115, label %116, label %212
116: ; preds = %112
%117 = load i32, i32* %14
%118 = call i64 @FD_ISSET(i32 %117, i32* %3)
%119 = icmp ne i64 %118, 0
br i1 %119, label %120, label %208
120: ; preds = %116
%121 = load i32, i32* %14
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %121)
%123 = load i32, i32* %14
%124 = load i32, i32* %5
%125 = icmp eq i32 %123, %124
br i1 %125, label %126, label %152
126: ; preds = %120
store i32 4, i32* %8
%127 = load i32, i32* %5
%128 = bitcast %struct.sockaddr_storage* %7 to %struct.sockaddr*
%129 = call i32 @accept(i32 %127, %struct.sockaddr* %128, i32* %8)
store i32 %129, i32* %6
%130 = load i32, i32* %6
%131 = icmp eq i32 %130, -1
br i1 %131, label %132, label %134
132: ; preds = %126
%133 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %151
134: ; preds = %126
%135 = load i32, i32* %6
%136 = call i32 @FD_SET(i32 %135, i32* %2)
%137 = load i32, i32* %6
%138 = load i32, i32* %4
%139 = icmp sgt i32 %137, %138
br i1 %139, label %140, label %142
140: ; preds = %134
%141 = load i32, i32* %6
store i32 %141, i32* %4
br label %142
142: ; preds = %140, %134
%143 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %7, i32 0, i32 0
%144 = load i32, i32* %143
%145 = bitcast %struct.sockaddr_storage* %7 to %struct.sockaddr*
%146 = call i32 @get_in_addr(%struct.sockaddr* %145)
%147 = load i32, i32* @INET6_ADDRSTRLEN
%148 = call i8* @inet_ntop(i32 %144, i32 %146, i8* %23, i32 %147)
%149 = load i32, i32* %6
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i8* %148, i32 %149)
br label %151
151: ; preds = %142, %132
br label %207
152: ; preds = %120
%153 = load i32, i32* %14
%154 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%155 = call i32 @recv(i32 %153, i8* %154, i32 256, i32 0)
store i32 %155, i32* %10
%156 = icmp sle i32 %155, 0
br i1 %156, label %157, label %170
157: ; preds = %152
%158 = load i32, i32* %10
%159 = icmp eq i32 %158, 0
br i1 %159, label %160, label %163
160: ; preds = %157
%161 = load i32, i32* %14
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %161)
br label %165
163: ; preds = %157
%164 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %165
165: ; preds = %163, %160
%166 = load i32, i32* %14
%167 = call i32 @close(i32 %166)
%168 = load i32, i32* %14
%169 = call i32 @FD_CLR(i32 %168, i32* %2)
br label %206
170: ; preds = %152
%171 = load i32, i32* %5
%172 = load i32, i32* %14
%173 = load i32, i32* %4
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %171, i32 %172, i32 %173)
store i32 0, i32* %15
br label %175
175: ; preds = %202, %170
%176 = load i32, i32* %15
%177 = load i32, i32* %4
%178 = icmp sle i32 %176, %177
br i1 %178, label %179, label %205
179: ; preds = %175
%180 = load i32, i32* %15
%181 = call i64 @FD_ISSET(i32 %180, i32* %2)
%182 = icmp ne i64 %181, 0
br i1 %182, label %183, label %201
183: ; preds = %179
%184 = load i32, i32* %15
%185 = load i32, i32* %5
%186 = icmp ne i32 %184, %185
br i1 %186, label %187, label %200
187: ; preds = %183
%188 = load i32, i32* %15
%189 = load i32, i32* %14
%190 = icmp ne i32 %188, %189
br i1 %190, label %191, label %200
191: ; preds = %187
%192 = load i32, i32* %15
%193 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%194 = load i32, i32* %10
%195 = call i32 @send(i32 %192, i8* %193, i32 %194, i32 0)
%196 = icmp eq i32 %195, -1
br i1 %196, label %197, label %199
197: ; preds = %191
%198 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %199
199: ; preds = %197, %191
br label %200
200: ; preds = %199, %187, %183
br label %201
201: ; preds = %200, %179
br label %202
202: ; preds = %201
%203 = load i32, i32* %15
%204 = add nsw i32 %203, 1
store i32 %204, i32* %15
br label %175
205: ; preds = %175
br label %206
206: ; preds = %205, %165
br label %207
207: ; preds = %206, %151
br label %208
208: ; preds = %207, %116
br label %209
209: ; preds = %208
%210 = load i32, i32* %14
%211 = add nsw i32 %210, 1
store i32 %211, i32* %14
br label %112
212: ; preds = %112
br label %102
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [5 x i8] c"3490\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"selectserver: %s\0A\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [30 x i8] c"selectserver: failed to bind\0A\00"
@.str.3 = [7 x i8] c"listen\00"
@.str.4 = [7 x i8] c"select\00"
@.str.5 = [29 x i8] c"Found something waiting %d \0A\00"
@.str.6 = [7 x i8] c"accept\00"
@.str.7 = [51 x i8] c"selectserver: new connection from %s on socket %d\0A\00"
@.str.8 = [33 x i8] c"selectserver: socket %d hung up\0A\00"
@.str.9 = [5 x i8] c"recv\00"
@.str.10 = [24 x i8] c"Got some data %d %d %d\0A\00"
@.str.11 = [5 x i8] c"send\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.sockaddr_storage
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca i32
%7 = alloca %struct.addrinfo
%8 = alloca %struct.addrinfo*
%9 = bitcast i32* %1 to i8*
%10 = bitcast i32* %2 to i8*
%11 = bitcast %struct.sockaddr_storage* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%14 = load i32, i32* @INET6_ADDRSTRLEN
%15 = zext i32 %14 to i64
%16 = alloca i8, i64 %15
%17 = bitcast i32* %6 to i8*
store i32 1, i32* %6
%18 = bitcast %struct.addrinfo* %7 to i8*
%19 = bitcast %struct.addrinfo** %8 to i8*
%20 = call i32 @FD_ZERO(i32* %1)
%21 = call i32 @FD_ZERO(i32* %2)
%22 = call i32 @memset(%struct.addrinfo* %7, i32 0, i32 40)
%23 = load i32, i32* @AF_UNSPEC
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 4
store i32 %23, i32* %24
%25 = load i32, i32* @SOCK_STREAM
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 3
store i32 %25, i32* %26
%27 = load i32, i32* @AI_PASSIVE
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 6
store i32 %27, i32* %28
%29 = call i32 @getaddrinfo(i32* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %7, %struct.addrinfo** %8)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %0
%32 = load %struct.addrinfo*, %struct.addrinfo** %8
%33 = icmp eq %struct.addrinfo* %32, null
br i1 %33, label %65, label %39
34: ; preds = %0
%35 = load i32, i32* @stderr
%36 = call i8* @gai_strerror(i32 %29)
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %36)
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %31, %61
%40 = phi %struct.addrinfo* [ %63, %61 ], [ %32, %31 ]
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 4
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 3
%44 = load i32, i32* %43
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 2
%46 = load i32, i32* %45
%47 = call i32 @socket(i32 %42, i32 %44, i32 %46)
%48 = icmp slt i32 %47, 0
br i1 %48, label %61, label %49
49: ; preds = %39
%50 = load i32, i32* @SOL_SOCKET
%51 = load i32, i32* @SO_REUSEADDR
%52 = call i32 @setsockopt(i32 %47, i32 %50, i32 %51, i32* %6, i32 4)
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 1
%54 = load i32, i32* %53
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 0
%56 = load i32, i32* %55
%57 = call i64 @bind(i32 %47, i32 %54, i32 %56)
%58 = icmp slt i64 %57, 0
br i1 %58, label %59, label %69
59: ; preds = %49
%60 = call i32 @close(i32 %47)
br label %61
61: ; preds = %39, %59
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 5
%63 = load %struct.addrinfo*, %struct.addrinfo** %62
%64 = icmp eq %struct.addrinfo* %63, null
br i1 %64, label %65, label %39
65: ; preds = %61, %31
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%68 = call i32 @exit(i32 2)
unreachable
69: ; preds = %49
%70 = load %struct.addrinfo*, %struct.addrinfo** %8
%71 = call i32 @freeaddrinfo(%struct.addrinfo* %70)
%72 = call i32 @listen(i32 %47, i32 10)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %77
74: ; preds = %69
%75 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%76 = call i32 @exit(i32 3)
unreachable
77: ; preds = %69
%78 = call i32 @FD_SET(i32 %47, i32* %1)
%79 = load i32, i32* %1
store i32 %79, i32* %2
%80 = add nuw nsw i32 %47, 1
%81 = call i32 @select(i32 %80, i32* %2, i32* null, i32* null, i32* null)
%82 = icmp eq i32 %81, -1
br i1 %82, label %95, label %83
83: ; preds = %77
%84 = bitcast %struct.sockaddr_storage* %3 to %struct.sockaddr*
%85 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %3, i64 0, i32 0
br label %92
86: ; preds = %151, %92
%87 = phi i32 [ %93, %92 ], [ %152, %151 ]
%88 = load i32, i32* %1
store i32 %88, i32* %2
%89 = add nsw i32 %87, 1
%90 = call i32 @select(i32 %89, i32* %2, i32* null, i32* null, i32* null)
%91 = icmp eq i32 %90, -1
br i1 %91, label %95, label %92
92: ; preds = %83, %86
%93 = phi i32 [ %47, %83 ], [ %87, %86 ]
%94 = icmp slt i32 %93, 0
br i1 %94, label %86, label %98
95: ; preds = %86, %77
%96 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%97 = call i32 @exit(i32 4)
unreachable
98: ; preds = %92, %151
%99 = phi i32 [ %152, %151 ], [ %93, %92 ]
%100 = phi i32 [ %153, %151 ], [ 0, %92 ]
%101 = call i64 @FD_ISSET(i32 %100, i32* %2)
%102 = icmp eq i64 %101, 0
br i1 %102, label %151, label %103
103: ; preds = %98
%104 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %100)
%105 = icmp eq i32 %100, %47
br i1 %105, label %106, label %120
106: ; preds = %103
store i32 4, i32* %4
%107 = call i32 @accept(i32 %47, %struct.sockaddr* %84, i32* %4)
%108 = icmp eq i32 %107, -1
br i1 %108, label %109, label %111
109: ; preds = %106
%110 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %151
111: ; preds = %106
%112 = call i32 @FD_SET(i32 %107, i32* %1)
%113 = icmp sgt i32 %107, %99
%114 = select i1 %113, i32 %107, i32 %99
%115 = load i32, i32* %85
%116 = call i32 @get_in_addr(%struct.sockaddr* %84)
%117 = load i32, i32* @INET6_ADDRSTRLEN
%118 = call i8* @inet_ntop(i32 %115, i32 %116, i8* %16, i32 %117)
%119 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i8* %118, i32 %107)
br label %151
120: ; preds = %103
%121 = call i32 @recv(i32 %100, i8* %13, i32 256, i32 0)
%122 = icmp slt i32 %121, 1
br i1 %122, label %123, label %132
123: ; preds = %120
%124 = icmp eq i32 %121, 0
br i1 %124, label %125, label %127
125: ; preds = %123
%126 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %100)
br label %129
127: ; preds = %123
%128 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %129
129: ; preds = %127, %125
%130 = call i32 @close(i32 %100)
%131 = call i32 @FD_CLR(i32 %100, i32* %1)
br label %151
132: ; preds = %120
%133 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %47, i32 %100, i32 %99)
%134 = icmp slt i32 %99, 0
br i1 %134, label %151, label %135
135: ; preds = %132, %148
%136 = phi i32 [ %149, %148 ], [ 0, %132 ]
%137 = call i64 @FD_ISSET(i32 %136, i32* %1)
%138 = icmp eq i64 %137, 0
%139 = icmp eq i32 %136, %47
%140 = select i1 %138, i1 true, i1 %139
%141 = icmp eq i32 %136, %100
%142 = or i1 %140, %141
br i1 %142, label %148, label %143
143: ; preds = %135
%144 = call i32 @send(i32 %136, i8* %13, i32 %121, i32 0)
%145 = icmp eq i32 %144, -1
br i1 %145, label %146, label %148
146: ; preds = %143
%147 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %148
148: ; preds = %135, %143, %146
%149 = add nuw i32 %136, 1
%150 = icmp eq i32 %136, %99
br i1 %150, label %151, label %135
151: ; preds = %148, %132, %98, %129, %109, %111
%152 = phi i32 [ %99, %109 ], [ %114, %111 ], [ %99, %129 ], [ %99, %98 ], [ %99, %132 ], [ %99, %148 ]
%153 = add nuw nsw i32 %100, 1
%154 = icmp slt i32 %100, %152
br i1 %154, label %98, label %86
}