#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_in {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ recvbuf;
typedef int /*<<< orphan*/ op;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ EINTR;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ FD_CLR(int, int /*<<< orphan*/ *);
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int FD_SETSIZE;
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SOMAXCONN;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_aton(char *, int /*<<< orphan*/ *);
int listen(int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char **, int, int);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int main(void) {
  fd_set rset;
  fd_set allset;
  int i;
  int maxfd;
  int connfd;
  int nready;
  int listenfd;
  int maxi = 0;
  char recvbuf[1024];
  int client[FD_SETSIZE];
  struct sockaddr_in addr;
  for (i = 0; i < FD_SETSIZE; i++)
    client[i] = -1;
  if ((listenfd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
    do {
      fprintf(stderr, "[%s][%d] %s %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/"
              "master/apue/day12/select_svr.c",
              37, "socket", strerror(errno));
      exit(EXIT_FAILURE);
    } while (0);
  addr.sin_family = AF_INET;
  addr.sin_port = htons(9999);
  inet_aton("192.168.0.200", &addr.sin_addr);
  int op = 1;
  signal(SIGPIPE, SIG_IGN);
  setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &op, sizeof(op));
  if (bind(listenfd, (struct sockaddr *)&addr, sizeof(addr)) == -1)
    do {
      fprintf(stderr, "[%s][%d] %s %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/"
              "master/apue/day12/select_svr.c",
              45, "bind", strerror(errno));
      exit(EXIT_FAILURE);
    } while (0);
  if (listen(listenfd, SOMAXCONN) == -1)
    do {
      fprintf(stderr, "[%s][%d] %s %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/"
              "master/apue/day12/select_svr.c",
              47, "listen", strerror(errno));
      exit(EXIT_FAILURE);
    } while (0);
  FD_ZERO(&rset);
  FD_ZERO(&allset);
  FD_SET(listenfd, &allset);
  maxfd = listenfd;
  for (;;) {
    rset = allset;
    nready = select(maxfd + 1, &rset, NULL, NULL, NULL);
    if (nready == -1) {
      if (errno == EINTR)
        continue;
      do {
        fprintf(stderr, "[%s][%d] %s %s\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/"
                "heads/master/apue/day12/select_svr.c",
                59, "select", strerror(errno));
        exit(EXIT_FAILURE);
      } while (0);
    }
    if (FD_ISSET(listenfd, &rset)) {
      connfd = accept(listenfd, NULL, NULL);
      for (i = 0; i < FD_SETSIZE; i++) {
        if (client[i] == -1) {
          client[i] = connfd;
          if (i > maxi)
            maxi = i;
          break;
        }
      }
      if (i == FD_SETSIZE) {
        printf("too many clients!\n");
        do {
          fprintf(stderr, "[%s][%d] %s %s\n",
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/"
                  "heads/master/apue/day12/select_svr.c",
                  73, "accept", strerror(errno));
          exit(EXIT_FAILURE);
        } while (0);
      }
      FD_SET(connfd, &allset);
      if (connfd > maxfd)
        maxfd = connfd;
      if (--nready <= 0) {
        continue;
      }
    }
    for (i = 0; i <= maxi; i++) {
      connfd = client[i];
      if (connfd == -1)
        continue;
      if (FD_ISSET(connfd, &rset)) {
        memset(&recvbuf, 0x00, sizeof(recvbuf));
        int ret = read(connfd, recvbuf, 1024);
        if (ret == 0) {
          printf("client close!\n");
          client[i] = -1;
          FD_CLR(connfd, &allset);
        }
        write(connfd, recvbuf, strlen(recvbuf));
        if (--nready <= 0)
          break;
      }
    }
  }
  close(listenfd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2d38(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x438(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x460(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x440(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2cf8(%rip),%rcx
cmp    (%rcx),%eax
jge    12d8 <main+0x88>
mov    -0x460(%rbp),%rax
movslq -0x10(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12a6 <main+0x56>
mov    0x2cb9(%rip),%rax
mov    (%rax),%edi
mov    0x2cd0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1170 <socket@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    1356 <main+0x106>
jmp    1302 <main+0xb2>
mov    0x2cbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x464(%rbp)
mov    0x2c88(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x464(%rbp),%edi
mov    %rax,%r9
lea    0xcd0(%rip),%rsi
lea    0xcd9(%rip),%rdx
mov    $0x25,%ecx
lea    0xd66(%rip),%r8
call   10c0 <fprintf@plt>
mov    0x2c41(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    0x2c83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x448(%rbp)
mov    $0x270f,%edi
call   1070 <htons@plt>
mov    %eax,-0x44c(%rbp)
lea    -0x450(%rbp),%rsi
lea    0xd2d(%rip),%rdi
call   10f0 <inet_aton@plt>
movl   $0x1,-0x454(%rbp)
mov    0x2c17(%rip),%rax
mov    (%rax),%edi
mov    0x2c36(%rip),%rax
mov    (%rax),%esi
call   10b0 <signal@plt>
mov    -0x20(%rbp),%edi
mov    0x2c35(%rip),%rax
mov    (%rax),%esi
mov    0x2bc4(%rip),%rax
mov    (%rax),%edx
lea    -0x454(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    -0x20(%rbp),%edi
lea    -0x450(%rbp),%rsi
mov    $0xc,%edx
call   1110 <bind@plt>
cmp    $0xffffffff,%eax
jne    1446 <main+0x1f6>
jmp    13f2 <main+0x1a2>
mov    0x2bcf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x468(%rbp)
mov    0x2b98(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x468(%rbp),%edi
mov    %rax,%r9
lea    0xbe0(%rip),%rsi
lea    0xbe9(%rip),%rdx
mov    $0x2d,%ecx
lea    0xc8b(%rip),%r8
call   10c0 <fprintf@plt>
mov    0x2b51(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x20(%rbp),%edi
mov    0x2b70(%rip),%rax
mov    (%rax),%esi
call   1100 <listen@plt>
cmp    $0xffffffff,%eax
jne    14b9 <main+0x269>
jmp    1465 <main+0x215>
mov    0x2b5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x46c(%rbp)
mov    0x2b25(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x46c(%rbp),%edi
mov    %rax,%r9
lea    0xb6d(%rip),%rsi
lea    0xb76(%rip),%rdx
mov    $0x2f,%ecx
lea    0xc1d(%rip),%r8
call   10c0 <fprintf@plt>
mov    0x2ade(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
lea    -0x8(%rbp),%rdi
call   10d0 <FD_ZERO@plt>
lea    -0xc(%rbp),%rdi
call   10d0 <FD_ZERO@plt>
mov    -0x20(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1160 <FD_SET@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10e0 <select@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1582 <main+0x332>
mov    0x2a8f(%rip),%rax
mov    (%rax),%rax
mov    0x2a6d(%rip),%rcx
cmp    (%rcx),%rax
jne    1529 <main+0x2d9>
jmp    14dd <main+0x28d>
jmp    152e <main+0x2de>
mov    0x2a93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x470(%rbp)
mov    0x2a5c(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x470(%rbp),%edi
mov    %rax,%r9
lea    0xaa4(%rip),%rsi
lea    0xaad(%rip),%rdx
mov    $0x3b,%ecx
lea    0xb5b(%rip),%r8
call   10c0 <fprintf@plt>
mov    0x2a15(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x20(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     16bf <main+0x46f>
mov    -0x20(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1120 <accept@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    0x29ed(%rip),%rcx
cmp    (%rcx),%eax
jge    1613 <main+0x3c3>
mov    -0x460(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
jne    1600 <main+0x3b0>
mov    -0x460(%rbp),%rax
mov    -0x18(%rbp),%edx
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    15fb <main+0x3ab>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1613 <main+0x3c3>
jmp    1605 <main+0x3b5>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    15b1 <main+0x361>
mov    -0x10(%rbp),%eax
mov    0x298b(%rip),%rcx
cmp    (%rcx),%eax
jne    1685 <main+0x435>
lea    0xaa5(%rip),%rdi
call   1080 <printf@plt>
mov    0x2990(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x474(%rbp)
mov    0x2959(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
mov    -0x474(%rbp),%edi
mov    %rax,%r9
lea    0x9a1(%rip),%rsi
lea    0x9aa(%rip),%rdx
mov    $0x49,%ecx
lea    0xa72(%rip),%r8
call   10c0 <fprintf@plt>
mov    0x2912(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x18(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1160 <FD_SET@plt>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    16a3 <main+0x453>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jg     16ba <main+0x46a>
jmp    14dd <main+0x28d>
jmp    16bf <main+0x46f>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     17d2 <main+0x582>
mov    -0x460(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    16f2 <main+0x4a2>
jmp    17c4 <main+0x574>
mov    -0x18(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     17bf <main+0x56f>
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
mov    -0x18(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
mov    %eax,-0x458(%rbp)
cmpl   $0x0,-0x458(%rbp)
jne    176c <main+0x51c>
lea    0x9a2(%rip),%rdi
call   1080 <printf@plt>
mov    -0x460(%rbp),%rax
movslq -0x10(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x18(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1130 <FD_CLR@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x484(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x480(%rbp)
lea    -0x430(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x484(%rbp),%edi
mov    -0x480(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jg     17ba <main+0x56a>
jmp    17d2 <main+0x582>
jmp    17bf <main+0x56f>
jmp    17c4 <main+0x574>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    16c6 <main+0x476>
jmp    14dd <main+0x28d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x448,%rsp
mov    0x2d3d(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
lea    0xf(,%rdx,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
test   %edx,%edx
jle    129c <main+0x4c>
shl    $0x2,%rdx
mov    -0x30(%rbp),%rdi
mov    $0xff,%esi
call   1090 <memset@plt>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
mov    0x2d0c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1170 <socket@plt>
cmp    $0xffffffff,%eax
jne    12f3 <main+0xa3>
mov    0x2d07(%rip),%rax
mov    (%rax),%ebx
mov    0x2cd6(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
lea    0xd27(%rip),%rsi
lea    0xd30(%rip),%rdx
lea    0xdc2(%rip),%r8
mov    %ebx,%edi
mov    $0x25,%ecx
jmp    1695 <main+0x445>
mov    %eax,%r15d
mov    0x2ce3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    $0x270f,%edi
call   1080 <htons@plt>
mov    %eax,-0x64(%rbp)
lea    0xd9a(%rip),%rdi
lea    -0x68(%rbp),%rbx
mov    %rbx,%rsi
call   10f0 <inet_aton@plt>
movl   $0x1,-0x4c(%rbp)
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
mov    0x2c9f(%rip),%rax
mov    (%rax),%esi
call   10b0 <signal@plt>
mov    0x2ca1(%rip),%rax
mov    (%rax),%esi
mov    0x2c30(%rip),%rax
mov    (%rax),%edx
lea    -0x4c(%rbp),%rcx
mov    %r15d,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1110 <bind@plt>
cmp    $0xffffffff,%eax
jne    13b2 <main+0x162>
mov    0x2c48(%rip),%rax
mov    (%rax),%ebx
mov    0x2c17(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
lea    0xc68(%rip),%rsi
lea    0xc71(%rip),%rdx
lea    0xd18(%rip),%r8
mov    %ebx,%edi
mov    $0x2d,%ecx
jmp    1695 <main+0x445>
mov    0x2c07(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
call   1100 <listen@plt>
cmp    $0xffffffff,%eax
jne    1401 <main+0x1b1>
mov    0x2bf9(%rip),%rax
mov    (%rax),%ebx
mov    0x2bc8(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
lea    0xc19(%rip),%rsi
lea    0xc22(%rip),%rdx
lea    0xcce(%rip),%r8
mov    %ebx,%edi
mov    $0x2f,%ecx
jmp    1695 <main+0x445>
lea    -0x50(%rbp),%r13
mov    %r13,%rdi
call   10d0 <FD_ZERO@plt>
lea    -0x34(%rbp),%rbx
mov    %rbx,%rdi
call   10d0 <FD_ZERO@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
call   1160 <FD_SET@plt>
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
mov    0x2b6f(%rip),%r14
mov    %r15d,%eax
mov    %rax,-0x48(%rbp)
mov    %r15d,-0x38(%rbp)
jmp    144b <main+0x1fb>
xchg   %ax,%ax
mov    -0x38(%rbp),%r15d
mov    0x2b55(%rip),%r14
mov    -0x48(%rbp),%rax
lea    0x1(%rax),%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    -0x34(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    %ebx,%edi
mov    %r13,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <select@plt>
cmp    $0xffffffff,%eax
jne    1490 <main+0x240>
mov    (%r14),%rdi
mov    0x2b02(%rip),%rax
cmp    (%rax),%rdi
je     1460 <main+0x210>
jmp    1629 <main+0x3d9>
mov    %eax,%r12d
mov    %r15d,%edi
mov    %r13,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     1550 <main+0x300>
xor    %ebx,%ebx
mov    %r15d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1120 <accept@plt>
mov    %eax,%r14d
mov    0x2ae9(%rip),%rax
mov    (%rax),%eax
test   %eax,%eax
jle    1501 <main+0x2b1>
xor    %ebx,%ebx
mov    -0x30(%rbp),%rcx
nopl   0x0(%rax,%rax,1)
cmpl   $0xffffffff,(%rcx,%rbx,4)
je     14f0 <main+0x2a0>
add    $0x1,%rbx
cmp    %rbx,%rax
jne    14d0 <main+0x280>
jmp    1655 <main+0x405>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14d,(%rcx,%rbx,4)
mov    -0x40(%rbp),%rcx
cmp    %ebx,%ecx
cmovl  %ebx,%ecx
mov    %rcx,-0x40(%rbp)
cmp    %eax,%ebx
je     1655 <main+0x405>
mov    %r14d,%edi
lea    -0x34(%rbp),%rsi
call   1160 <FD_SET@plt>
mov    -0x30(%rbp),%rax
mov    -0x48(%rbp),%rcx
cmp    %ecx,%r14d
cmovg  %r14d,%ecx
mov    %rcx,-0x48(%rbp)
cmp    $0x2,%r12d
mov    0x2a6d(%rip),%r14
jl     144b <main+0x1fb>
add    $0xffffffff,%r12d
cmpl   $0x0,-0x40(%rbp)
jns    155e <main+0x30e>
jmp    144b <main+0x1fb>
nopl   0x0(%rax,%rax,1)
mov    -0x30(%rbp),%rax
cmpl   $0x0,-0x40(%rbp)
js     144b <main+0x1fb>
mov    -0x40(%rbp),%rcx
lea    0x1(%rcx),%r14d
xor    %r15d,%r15d
mov    %r14,-0x58(%rbp)
jmp    15ae <main+0x35e>
nop
mov    %r13,%rdi
call   1070 <strlen@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    -0x1(%r12),%eax
cmp    $0x2,%r12d
mov    %eax,%r12d
mov    -0x30(%rbp),%rax
mov    %r14,%r13
mov    -0x58(%rbp),%r14
jl     1440 <main+0x1f0>
add    $0x1,%r15
cmp    %r15,%r14
je     1440 <main+0x1f0>
mov    (%rax,%r15,4),%ebx
cmp    $0xffffffff,%ebx
je     15a1 <main+0x351>
mov    %ebx,%edi
mov    %r13,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     1620 <main+0x3d0>
mov    %r13,%r14
lea    -0x470(%rbp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
test   %eax,%eax
jne    1570 <main+0x320>
lea    0xadb(%rip),%rdi
call   1030 <puts@plt>
mov    -0x30(%rbp),%rax
movl   $0xffffffff,(%rax,%r15,4)
ff
mov    %ebx,%edi
lea    -0x34(%rbp),%rsi
call   1130 <FD_CLR@plt>
jmp    1570 <main+0x320>
xchg   %ax,%ax
mov    -0x30(%rbp),%rax
jmp    15a1 <main+0x351>
mov    0x2998(%rip),%rax
mov    (%rax),%ebx
call   1150 <strerror@plt>
lea    0x9c2(%rip),%rsi
lea    0x9cb(%rip),%rdx
lea    0xa7e(%rip),%r8
mov    %ebx,%edi
mov    $0x3b,%ecx
jmp    1695 <main+0x445>
lea    0xa8a(%rip),%rdi
call   1030 <puts@plt>
mov    0x2960(%rip),%rax
mov    (%rax),%ebx
mov    0x292f(%rip),%rax
mov    (%rax),%rdi
call   1150 <strerror@plt>
lea    0x980(%rip),%rsi
lea    0x989(%rip),%rdx
lea    0xa43(%rip),%r8
mov    %ebx,%edi
mov    $0x49,%ecx
mov    %rax,%r9
call   10c0 <fprintf@plt>
mov    0x28ec(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@FD_SETSIZE = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"[%s][%d] %s %s\0A\00"
@.str.1 = [153 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/master/apue/day12/select_svr.c\00"
@.str.2 = [7 x i8] c"socket\00"
@errno = global i64 0
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@.str.3 = [14 x i8] c"192.168.0.200\00"
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.4 = [5 x i8] c"bind\00"
@SOMAXCONN = global i32 0
@.str.5 = [7 x i8] c"listen\00"
@EINTR = global i64 0
@.str.6 = [7 x i8] c"select\00"
@.str.7 = [19 x i8] c"too many clients!\0A\00"
@.str.8 = [7 x i8] c"accept\00"
@.str.9 = [15 x i8] c"client close!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [1024 x i8]
%11 = alloca i8*
%12 = alloca i64
%13 = alloca %struct.sockaddr_in
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %9
%16 = load i32, i32* @FD_SETSIZE
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %11
%19 = alloca i32, i64 %17
store i64 %17, i64* %12
store i32 0, i32* %4
br label %20
20: ; preds = %28, %0
%21 = load i32, i32* %4
%22 = load i32, i32* @FD_SETSIZE
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %19, i64 %26
store i32 -1, i32* %27
br label %28
28: ; preds = %24
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %20
31: ; preds = %20
%32 = load i32, i32* @PF_INET
%33 = load i32, i32* @SOCK_STREAM
%34 = call i32 @socket(i32 %32, i32 %33, i32 0)
store i32 %34, i32* %8
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %46
36: ; preds = %31
br label %37
37: ; preds = %36
%38 = load i32, i32* @stderr
%39 = load i64, i64* @errno
%40 = call i8* @strerror(i64 %39)
%41 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %40)
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; No predecessors!
br label %45
45: ; preds = %44
br label %46
46: ; preds = %45, %31
%47 = load i32, i32* @AF_INET
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 2
store i32 %47, i32* %48
%49 = call i32 @htons(i32 9999)
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
store i32 %49, i32* %50
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 0
%52 = call i32 @inet_aton(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32* %51)
store i32 1, i32* %14
%53 = load i32, i32* @SIGPIPE
%54 = load i32, i32* @SIG_IGN
%55 = call i32 @signal(i32 %53, i32 %54)
%56 = load i32, i32* %8
%57 = load i32, i32* @SOL_SOCKET
%58 = load i32, i32* @SO_REUSEADDR
%59 = call i32 @setsockopt(i32 %56, i32 %57, i32 %58, i32* %14, i32 4)
%60 = load i32, i32* %8
%61 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%62 = call i32 @bind(i32 %60, %struct.sockaddr* %61, i32 12)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %74
64: ; preds = %46
br label %65
65: ; preds = %64
%66 = load i32, i32* @stderr
%67 = load i64, i64* @errno
%68 = call i8* @strerror(i64 %67)
%69 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %68)
%70 = load i32, i32* @EXIT_FAILURE
%71 = call i32 @exit(i32 %70)
unreachable
72: ; No predecessors!
br label %73
73: ; preds = %72
br label %74
74: ; preds = %73, %46
%75 = load i32, i32* %8
%76 = load i32, i32* @SOMAXCONN
%77 = call i32 @listen(i32 %75, i32 %76)
%78 = icmp eq i32 %77, -1
br i1 %78, label %79, label %89
79: ; preds = %74
br label %80
80: ; preds = %79
%81 = load i32, i32* @stderr
%82 = load i64, i64* @errno
%83 = call i8* @strerror(i64 %82)
%84 = call i32 @fprintf(i32 %81, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %83)
%85 = load i32, i32* @EXIT_FAILURE
%86 = call i32 @exit(i32 %85)
unreachable
87: ; No predecessors!
br label %88
88: ; preds = %87
br label %89
89: ; preds = %88, %74
%90 = call i32 @FD_ZERO(i32* %2)
%91 = call i32 @FD_ZERO(i32* %3)
%92 = load i32, i32* %8
%93 = call i32 @FD_SET(i32 %92, i32* %3)
%94 = load i32, i32* %8
store i32 %94, i32* %5
br label %95
95: ; preds = %225, %176, %106, %89
%96 = load i32, i32* %3
store i32 %96, i32* %2
%97 = load i32, i32* %5
%98 = add nsw i32 %97, 1
%99 = call i32 @select(i32 %98, i32* %2, i32* null, i32* null, i32* null)
store i32 %99, i32* %7
%100 = load i32, i32* %7
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %117
102: ; preds = %95
%103 = load i64, i64* @errno
%104 = load i64, i64* @EINTR
%105 = icmp eq i64 %103, %104
br i1 %105, label %106, label %107
106: ; preds = %102
br label %95
107: ; preds = %102
br label %108
108: ; preds = %107
%109 = load i32, i32* @stderr
%110 = load i64, i64* @errno
%111 = call i8* @strerror(i64 %110)
%112 = call i32 @fprintf(i32 %109, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 59, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %111)
%113 = load i32, i32* @EXIT_FAILURE
%114 = call i32 @exit(i32 %113)
unreachable
115: ; No predecessors!
br label %116
116: ; preds = %115
br label %117
117: ; preds = %116, %95
%118 = load i32, i32* %8
%119 = call i64 @FD_ISSET(i32 %118, i32* %2)
%120 = icmp ne i64 %119, 0
br i1 %120, label %121, label %178
121: ; preds = %117
%122 = load i32, i32* %8
%123 = call i32 @accept(i32 %122, i32* null, i32* null)
store i32 %123, i32* %6
store i32 0, i32* %4
br label %124
124: ; preds = %146, %121
%125 = load i32, i32* %4
%126 = load i32, i32* @FD_SETSIZE
%127 = icmp slt i32 %125, %126
br i1 %127, label %128, label %149
128: ; preds = %124
%129 = load i32, i32* %4
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i32, i32* %19, i64 %130
%132 = load i32, i32* %131
%133 = icmp eq i32 %132, -1
br i1 %133, label %134, label %145
134: ; preds = %128
%135 = load i32, i32* %6
%136 = load i32, i32* %4
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i32, i32* %19, i64 %137
store i32 %135, i32* %138
%139 = load i32, i32* %4
%140 = load i32, i32* %9
%141 = icmp sgt i32 %139, %140
br i1 %141, label %142, label %144
142: ; preds = %134
%143 = load i32, i32* %4
store i32 %143, i32* %9
br label %144
144: ; preds = %142, %134
br label %149
145: ; preds = %128
br label %146
146: ; preds = %145
%147 = load i32, i32* %4
%148 = add nsw i32 %147, 1
store i32 %148, i32* %4
br label %124
149: ; preds = %144, %124
%150 = load i32, i32* %4
%151 = load i32, i32* @FD_SETSIZE
%152 = icmp eq i32 %150, %151
br i1 %152, label %153, label %164
153: ; preds = %149
%154 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %155
155: ; preds = %153
%156 = load i32, i32* @stderr
%157 = load i64, i64* @errno
%158 = call i8* @strerror(i64 %157)
%159 = call i32 @fprintf(i32 %156, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 73, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %158)
%160 = load i32, i32* @EXIT_FAILURE
%161 = call i32 @exit(i32 %160)
unreachable
162: ; No predecessors!
br label %163
163: ; preds = %162
br label %164
164: ; preds = %163, %149
%165 = load i32, i32* %6
%166 = call i32 @FD_SET(i32 %165, i32* %3)
%167 = load i32, i32* %6
%168 = load i32, i32* %5
%169 = icmp sgt i32 %167, %168
br i1 %169, label %170, label %172
170: ; preds = %164
%171 = load i32, i32* %6
store i32 %171, i32* %5
br label %172
172: ; preds = %170, %164
%173 = load i32, i32* %7
%174 = add nsw i32 %173, -1
store i32 %174, i32* %7
%175 = icmp sle i32 %174, 0
br i1 %175, label %176, label %177
176: ; preds = %172
br label %95
177: ; preds = %172
br label %178
178: ; preds = %177, %117
store i32 0, i32* %4
br label %179
179: ; preds = %222, %178
%180 = load i32, i32* %4
%181 = load i32, i32* %9
%182 = icmp sle i32 %180, %181
br i1 %182, label %183, label %225
183: ; preds = %179
%184 = load i32, i32* %4
%185 = sext i32 %184 to i64
%186 = getelementptr inbounds i32, i32* %19, i64 %185
%187 = load i32, i32* %186
store i32 %187, i32* %6
%188 = load i32, i32* %6
%189 = icmp eq i32 %188, -1
br i1 %189, label %190, label %191
190: ; preds = %183
br label %222
191: ; preds = %183
%192 = load i32, i32* %6
%193 = call i64 @FD_ISSET(i32 %192, i32* %2)
%194 = icmp ne i64 %193, 0
br i1 %194, label %195, label %221
195: ; preds = %191
%196 = bitcast [1024 x i8]* %10 to i8**
%197 = call i32 @memset(i8** %196, i32 0, i32 1024)
%198 = load i32, i32* %6
%199 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%200 = call i32 @read(i32 %198, i8* %199, i32 1024)
store i32 %200, i32* %15
%201 = load i32, i32* %15
%202 = icmp eq i32 %201, 0
br i1 %202, label %203, label %210
203: ; preds = %195
%204 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%205 = load i32, i32* %4
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds i32, i32* %19, i64 %206
store i32 -1, i32* %207
%208 = load i32, i32* %6
%209 = call i32 @FD_CLR(i32 %208, i32* %3)
br label %210
210: ; preds = %203, %195
%211 = load i32, i32* %6
%212 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%213 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%214 = call i32 @strlen(i8* %213)
%215 = call i32 @write(i32 %211, i8* %212, i32 %214)
%216 = load i32, i32* %7
%217 = add nsw i32 %216, -1
store i32 %217, i32* %7
%218 = icmp sle i32 %217, 0
br i1 %218, label %219, label %220
219: ; preds = %210
br label %225
220: ; preds = %210
br label %221
221: ; preds = %220, %191
br label %222
222: ; preds = %221, %190
%223 = load i32, i32* %4
%224 = add nsw i32 %223, 1
store i32 %224, i32* %4
br label %179
225: ; preds = %219, %179
br label %95
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@FD_SETSIZE = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"[%s][%d] %s %s\0A\00"
@.str.1 = [153 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/master/apue/day12/select_svr.c\00"
@.str.2 = [7 x i8] c"socket\00"
@errno = global i64 0
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@.str.3 = [14 x i8] c"192.168.0.200\00"
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.4 = [5 x i8] c"bind\00"
@SOMAXCONN = global i32 0
@.str.5 = [7 x i8] c"listen\00"
@EINTR = global i64 0
@.str.6 = [7 x i8] c"select\00"
@.str.8 = [7 x i8] c"accept\00"
@str = [14 x i8] c"client close!\00"
@str.10 = [18 x i8] c"too many clients!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = load i32, i32* @FD_SETSIZE
%10 = zext i32 %9 to i64
%11 = alloca i32, i64 %10
%12 = bitcast %struct.sockaddr_in* %4 to i8*
%13 = icmp sgt i32 %9, 0
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = bitcast i32* %11 to i8*
%16 = shl nuw nsw i64 %10, 2
br label %17
17: ; preds = %14, %0
%18 = load i32, i32* @PF_INET
%19 = load i32, i32* @SOCK_STREAM
%20 = tail call i32 @socket(i32 %18, i32 %19, i32 0)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %29
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = load i64, i64* @errno
%25 = tail call i8* @strerror(i64 %24)
%26 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = tail call i32 @exit(i32 %27)
unreachable
29: ; preds = %17
%30 = load i32, i32* @AF_INET
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %30, i32* %31
%32 = tail call i32 @htons(i32 9999)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %32, i32* %33
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%35 = call i32 @inet_aton(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32* %34)
%36 = bitcast i32* %5 to i8*
store i32 1, i32* %5
%37 = load i32, i32* @SIGPIPE
%38 = load i32, i32* @SIG_IGN
%39 = call i32 @signal(i32 %37, i32 %38)
%40 = load i32, i32* @SOL_SOCKET
%41 = load i32, i32* @SO_REUSEADDR
%42 = call i32 @setsockopt(i32 %20, i32 %40, i32 %41, i32* %5, i32 4)
%43 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%44 = call i32 @bind(i32 %20, %struct.sockaddr* %43, i32 12)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %53
46: ; preds = %29
%47 = load i32, i32* @stderr
%48 = load i64, i64* @errno
%49 = call i8* @strerror(i64 %48)
%50 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %49)
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %29
%54 = load i32, i32* @SOMAXCONN
%55 = call i32 @listen(i32 %20, i32 %54)
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %64
57: ; preds = %53
%58 = load i32, i32* @stderr
%59 = load i64, i64* @errno
%60 = call i8* @strerror(i64 %59)
%61 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %60)
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @exit(i32 %62)
unreachable
64: ; preds = %53
%65 = call i32 @FD_ZERO(i32* %1)
%66 = call i32 @FD_ZERO(i32* %2)
%67 = call i32 @FD_SET(i32 %20, i32* %2)
%68 = bitcast [1024 x i8]* %3 to i8**
br label %69
69: ; preds = %133, %64
%70 = phi i32 [ 0, %64 ], [ %134, %133 ]
%71 = phi i32 [ %20, %64 ], [ %135, %133 ]
%72 = add nsw i32 %71, 1
br label %73
73: ; preds = %69, %77
%74 = load i32, i32* %2
store i32 %74, i32* %1
%75 = call i32 @select(i32 %72, i32* %1, i32* null, i32* null, i32* null)
%76 = icmp eq i32 %75, -1
br i1 %76, label %77, label %87
77: ; preds = %73
%78 = load i64, i64* @errno
%79 = load i64, i64* @EINTR
%80 = icmp eq i64 %78, %79
br i1 %80, label %73, label %81
81: ; preds = %77
%82 = load i32, i32* @stderr
%83 = call i8* @strerror(i64 %78)
%84 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 59, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %83)
%85 = load i32, i32* @EXIT_FAILURE
%86 = call i32 @exit(i32 %85)
unreachable
87: ; preds = %73
%88 = call i64 @FD_ISSET(i32 %20, i32* %1)
%89 = icmp eq i64 %88, 0
br i1 %89, label %128, label %90
90: ; preds = %87
%91 = call i32 @accept(i32 %20, i32* null, i32* null)
%92 = load i32, i32* @FD_SETSIZE
%93 = icmp sgt i32 %92, 0
br i1 %93, label %94, label %110
94: ; preds = %90
%95 = zext i32 %92 to i64
br label %96
96: ; preds = %94, %107
%97 = phi i64 [ 0, %94 ], [ %108, %107 ]
%98 = getelementptr inbounds i32, i32* %11, i64 %97
%99 = load i32, i32* %98
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %107
101: ; preds = %96
%102 = trunc i64 %97 to i32
%103 = and i64 %97, 4294967295
%104 = getelementptr inbounds i32, i32* %11, i64 %103
store i32 %91, i32* %104
%105 = icmp slt i32 %70, %102
%106 = select i1 %105, i32 %102, i32 %70
br label %110
107: ; preds = %96
%108 = add nuw nsw i64 %97, 1
%109 = icmp eq i64 %108, %95
br i1 %109, label %114, label %96
110: ; preds = %90, %101
%111 = phi i32 [ %102, %101 ], [ 0, %90 ]
%112 = phi i32 [ %106, %101 ], [ %70, %90 ]
%113 = icmp eq i32 %111, %92
br i1 %113, label %114, label %122
114: ; preds = %110, %107
%115 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
%116 = load i32, i32* @stderr
%117 = load i64, i64* @errno
%118 = call i8* @strerror(i64 %117)
%119 = call i32 @fprintf(i32 %116, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 73, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %118)
%120 = load i32, i32* @EXIT_FAILURE
%121 = call i32 @exit(i32 %120)
unreachable
122: ; preds = %110
%123 = call i32 @FD_SET(i32 %91, i32* %2)
%124 = icmp sgt i32 %91, %71
%125 = select i1 %124, i32 %91, i32 %71
%126 = add nsw i32 %75, -1
%127 = icmp slt i32 %75, 2
br i1 %127, label %133, label %128
128: ; preds = %122, %87
%129 = phi i32 [ %126, %122 ], [ %75, %87 ]
%130 = phi i32 [ %112, %122 ], [ %70, %87 ]
%131 = phi i32 [ %125, %122 ], [ %71, %87 ]
%132 = icmp slt i32 %130, 0
br i1 %132, label %133, label %136
133: ; preds = %160, %155, %128, %122
%134 = phi i32 [ %112, %122 ], [ %130, %128 ], [ %130, %155 ], [ %130, %160 ]
%135 = phi i32 [ %125, %122 ], [ %131, %128 ], [ %131, %155 ], [ %131, %160 ]
br label %69
136: ; preds = %128
%137 = add nuw i32 %130, 1
%138 = zext i32 %137 to i64
br label %139
139: ; preds = %136, %160
%140 = phi i64 [ 0, %136 ], [ %162, %160 ]
%141 = phi i32 [ %129, %136 ], [ %161, %160 ]
%142 = getelementptr inbounds i32, i32* %11, i64 %140
%143 = load i32, i32* %142
%144 = icmp eq i32 %143, -1
br i1 %144, label %160, label %145
145: ; preds = %139
%146 = call i64 @FD_ISSET(i32 %143, i32* %1)
%147 = icmp eq i64 %146, 0
br i1 %147, label %160, label %148
148: ; preds = %145
%149 = call i32 @memset(i8** %68, i32 0, i32 1024)
%150 = call i32 @read(i32 %143, i8* %8, i32 1024)
%151 = icmp eq i32 %150, 0
br i1 %151, label %152, label %155
152: ; preds = %148
%153 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
store i32 -1, i32* %142
%154 = call i32 @FD_CLR(i32 %143, i32* %2)
br label %155
155: ; preds = %152, %148
%156 = call i32 @strlen(i8* %8)
%157 = call i32 @write(i32 %143, i8* %8, i32 %156)
%158 = add nsw i32 %141, -1
%159 = icmp slt i32 %141, 2
br i1 %159, label %133, label %160
160: ; preds = %155, %145, %139
%161 = phi i32 [ %141, %139 ], [ %158, %155 ], [ %141, %145 ]
%162 = add nuw nsw i64 %140, 1
%163 = icmp eq i64 %162, %138
br i1 %163, label %133, label %139
}