#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ on;
typedef int /*<<< orphan*/ master_set;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ EWOULDBLOCK;
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 /*<<< orphan*/ FIONBIO;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
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);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int ioctl(int, int /*<<< orphan*/, char *);
int listen(int, int);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, 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*/ *, struct timeval *);
int send(int, char *, int, int /*<<< orphan*/);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
main(int argc, char *argv[]) {
  int i, len, rc, on = 1;
  int listen_sd, max_sd, new_sd;
  int desc_ready, end_server = 0;
  int close_conn;
  char buffer[80];
  struct sockaddr_in addr;
  struct timeval timeout;
  fd_set master_set, working_set;
  listen_sd = socket(AF_INET, SOCK_STREAM, 0);
  if (listen_sd < 0) {
    perror("socket() failed");
    exit(-1);
  }
  rc = setsockopt(listen_sd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on));
  if (rc < 0) {
    perror("setsockopt() failed");
    close(listen_sd);
    exit(-1);
  }
  rc = ioctl(listen_sd, FIONBIO, (char *)&on);
  if (rc < 0) {
    perror("ioctl() failed");
    close(listen_sd);
    exit(-1);
  }
  memset(&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_addr.s_addr = htonl(INADDR_ANY);
  addr.sin_port = htons(12345);
  rc = bind(listen_sd, (struct sockaddr *)&addr, sizeof(addr));
  if (rc < 0) {
    perror("bind() failed");
    close(listen_sd);
    exit(-1);
  }
  rc = listen(listen_sd, 32);
  if (rc < 0) {
    perror("listen() failed");
    close(listen_sd);
    exit(-1);
  }
  FD_ZERO(&master_set);
  max_sd = listen_sd;
  FD_SET(listen_sd, &master_set);
  timeout.tv_sec = 3 * 60;
  timeout.tv_usec = 0;
  do {
    memcpy(&working_set, &master_set, sizeof(master_set));
    printf("Waiting on select()...\n");
    rc = select(max_sd + 1, &working_set, NULL, NULL, &timeout);
    if (rc < 0) {
      perror("  select() failed");
      break;
    }
    if (rc == 0) {
      printf("  select() timed out.  End program.\n");
      break;
    }
    desc_ready = rc;
    for (i = 0; i <= max_sd && desc_ready > 0; ++i) {
      if (FD_ISSET(i, &working_set)) {
        desc_ready -= 1;
        if (i == listen_sd) {
          printf("  Listening socket is readable\n");
          do {
            new_sd = accept(listen_sd, NULL, NULL);
            if (new_sd < 0) {
              if (errno != EWOULDBLOCK) {
                perror("  accept() failed");
                end_server = 1;
              }
              break;
            }
            printf("  New incoming connection - %d\n", new_sd);
            FD_SET(new_sd, &master_set);
            if (new_sd > max_sd)
              max_sd = new_sd;
          } while (new_sd != -1);
        } else {
          printf("  Descriptor %d is readable\n", i);
          close_conn = 0;
          do {
            rc = recv(i, buffer, sizeof(buffer), 0);
            if (rc < 0) {
              if (errno != EWOULDBLOCK) {
                perror("  recv() failed");
                close_conn = 1;
              }
              break;
            }
            if (rc == 0) {
              printf("  Connection closed\n");
              close_conn = 1;
              break;
            }
            len = rc;
            printf("  %d bytes received\n", len);
            rc = send(i, buffer, len, 0);
            if (rc < 0) {
              perror("  send() failed");
              close_conn = 1;
              break;
            }
          } while (1);
          if (close_conn) {
            close(i);
            FD_CLR(i, &master_set);
            if (i == max_sd) {
              while (FD_ISSET(max_sd, &master_set) == 0)
                max_sd -= 1;
            }
          }
        }
      }
    }
  } while (end_server == 0);
  for (i = 0; i <= max_sd; ++i) {
    if (FD_ISSET(i, &master_set))
      close(i);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
mov    0x2d41(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1170 <socket@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    12b3 <main+0x63>
lea    0xd5c(%rip),%rdi
call   1120 <perror@plt>
mov    $0xffffffff,%edi
call   1150 <exit@plt>
mov    -0x24(%rbp),%edi
mov    0x2d2b(%rip),%rax
mov    (%rax),%esi
mov    0x2ce2(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1302 <main+0xb2>
lea    0xd25(%rip),%rdi
call   1120 <perror@plt>
mov    -0x24(%rbp),%edi
call   10c0 <close@plt>
mov    $0xffffffff,%edi
call   1150 <exit@plt>
mov    -0x24(%rbp),%edi
mov    0x2ca4(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   10b0 <ioctl@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1342 <main+0xf2>
lea    0xcf9(%rip),%rdi
call   1120 <perror@plt>
mov    -0x24(%rbp),%edi
call   10c0 <close@plt>
mov    $0xffffffff,%edi
call   1150 <exit@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   10a0 <memset@plt>
mov    0x2c84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x98(%rbp)
mov    0x2c6d(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %eax,-0x9c(%rbp)
mov    $0x3039,%edi
call   1060 <htons@plt>
mov    %eax,-0xa0(%rbp)
mov    -0x24(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0xc,%edx
call   1110 <bind@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    13c7 <main+0x177>
lea    0xc83(%rip),%rdi
call   1120 <perror@plt>
mov    -0x24(%rbp),%edi
call   10c0 <close@plt>
mov    $0xffffffff,%edi
call   1150 <exit@plt>
mov    -0x24(%rbp),%edi
mov    $0x20,%esi
call   1100 <listen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    13ff <main+0x1af>
lea    0xc59(%rip),%rdi
call   1120 <perror@plt>
mov    -0x24(%rbp),%edi
call   10c0 <close@plt>
mov    $0xffffffff,%edi
call   1150 <exit@plt>
lea    -0xb4(%rbp),%rdi
call   10e0 <FD_ZERO@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
lea    -0xb4(%rbp),%rsi
call   1160 <FD_SET@plt>
movl   $0xb4,-0xb0(%rbp)
movq   $0x0,-0xa8(%rbp)
lea    -0xb8(%rbp),%rdi
lea    -0xb4(%rbp),%rsi
mov    $0x4,%edx
call   10d0 <memcpy@plt>
lea    0xbfd(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x28(%rbp),%edi
add    $0x1,%edi
lea    -0xb8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0xb0(%rbp),%r8
mov    %rcx,%rdx
call   10f0 <select@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1499 <main+0x249>
lea    0xbda(%rip),%rdi
call   1120 <perror@plt>
jmp    174b <main+0x4fb>
cmpl   $0x0,-0x1c(%rbp)
jne    14b6 <main+0x266>
lea    0xbd1(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    174b <main+0x4fb>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x28(%rbp),%ecx
mov    %al,-0xb9(%rbp)
jg     14e4 <main+0x294>
cmpl   $0x0,-0x30(%rbp)
setg   %al
mov    %al,-0xb9(%rbp)
mov    -0xb9(%rbp),%al
test   $0x1,%al
jne    14f7 <main+0x2a7>
jmp    173c <main+0x4ec>
mov    -0x14(%rbp),%edi
lea    -0xb8(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1729 <main+0x4d9>
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    15c7 <main+0x377>
lea    0xb74(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x24(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1130 <accept@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1581 <main+0x331>
mov    0x2a6a(%rip),%rax
mov    (%rax),%rax
mov    0x2a58(%rip),%rcx
cmp    (%rcx),%rax
je     157c <main+0x32c>
lea    0xb50(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x34(%rbp)
jmp    15c2 <main+0x372>
mov    -0x2c(%rbp),%esi
lea    0xb47(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x2c(%rbp),%edi
lea    -0xb4(%rbp),%rsi
call   1160 <FD_SET@plt>
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    15b3 <main+0x363>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    15b8 <main+0x368>
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1533 <main+0x2e3>
jmp    1724 <main+0x4d4>
mov    -0x14(%rbp),%esi
lea    0xb21(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1634 <main+0x3e4>
mov    0x29b7(%rip),%rax
mov    (%rax),%rax
mov    0x29a5(%rip),%rcx
cmp    (%rcx),%rax
je     162f <main+0x3df>
lea    0xaec(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x38(%rbp)
jmp    16bc <main+0x46c>
cmpl   $0x0,-0x1c(%rbp)
jne    1658 <main+0x408>
lea    0xada(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x1,-0x38(%rbp)
jmp    16bc <main+0x46c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xacc(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    -0x18(%rbp),%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    16a8 <main+0x458>
lea    0xab2(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x38(%rbp)
jmp    16bc <main+0x46c>
jmp    16ad <main+0x45d>
mov    $0x1,%al
test   $0x1,%al
jne    15df <main+0x38f>
jmp    16bc <main+0x46c>
cmpl   $0x0,-0x38(%rbp)
je     171f <main+0x4cf>
mov    -0x14(%rbp),%edi
call   10c0 <close@plt>
mov    -0x14(%rbp),%edi
lea    -0xb4(%rbp),%rsi
call   1140 <FD_CLR@plt>
mov    -0x14(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    171a <main+0x4ca>
jmp    16ee <main+0x49e>
mov    -0x28(%rbp),%edi
lea    -0xb4(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
jne    1715 <main+0x4c5>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    16ee <main+0x49e>
jmp    171a <main+0x4ca>
jmp    171f <main+0x4cf>
jmp    1724 <main+0x4d4>
jmp    1729 <main+0x4d9>
jmp    172e <main+0x4de>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    14c3 <main+0x273>
jmp    1741 <main+0x4f1>
cmpl   $0x0,-0x34(%rbp)
je     1435 <main+0x1e5>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x28(%rbp),%eax
jg     1792 <main+0x542>
mov    -0x14(%rbp),%edi
lea    -0xb4(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     177f <main+0x52f>
mov    -0x14(%rbp),%edi
call   10c0 <close@plt>
jmp    1784 <main+0x534>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1752 <main+0x502>
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
movl   $0x1,0x14(%rsp)
mov    0x2d60(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d3e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1180 <socket@plt>
test   %eax,%eax
js     1653 <main+0x3f3>
mov    %eax,%r14d
mov    0x2d43(%rip),%rax
mov    (%rax),%esi
mov    0x2cfa(%rip),%rax
mov    (%rax),%edx
lea    0x14(%rsp),%rcx
mov    %r14d,%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
test   %eax,%eax
js     1669 <main+0x409>
mov    0x2cde(%rip),%rax
mov    (%rax),%esi
lea    0x14(%rsp),%rdx
mov    %r14d,%edi
call   10c0 <ioctl@plt>
test   %eax,%eax
js     1672 <main+0x412>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   10b0 <memset@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x28(%rsp)
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
call   10a0 <htonl@plt>
mov    %eax,0x24(%rsp)
mov    $0x3039,%edi
call   1070 <htons@plt>
mov    %eax,0x20(%rsp)
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1120 <bind@plt>
test   %eax,%eax
js     167b <main+0x41b>
mov    %r14d,%edi
mov    $0x20,%esi
call   1110 <listen@plt>
test   %eax,%eax
js     1684 <main+0x424>
lea    0x1c(%rsp),%rbp
mov    %rbp,%rdi
call   10f0 <FD_ZERO@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1170 <FD_SET@plt>
movl   $0xb4,0x30(%rsp)
movq   $0x0,0x38(%rsp)
lea    0x40(%rsp),%r12
mov    %r14d,%ebx
jmp    13a3 <main+0x143>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movl   $0x0,0xc(%rsp)
cmpl   $0x0,0xc(%rsp)
jne    15f6 <main+0x396>
lea    0x18(%rsp),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
call   10e0 <memcpy@plt>
lea    0xd28(%rip),%rdi
call   1040 <puts@plt>
lea    0x1(%rbx),%edi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
lea    0x30(%rsp),%r8
call   1100 <select@plt>
test   %eax,%eax
js     162f <main+0x3cf>
je     15ea <main+0x38a>
test   %ebx,%ebx
js     1390 <main+0x130>
mov    %eax,%r13d
movl   $0x0,0xc(%rsp)
movl   $0x1,0x10(%rsp)
xor    %r15d,%r15d
mov    %r15d,%edi
lea    0x18(%rsp),%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     15a0 <main+0x340>
add    $0xffffffff,%r13d
mov    %r13d,0x8(%rsp)
cmp    %r14d,%r15d
jne    14c0 <main+0x260>
lea    0xce3(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1140 <accept@plt>
mov    %eax,%r13d
test   %eax,%eax
mov    %r14d,%r12d
lea    0xc26(%rip),%r14
js     1492 <main+0x232>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
call   1170 <FD_SET@plt>
cmp    %ebx,%r13d
cmovg  %r13d,%ebx
mov    %r12d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1140 <accept@plt>
mov    %eax,%r13d
test   %eax,%eax
jns    1460 <main+0x200>
mov    0x2b27(%rip),%rax
mov    (%rax),%rax
mov    0x2b15(%rip),%rcx
cmp    (%rcx),%rax
jne    15c0 <main+0x360>
mov    %r12d,%r14d
lea    0x40(%rsp),%r12
mov    0x8(%rsp),%r13d
jmp    15a0 <main+0x340>
xchg   %ax,%ax
mov    %rbp,%r13
lea    0xbcb(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15d,%edi
mov    %r12,%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
js     1529 <main+0x2c9>
je     154d <main+0x2ed>
mov    %eax,%ebp
lea    0xbc1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15d,%edi
mov    %r12,%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
test   %eax,%eax
jns    14e0 <main+0x280>
lea    0xbb3(%rip),%rdi
jmp    15e0 <main+0x380>
mov    0x2a90(%rip),%rax
mov    (%rax),%rax
mov    0x2a7e(%rip),%rcx
cmp    (%rcx),%rax
jne    15d9 <main+0x379>
mov    %r13,%rbp
mov    0x8(%rsp),%r13d
jmp    15a0 <main+0x340>
lea    0xbaa(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rbp
mov    %r15d,%edi
call   10d0 <close@plt>
mov    %r15d,%edi
mov    %r13,%rsi
call   1150 <FD_CLR@plt>
cmp    %ebx,%r15d
mov    0x8(%rsp),%r13d
jne    15a0 <main+0x340>
mov    0x10(%rsp),%eax
mov    %eax,%ebx
nop
add    $0xffffffff,%ebx
mov    %ebx,%edi
mov    %rbp,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     1580 <main+0x320>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %ebx,%r15d
jge    1398 <main+0x138>
add    $0x1,%r15d
addl   $0x1,0x10(%rsp)
test   %r13d,%r13d
jg     1400 <main+0x1a0>
jmp    1398 <main+0x138>
lea    0xa9c(%rip),%rdi
call   1130 <perror@plt>
movl   $0x1,0xc(%rsp)
jmp    14ac <main+0x24c>
lea    0xad2(%rip),%rdi
call   1130 <perror@plt>
jmp    1559 <main+0x2f9>
lea    0xb40(%rip),%rdi
call   1040 <puts@plt>
test   %ebx,%ebx
js     163f <main+0x3df>
add    $0x1,%ebx
xor    %ebp,%ebp
lea    0x1c(%rsp),%r14
jmp    1617 <main+0x3b7>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    %ebp,%ebx
je     163f <main+0x3df>
mov    %ebp,%edi
mov    %r14,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     1610 <main+0x3b0>
mov    %ebp,%edi
call   10d0 <close@plt>
jmp    1610 <main+0x3b0>
lea    0xa1b(%rip),%rdi
call   1130 <perror@plt>
test   %ebx,%ebx
jns    15fa <main+0x39a>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x9a6(%rip),%rdi
call   1130 <perror@plt>
mov    $0xffffffff,%edi
call   1160 <exit@plt>
lea    0x9a0(%rip),%rdi
jmp    168b <main+0x42b>
lea    0x9ab(%rip),%rdi
jmp    168b <main+0x42b>
lea    0x9b1(%rip),%rdi
jmp    168b <main+0x42b>
lea    0x9b6(%rip),%rdi
call   1130 <perror@plt>
mov    %r14d,%edi
call   10d0 <close@plt>
mov    $0xffffffff,%edi
call   1160 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [16 x i8] c"socket() failed\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.1 = [20 x i8] c"setsockopt() failed\00"
@FIONBIO = global i32 0
@.str.2 = [15 x i8] c"ioctl() failed\00"
@INADDR_ANY = global i32 0
@.str.3 = [14 x i8] c"bind() failed\00"
@.str.4 = [16 x i8] c"listen() failed\00"
@.str.5 = [24 x i8] c"Waiting on select()...\0A\00"
@.str.6 = [18 x i8] c" select() failed\00"
@.str.7 = [37 x i8] c" select() timed out. End program.\0A\00"
@.str.8 = [32 x i8] c" Listening socket is readable\0A\00"
@errno = global i64 0
@EWOULDBLOCK = global i64 0
@.str.9 = [18 x i8] c" accept() failed\00"
@.str.10 = [32 x i8] c" New incoming connection - %d\0A\00"
@.str.11 = [29 x i8] c" Descriptor %d is readable\0A\00"
@.str.12 = [16 x i8] c" recv() failed\00"
@.str.13 = [21 x i8] c" Connection closed\0A\00"
@.str.14 = [21 x i8] c" %d bytes received\0A\00"
@.str.15 = [16 x i8] c" send() failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [80 x i8]
%17 = alloca %struct.sockaddr_in
%18 = alloca %struct.timeval
%19 = alloca i32
%20 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %9
store i32 0, i32* %14
%21 = load i32, i32* @AF_INET
%22 = load i32, i32* @SOCK_STREAM
%23 = call i32 @socket(i32 %21, i32 %22, i32 0)
store i32 %23, i32* %10
%24 = load i32, i32* %10
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %2
%27 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %2
%30 = load i32, i32* %10
%31 = load i32, i32* @SOL_SOCKET
%32 = load i32, i32* @SO_REUSEADDR
%33 = bitcast i32* %9 to i8*
%34 = call i32 @setsockopt(i32 %30, i32 %31, i32 %32, i8* %33, i32 4)
store i32 %34, i32* %8
%35 = load i32, i32* %8
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %29
%38 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32, i32* %10
%40 = call i32 @close(i32 %39)
%41 = call i32 @exit(i32 -1)
unreachable
42: ; preds = %29
%43 = load i32, i32* %10
%44 = load i32, i32* @FIONBIO
%45 = bitcast i32* %9 to i8*
%46 = call i32 @ioctl(i32 %43, i32 %44, i8* %45)
store i32 %46, i32* %8
%47 = load i32, i32* %8
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %42
%50 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%51 = load i32, i32* %10
%52 = call i32 @close(i32 %51)
%53 = call i32 @exit(i32 -1)
unreachable
54: ; preds = %42
%55 = call i32 @memset(%struct.sockaddr_in* %17, i32 0, i32 12)
%56 = load i32, i32* @AF_INET
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 2
store i32 %56, i32* %57
%58 = load i32, i32* @INADDR_ANY
%59 = call i32 @htonl(i32 %58)
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 1
%61 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %60, i32 0, i32 0
store i32 %59, i32* %61
%62 = call i32 @htons(i32 12345)
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 0
store i32 %62, i32* %63
%64 = load i32, i32* %10
%65 = bitcast %struct.sockaddr_in* %17 to %struct.sockaddr*
%66 = call i32 @bind(i32 %64, %struct.sockaddr* %65, i32 12)
store i32 %66, i32* %8
%67 = load i32, i32* %8
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %74
69: ; preds = %54
%70 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%71 = load i32, i32* %10
%72 = call i32 @close(i32 %71)
%73 = call i32 @exit(i32 -1)
unreachable
74: ; preds = %54
%75 = load i32, i32* %10
%76 = call i32 @listen(i32 %75, i32 32)
store i32 %76, i32* %8
%77 = load i32, i32* %8
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %84
79: ; preds = %74
%80 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%81 = load i32, i32* %10
%82 = call i32 @close(i32 %81)
%83 = call i32 @exit(i32 -1)
unreachable
84: ; preds = %74
%85 = call i32 @FD_ZERO(i32* %19)
%86 = load i32, i32* %10
store i32 %86, i32* %11
%87 = load i32, i32* %10
%88 = call i32 @FD_SET(i32 %87, i32* %19)
%89 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 0
store i32 180, i32* %89
%90 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
store i64 0, i64* %90
br label %91
91: ; preds = %219, %84
%92 = call i32 @memcpy(i32* %20, i32* %19, i32 4)
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%94 = load i32, i32* %11
%95 = add nsw i32 %94, 1
%96 = call i32 @select(i32 %95, i32* %20, i32* null, i32* null, %struct.timeval* %18)
store i32 %96, i32* %8
%97 = load i32, i32* %8
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %91
%100 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %222
101: ; preds = %91
%102 = load i32, i32* %8
%103 = icmp eq i32 %102, 0
br i1 %103, label %104, label %106
104: ; preds = %101
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %222
106: ; preds = %101
%107 = load i32, i32* %8
store i32 %107, i32* %13
store i32 0, i32* %6
br label %108
108: ; preds = %215, %106
%109 = load i32, i32* %6
%110 = load i32, i32* %11
%111 = icmp sle i32 %109, %110
br i1 %111, label %112, label %115
112: ; preds = %108
%113 = load i32, i32* %13
%114 = icmp sgt i32 %113, 0
br label %115
115: ; preds = %112, %108
%116 = phi i1 [ false, %108 ], [ %114, %112 ]
br i1 %116, label %117, label %218
117: ; preds = %115
%118 = load i32, i32* %6
%119 = call i64 @FD_ISSET(i32 %118, i32* %20)
%120 = icmp ne i64 %119, 0
br i1 %120, label %121, label %214
121: ; preds = %117
%122 = load i32, i32* %13
%123 = sub nsw i32 %122, 1
store i32 %123, i32* %13
%124 = load i32, i32* %6
%125 = load i32, i32* %10
%126 = icmp eq i32 %124, %125
br i1 %126, label %127, label %156
127: ; preds = %121
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
br label %129
129: ; preds = %152, %127
%130 = load i32, i32* %10
%131 = call i32 @accept(i32 %130, i32* null, i32* null)
store i32 %131, i32* %12
%132 = load i32, i32* %12
%133 = icmp slt i32 %132, 0
br i1 %133, label %134, label %141
134: ; preds = %129
%135 = load i64, i64* @errno
%136 = load i64, i64* @EWOULDBLOCK
%137 = icmp ne i64 %135, %136
br i1 %137, label %138, label %140
138: ; preds = %134
%139 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %14
br label %140
140: ; preds = %138, %134
br label %155
141: ; preds = %129
%142 = load i32, i32* %12
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i32 %142)
%144 = load i32, i32* %12
%145 = call i32 @FD_SET(i32 %144, i32* %19)
%146 = load i32, i32* %12
%147 = load i32, i32* %11
%148 = icmp sgt i32 %146, %147
br i1 %148, label %149, label %151
149: ; preds = %141
%150 = load i32, i32* %12
store i32 %150, i32* %11
br label %151
151: ; preds = %149, %141
br label %152
152: ; preds = %151
%153 = load i32, i32* %12
%154 = icmp ne i32 %153, -1
br i1 %154, label %129, label %155
155: ; preds = %152, %140
br label %213
156: ; preds = %121
%157 = load i32, i32* %6
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i32 %157)
store i32 0, i32* %15
br label %159
159: ; preds = %190, %156
%160 = load i32, i32* %6
%161 = getelementptr inbounds [80 x i8], [80 x i8]* %16, i64 0, i64 0
%162 = call i32 @recv(i32 %160, i8* %161, i32 80, i32 0)
store i32 %162, i32* %8
%163 = load i32, i32* %8
%164 = icmp slt i32 %163, 0
br i1 %164, label %165, label %172
165: ; preds = %159
%166 = load i64, i64* @errno
%167 = load i64, i64* @EWOULDBLOCK
%168 = icmp ne i64 %166, %167
br i1 %168, label %169, label %171
169: ; preds = %165
%170 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %15
br label %171
171: ; preds = %169, %165
br label %191
172: ; preds = %159
%173 = load i32, i32* %8
%174 = icmp eq i32 %173, 0
br i1 %174, label %175, label %177
175: ; preds = %172
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0))
store i32 1, i32* %15
br label %191
177: ; preds = %172
%178 = load i32, i32* %8
store i32 %178, i32* %7
%179 = load i32, i32* %7
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.14, i64 0, i64 0), i32 %179)
%181 = load i32, i32* %6
%182 = getelementptr inbounds [80 x i8], [80 x i8]* %16, i64 0, i64 0
%183 = load i32, i32* %7
%184 = call i32 @send(i32 %181, i8* %182, i32 %183, i32 0)
store i32 %184, i32* %8
%185 = load i32, i32* %8
%186 = icmp slt i32 %185, 0
br i1 %186, label %187, label %189
187: ; preds = %177
%188 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0))
store i32 1, i32* %15
br label %191
189: ; preds = %177
br label %190
190: ; preds = %189
br i1 true, label %159, label %191
191: ; preds = %190, %187, %175, %171
%192 = load i32, i32* %15
%193 = icmp ne i32 %192, 0
br i1 %193, label %194, label %212
194: ; preds = %191
%195 = load i32, i32* %6
%196 = call i32 @close(i32 %195)
%197 = load i32, i32* %6
%198 = call i32 @FD_CLR(i32 %197, i32* %19)
%199 = load i32, i32* %6
%200 = load i32, i32* %11
%201 = icmp eq i32 %199, %200
br i1 %201, label %202, label %211
202: ; preds = %194
br label %203
203: ; preds = %207, %202
%204 = load i32, i32* %11
%205 = call i64 @FD_ISSET(i32 %204, i32* %19)
%206 = icmp eq i64 %205, 0
br i1 %206, label %207, label %210
207: ; preds = %203
%208 = load i32, i32* %11
%209 = sub nsw i32 %208, 1
store i32 %209, i32* %11
br label %203
210: ; preds = %203
br label %211
211: ; preds = %210, %194
br label %212
212: ; preds = %211, %191
br label %213
213: ; preds = %212, %155
br label %214
214: ; preds = %213, %117
br label %215
215: ; preds = %214
%216 = load i32, i32* %6
%217 = add nsw i32 %216, 1
store i32 %217, i32* %6
br label %108
218: ; preds = %115
br label %219
219: ; preds = %218
%220 = load i32, i32* %14
%221 = icmp eq i32 %220, 0
br i1 %221, label %91, label %222
222: ; preds = %219, %104, %99
store i32 0, i32* %6
br label %223
223: ; preds = %235, %222
%224 = load i32, i32* %6
%225 = load i32, i32* %11
%226 = icmp sle i32 %224, %225
br i1 %226, label %227, label %238
227: ; preds = %223
%228 = load i32, i32* %6
%229 = call i64 @FD_ISSET(i32 %228, i32* %19)
%230 = icmp ne i64 %229, 0
br i1 %230, label %231, label %234
231: ; preds = %227
%232 = load i32, i32* %6
%233 = call i32 @close(i32 %232)
br label %234
234: ; preds = %231, %227
br label %235
235: ; preds = %234
%236 = load i32, i32* %6
%237 = add nsw i32 %236, 1
store i32 %237, i32* %6
br label %223
238: ; preds = %223
%239 = load i32, i32* %3
ret i32 %239
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [16 x i8] c"socket() failed\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.1 = [20 x i8] c"setsockopt() failed\00"
@FIONBIO = global i32 0
@.str.2 = [15 x i8] c"ioctl() failed\00"
@INADDR_ANY = global i32 0
@.str.3 = [14 x i8] c"bind() failed\00"
@.str.4 = [16 x i8] c"listen() failed\00"
@.str.6 = [18 x i8] c" select() failed\00"
@errno = global i64 0
@EWOULDBLOCK = global i64 0
@.str.9 = [18 x i8] c" accept() failed\00"
@.str.10 = [32 x i8] c" New incoming connection - %d\0A\00"
@.str.11 = [29 x i8] c" Descriptor %d is readable\0A\00"
@.str.12 = [16 x i8] c" recv() failed\00"
@.str.14 = [21 x i8] c" %d bytes received\0A\00"
@.str.15 = [16 x i8] c" send() failed\00"
@str = [23 x i8] c"Waiting on select()...\00"
@str.16 = [20 x i8] c" Connection closed\00"
@str.17 = [31 x i8] c" Listening socket is readable\00"
@str.18 = [36 x i8] c" select() timed out. End program.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [80 x i8]
%5 = alloca %struct.sockaddr_in
%6 = alloca %struct.timeval
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %3 to i8*
store i32 1, i32* %3
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%11 = bitcast %struct.sockaddr_in* %5 to i8*
%12 = bitcast %struct.timeval* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = bitcast i32* %8 to i8*
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = tail call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%21 = tail call i32 @exit(i32 -1)
unreachable
22: ; preds = %2
%23 = load i32, i32* @SOL_SOCKET
%24 = load i32, i32* @SO_REUSEADDR
%25 = call i32 @setsockopt(i32 %17, i32 %23, i32 %24, i8* %9, i32 4)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @close(i32 %17)
%30 = call i32 @exit(i32 -1)
unreachable
31: ; preds = %22
%32 = load i32, i32* @FIONBIO
%33 = call i32 @ioctl(i32 %17, i32 %32, i8* %9)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @close(i32 %17)
%38 = call i32 @exit(i32 -1)
unreachable
39: ; preds = %31
%40 = call i32 @memset(%struct.sockaddr_in* %5, i32 0, i32 12)
%41 = load i32, i32* @AF_INET
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %41, i32* %42
%43 = load i32, i32* @INADDR_ANY
%44 = call i32 @htonl(i32 %43)
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1, i32 0
store i32 %44, i32* %45
%46 = call i32 @htons(i32 12345)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
store i32 %46, i32* %47
%48 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%49 = call i32 @bind(i32 %17, %struct.sockaddr* %48, i32 12)
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %39
%52 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%53 = call i32 @close(i32 %17)
%54 = call i32 @exit(i32 -1)
unreachable
55: ; preds = %39
%56 = call i32 @listen(i32 %17, i32 32)
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %55
%59 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%60 = call i32 @close(i32 %17)
%61 = call i32 @exit(i32 -1)
unreachable
62: ; preds = %55
%63 = call i32 @FD_ZERO(i32* %7)
%64 = call i32 @FD_SET(i32 %17, i32* %7)
%65 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
store i32 180, i32* %65
%66 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
store i64 0, i64* %66
br label %67
67: ; preds = %150, %62
%68 = phi i32 [ %17, %62 ], [ %151, %150 ]
%69 = call i32 @memcpy(i32* %8, i32* %7, i32 4)
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%71 = add nsw i32 %68, 1
%72 = call i32 @select(i32 %71, i32* %8, i32* null, i32* null, %struct.timeval* %6)
%73 = icmp slt i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %67
%75 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %154
76: ; preds = %67
%77 = icmp eq i32 %72, 0
br i1 %77, label %80, label %78
78: ; preds = %76
%79 = icmp sgt i32 %68, -1
br i1 %79, label %82, label %150
80: ; preds = %76
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.18, i64 0, i64 0))
br label %154
82: ; preds = %78, %142
%83 = phi i32 [ %145, %142 ], [ 0, %78 ]
%84 = phi i32 [ %144, %142 ], [ %72, %78 ]
%85 = phi i32 [ %146, %142 ], [ 0, %78 ]
%86 = phi i32 [ %143, %142 ], [ %68, %78 ]
%87 = call i64 @FD_ISSET(i32 %85, i32* %8)
%88 = icmp eq i64 %87, 0
br i1 %88, label %142, label %89
89: ; preds = %82
%90 = add nsw i32 %84, -1
%91 = icmp eq i32 %85, %17
br i1 %91, label %92, label %112
92: ; preds = %89
%93 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.17, i64 0, i64 0))
%94 = call i32 @accept(i32 %17, i32* null, i32* null)
%95 = icmp slt i32 %94, 0
br i1 %95, label %96, label %103
96: ; preds = %103, %92
%97 = phi i32 [ %86, %92 ], [ %109, %103 ]
%98 = load i64, i64* @errno
%99 = load i64, i64* @EWOULDBLOCK
%100 = icmp eq i64 %98, %99
br i1 %100, label %142, label %101
101: ; preds = %96
%102 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %142
103: ; preds = %92, %103
%104 = phi i32 [ %110, %103 ], [ %94, %92 ]
%105 = phi i32 [ %109, %103 ], [ %86, %92 ]
%106 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i32 %104)
%107 = call i32 @FD_SET(i32 %104, i32* %7)
%108 = icmp sgt i32 %104, %105
%109 = select i1 %108, i32 %104, i32 %105
%110 = call i32 @accept(i32 %17, i32* null, i32* null)
%111 = icmp slt i32 %110, 0
br i1 %111, label %96, label %103
112: ; preds = %89
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i32 %85)
br label %114
114: ; preds = %127, %112
%115 = call i32 @recv(i32 %85, i8* %10, i32 80, i32 0)
%116 = icmp slt i32 %115, 0
br i1 %116, label %117, label %123
117: ; preds = %114
%118 = load i64, i64* @errno
%119 = load i64, i64* @EWOULDBLOCK
%120 = icmp eq i64 %118, %119
br i1 %120, label %142, label %121
121: ; preds = %117
%122 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
br label %133
123: ; preds = %114
%124 = icmp eq i32 %115, 0
br i1 %124, label %125, label %127
125: ; preds = %123
%126 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.16, i64 0, i64 0))
br label %133
127: ; preds = %123
%128 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.14, i64 0, i64 0), i32 %115)
%129 = call i32 @send(i32 %85, i8* %10, i32 %115, i32 0)
%130 = icmp slt i32 %129, 0
br i1 %130, label %131, label %114
131: ; preds = %127
%132 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0))
br label %133
133: ; preds = %125, %131, %121
%134 = call i32 @close(i32 %85)
%135 = call i32 @FD_CLR(i32 %85, i32* %7)
%136 = icmp eq i32 %85, %86
br i1 %136, label %137, label %142
137: ; preds = %133, %137
%138 = phi i32 [ %141, %137 ], [ %85, %133 ]
%139 = call i64 @FD_ISSET(i32 %138, i32* %7)
%140 = icmp eq i64 %139, 0
%141 = add nsw i32 %138, -1
br i1 %140, label %137, label %142
142: ; preds = %137, %117, %82, %133, %101, %96
%143 = phi i32 [ %97, %101 ], [ %97, %96 ], [ %86, %133 ], [ %86, %82 ], [ %86, %117 ], [ %138, %137 ]
%144 = phi i32 [ %90, %101 ], [ %90, %96 ], [ %90, %133 ], [ %84, %82 ], [ %90, %117 ], [ %90, %137 ]
%145 = phi i32 [ 1, %101 ], [ %83, %96 ], [ %83, %133 ], [ %83, %82 ], [ %83, %117 ], [ %83, %137 ]
%146 = add nuw nsw i32 %85, 1
%147 = icmp slt i32 %85, %143
%148 = icmp sgt i32 %144, 0
%149 = select i1 %147, i1 %148, i1 false
br i1 %149, label %82, label %150
150: ; preds = %142, %78
%151 = phi i32 [ %68, %78 ], [ %143, %142 ]
%152 = phi i32 [ 0, %78 ], [ %145, %142 ]
%153 = icmp eq i32 %152, 0
br i1 %153, label %67, label %154
154: ; preds = %150, %80, %74
%155 = phi i32 [ %68, %74 ], [ %68, %80 ], [ %151, %150 ]
%156 = icmp slt i32 %155, 0
br i1 %156, label %166, label %157
157: ; preds = %154, %163
%158 = phi i32 [ %164, %163 ], [ 0, %154 ]
%159 = call i64 @FD_ISSET(i32 %158, i32* %7)
%160 = icmp eq i64 %159, 0
br i1 %160, label %163, label %161
161: ; preds = %157
%162 = call i32 @close(i32 %158)
br label %163
163: ; preds = %157, %161
%164 = add nuw i32 %158, 1
%165 = icmp eq i32 %158, %155
br i1 %165, label %166, label %157
166: ; preds = %163, %154
ret i32 0
}