#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 {
  void *sin_port;
  TYPE_1__ sin_addr;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ sourceaddr;
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ sinkaddr;
typedef int /*<<< orphan*/ on;
typedef int /*<<< orphan*/ i;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
void *AF_INET;
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*/ F_SETFL;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ INADDR_LOOPBACK;
int /*<<< orphan*/ O_NONBLOCK;
void *PF_INET;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_KEEPALIVE;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fcntl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
void *htons(int);
scalar_t__ listen(int, 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 recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *,
             int /*<<< orphan*/ *);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  socklen_t fromlen;
  int length, tolen, n, count, fdmax, i;
  int sourcesock, sinksock, consock[20] = {0};
  struct sockaddr_in sourceaddr, sinkaddr;
  char buf[0x10000];
  fd_set fds;
  struct timeval tvt, tvcur;
  int on = 1;
  signal(SIGCHLD, SIG_IGN);
  sourcesock = socket(AF_INET, SOCK_DGRAM, 0);
  sinksock = socket(PF_INET, SOCK_STREAM, 0);
  if ((sourcesock < 0) || (sinksock < 0)) {
    perror("socket");
    exit(1);
  }
  tolen = sizeof(struct sockaddr_in);
  length = sizeof(sourceaddr);
  memset(&sourceaddr, 0, sizeof(sourceaddr));
  memset(&sinkaddr, 0, sizeof(sinkaddr));
  sourceaddr.sin_family = AF_INET;
  sourceaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
  sourceaddr.sin_port = htons(7023);
  sinkaddr.sin_family = AF_INET;
  sinkaddr.sin_addr.s_addr = INADDR_ANY;
  sinkaddr.sin_port = htons(7024);
  setsockopt(sinksock, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on));
  if ((bind(sourcesock, (struct sockaddr *)&sourceaddr, length) < 0) ||
      (bind(sinksock, (struct sockaddr *)&sinkaddr, length) < 0)) {
    perror("bind");
    exit(1);
  }
  if (listen(sinksock, 3)) {
    perror("listen");
    exit(1);
  }
  fdmax = ((sourcesock > sinksock) ? sourcesock : sinksock);
  FD_ZERO(&fds);
  while (1) {
    fdmax = ((sourcesock > sinksock) ? sourcesock : sinksock);
    FD_ZERO(&fds);
    FD_SET(sourcesock, &fds);
    FD_SET(sinksock, &fds);
    for (i = 0; i < 20; i++) {
      if (consock[i] != 0) {
        FD_SET(consock[i], &fds);
        fdmax = ((fdmax > consock[i]) ? fdmax : consock[i]);
      }
    }
    tvt.tv_sec = 1;
    tvt.tv_usec = 0;
    count = select(fdmax + 1, &fds, NULL, NULL, &tvt);
    for (i = 0; i < 20; i++) {
      if (FD_ISSET(consock[i], &fds)) {
        n = recv(consock[i], buf, sizeof(buf), 0);
        if (n <= 0) {
          if (n < 0)
            perror("recv");
          printf("disconnect\n");
          close(consock[i]);
          FD_CLR(consock[i], &fds);
          fdmax = ((sourcesock > sinksock) ? sourcesock : sinksock);
          consock[i] = 0;
        } else {
          printf("receive uplink %d\n", n);
        }
      }
    }
    if (FD_ISSET(sourcesock, &fds)) {
      gettimeofday(&tvcur, NULL);
      n = recvfrom(sourcesock, buf, sizeof(buf), 0,
                   (struct sockaddr *)&sourceaddr, (socklen_t *)&fromlen);
      if (n < 0)
        perror("recvfrom");
      printf("receive downlink %d\n", n);
      for (i = 0; i < 20; i++) {
        if (consock[i] != 0) {
          printf("send downlink %d\n", i);
          count = send(consock[i], buf, n, 0);
          if (count <= 0) {
            printf("disconnect\n");
            close(consock[i]);
            FD_CLR(consock[i], &fds);
            fdmax = ((sourcesock > sinksock) ? sourcesock : sinksock);
            consock[i] = 0;
          }
        }
      }
    }
    if (FD_ISSET(sinksock, &fds)) {
      for (i = 0; i < 20; i++) {
        if (consock[i] == 0) {
          consock[i] = accept(sinksock, (struct sockaddr *)&sinkaddr,
                              (socklen_t *)&fromlen);
          if (consock[i] < 0) {
            perror("socket");
            consock[i] = 0;
          } else {
            printf("connect\n");
            setsockopt(consock[i], SOL_SOCKET, SO_KEEPALIVE, &i, sizeof(i));
            fcntl(consock[i], F_SETFL, O_NONBLOCK);
            break;
          }
          printf("connect\n");
          FD_SET(consock[i], &fds);
          fdmax = ((fdmax > consock[i]) ? fdmax : consock[i]);
          break;
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   10c0 <memset@plt>
movl   $0x1,-0x100ec(%rbp)
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
mov    0x2cfa(%rip),%rax
mov    (%rax),%esi
call   10e0 <signal@plt>
mov    0x2d1c(%rip),%rax
mov    (%rax),%rdi
mov    0x2cf2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1190 <socket@plt>
mov    %eax,-0x30(%rbp)
mov    0x2caf(%rip),%rax
mov    (%rax),%rdi
mov    0x2cad(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1190 <socket@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x30(%rbp)
jl     130b <main+0x9b>
cmpl   $0x0,-0x34(%rbp)
jge    1321 <main+0xb1>
lea    0xcee(%rip),%rdi
call   1140 <perror@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
movl   $0x18,-0x1c(%rbp)
movl   $0x18,-0x18(%rbp)
lea    -0xa8(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10c0 <memset@plt>
lea    -0xc0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10c0 <memset@plt>
mov    0x2c84(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x98(%rbp)
mov    0x2c4b(%rip),%rax
mov    (%rax),%edi
call   10b0 <htonl@plt>
mov    %eax,-0xa0(%rbp)
mov    $0x1b6f,%edi
call   1070 <htons@plt>
mov    %rax,-0xa8(%rbp)
mov    0x2c4e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xb0(%rbp)
mov    0x2c2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb8(%rbp)
mov    $0x1b70,%edi
call   1070 <htons@plt>
mov    %rax,-0xc0(%rbp)
mov    -0x34(%rbp),%edi
mov    0x2c22(%rip),%rax
mov    (%rax),%esi
mov    0x2bb9(%rip),%rax
mov    (%rax),%edx
lea    -0x100ec(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    -0x30(%rbp),%edi
lea    -0xa8(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1130 <bind@plt>
cmp    $0x0,%rax
jl     141b <main+0x1ab>
mov    -0x34(%rbp),%edi
lea    -0xc0(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1130 <bind@plt>
cmp    $0x0,%rax
jge    1431 <main+0x1c1>
lea    0xbe5(%rip),%rdi
call   1140 <perror@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x34(%rbp),%edi
mov    $0x3,%esi
call   1110 <listen@plt>
cmp    $0x0,%rax
je     145e <main+0x1ee>
lea    0xbbd(%rip),%rdi
call   1140 <perror@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
jle    1478 <main+0x208>
mov    -0x30(%rbp),%eax
mov    %eax,-0x100f0(%rbp)
jmp    1481 <main+0x211>
mov    -0x34(%rbp),%eax
mov    %eax,-0x100f0(%rbp)
mov    -0x100f0(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x100c4(%rbp),%rdi
call   10f0 <FD_ZERO@plt>
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
jle    14b0 <main+0x240>
mov    -0x30(%rbp),%eax
mov    %eax,-0x100f4(%rbp)
jmp    14b9 <main+0x249>
mov    -0x34(%rbp),%eax
mov    %eax,-0x100f4(%rbp)
mov    -0x100f4(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x100c4(%rbp),%rdi
call   10f0 <FD_ZERO@plt>
mov    -0x30(%rbp),%edi
lea    -0x100c4(%rbp),%rsi
call   1180 <FD_SET@plt>
mov    -0x34(%rbp),%edi
lea    -0x100c4(%rbp),%rsi
call   1180 <FD_SET@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x14,-0x2c(%rbp)
jge    1575 <main+0x305>
movslq -0x2c(%rbp),%rax
cmpl   $0x0,-0x90(%rbp,%rax,4)
je     1562 <main+0x2f2>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edi
lea    -0x100c4(%rbp),%rsi
call   1180 <FD_SET@plt>
mov    -0x28(%rbp),%eax
movslq -0x2c(%rbp),%rcx
cmp    -0x90(%rbp,%rcx,4),%eax
jle    1548 <main+0x2d8>
mov    -0x28(%rbp),%eax
mov    %eax,-0x100f8(%rbp)
jmp    1559 <main+0x2e9>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%eax
mov    %eax,-0x100f8(%rbp)
mov    -0x100f8(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1567 <main+0x2f7>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    14f3 <main+0x283>
movl   $0x1,-0x100d8(%rbp)
movq   $0x0,-0x100d0(%rbp)
mov    -0x28(%rbp),%edi
add    $0x1,%edi
lea    -0x100c4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x100d8(%rbp),%r8
mov    %rcx,%rdx
call   1100 <select@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x14,-0x2c(%rbp)
jge    16be <main+0x44e>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edi
lea    -0x100c4(%rbp),%rsi
call   1060 <FD_ISSET@plt>
cmp    $0x0,%rax
je     16ab <main+0x43b>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edi
lea    -0x100c0(%rbp),%rsi
mov    $0x10000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jg     1695 <main+0x425>
cmpl   $0x0,-0x20(%rbp)
jge    1620 <main+0x3b0>
lea    0x9f8(%rip),%rdi
call   1140 <perror@plt>
lea    0x9f1(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edi
call   10d0 <close@plt>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edi
lea    -0x100c4(%rbp),%rsi
call   1160 <FD_CLR@plt>
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
jle    166f <main+0x3ff>
mov    -0x30(%rbp),%eax
mov    %eax,-0x100fc(%rbp)
jmp    1678 <main+0x408>
mov    -0x34(%rbp),%eax
mov    %eax,-0x100fc(%rbp)
mov    -0x100fc(%rbp),%eax
mov    %eax,-0x28(%rbp)
movslq -0x2c(%rbp),%rax
movl   $0x0,-0x90(%rbp,%rax,4)
jmp    16a6 <main+0x436>
mov    -0x20(%rbp),%esi
lea    0x985(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    16ab <main+0x43b>
jmp    16b0 <main+0x440>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    15b4 <main+0x344>
mov    -0x30(%rbp),%edi
lea    -0x100c4(%rbp),%rsi
call   1060 <FD_ISSET@plt>
cmp    $0x0,%rax
je     181c <main+0x5ac>
lea    -0x100e8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <gettimeofday@plt>
mov    -0x30(%rbp),%edi
lea    -0x100c0(%rbp),%rsi
lea    -0xa8(%rbp),%r8
mov    $0x10000,%edx
xor    %ecx,%ecx
lea    -0x14(%rbp),%r9
call   1120 <recvfrom@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1721 <main+0x4b1>
lea    0x91b(%rip),%rdi
call   1140 <perror@plt>
mov    -0x20(%rbp),%esi
lea    0x915(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x14,-0x2c(%rbp)
jge    1817 <main+0x5a7>
movslq -0x2c(%rbp),%rax
cmpl   $0x0,-0x90(%rbp,%rax,4)
je     1804 <main+0x594>
mov    -0x2c(%rbp),%esi
lea    0x8f6(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edi
lea    -0x100c0(%rbp),%rsi
mov    -0x20(%rbp),%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jg     17ff <main+0x58f>
lea    0x882(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edi
call   10d0 <close@plt>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edi
lea    -0x100c4(%rbp),%rsi
call   1160 <FD_CLR@plt>
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
jle    17de <main+0x56e>
mov    -0x30(%rbp),%eax
mov    %eax,-0x10100(%rbp)
jmp    17e7 <main+0x577>
mov    -0x34(%rbp),%eax
mov    %eax,-0x10100(%rbp)
mov    -0x10100(%rbp),%eax
mov    %eax,-0x28(%rbp)
movslq -0x2c(%rbp),%rax
movl   $0x0,-0x90(%rbp,%rax,4)
jmp    1804 <main+0x594>
jmp    1809 <main+0x599>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1739 <main+0x4c9>
jmp    181c <main+0x5ac>
mov    -0x34(%rbp),%edi
lea    -0x100c4(%rbp),%rsi
call   1060 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1989 <main+0x719>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x14,-0x2c(%rbp)
jge    1984 <main+0x714>
movslq -0x2c(%rbp),%rax
cmpl   $0x0,-0x90(%rbp,%rax,4)
jne    1971 <main+0x701>
mov    -0x34(%rbp),%edi
lea    -0xc0(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1150 <accept@plt>
mov    %eax,%ecx
movslq -0x2c(%rbp),%rax
mov    %ecx,-0x90(%rbp,%rax,4)
movslq -0x2c(%rbp),%rax
cmpl   $0x0,-0x90(%rbp,%rax,4)
jge    18aa <main+0x63a>
lea    0x76f(%rip),%rdi
call   1140 <perror@plt>
movslq -0x2c(%rbp),%rax
movl   $0x0,-0x90(%rbp,%rax,4)
jmp    190b <main+0x69b>
lea    0x76a(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edi
mov    0x271e(%rip),%rax
mov    (%rax),%esi
mov    0x26a5(%rip),%rax
mov    (%rax),%edx
lea    -0x2c(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edi
mov    0x26aa(%rip),%rax
mov    (%rax),%esi
mov    0x26d9(%rip),%rax
mov    (%rax),%edx
call   1050 <fcntl@plt>
jmp    1984 <main+0x714>
lea    0x709(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edi
lea    -0x100c4(%rbp),%rsi
call   1180 <FD_SET@plt>
mov    -0x28(%rbp),%eax
movslq -0x2c(%rbp),%rcx
cmp    -0x90(%rbp,%rcx,4),%eax
jle    1952 <main+0x6e2>
mov    -0x28(%rbp),%eax
mov    %eax,-0x10104(%rbp)
jmp    1963 <main+0x6f3>
movslq -0x2c(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%eax
mov    %eax,-0x10104(%rbp)
mov    -0x10104(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1984 <main+0x714>
jmp    1976 <main+0x706>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    183c <main+0x5cc>
jmp    1989 <main+0x719>
jmp    1496 <main+0x226>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100d8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x1,0x70(%rsp)
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
mov    0x2ceb(%rip),%rax
mov    (%rax),%esi
call   10f0 <signal@plt>
mov    0x2d0d(%rip),%r15
mov    (%r15),%rdi
mov    0x2ce3(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11a0 <socket@plt>
mov    %eax,%ebp
mov    0x2ca1(%rip),%rax
mov    (%rax),%rdi
mov    0x2c9f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11a0 <socket@plt>
mov    %ebp,0xc(%rsp)
test   %ebp,%ebp
js     193d <main+0x6bd>
mov    %eax,%ebx
test   %eax,%eax
js     193d <main+0x6bd>
lea    0x98(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10d0 <memset@plt>
lea    0x78(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10d0 <memset@plt>
mov    (%r15),%rax
mov    %rax,0xa8(%rsp)
mov    0x2c66(%rip),%rax
mov    (%rax),%edi
call   10c0 <htonl@plt>
mov    %eax,0xa0(%rsp)
mov    $0x1b6f,%edi
call   1080 <htons@plt>
mov    %rax,0x98(%rsp)
mov    (%r15),%rax
mov    %rax,0x88(%rsp)
mov    0x2c4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x80(%rsp)
mov    $0x1b70,%edi
call   1080 <htons@plt>
mov    %rax,0x78(%rsp)
mov    0x2c45(%rip),%rax
mov    (%rax),%esi
mov    0x2bdc(%rip),%rax
mov    (%rax),%edx
lea    0x70(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
mov    0xc(%rsp),%edi
mov    %r14,%rsi
mov    $0x18,%edx
call   1140 <bind@plt>
test   %rax,%rax
js     1934 <main+0x6b4>
lea    0x78(%rsp),%rsi
mov    %ebx,%edi
mov    $0x18,%edx
call   1140 <bind@plt>
test   %rax,%rax
js     1934 <main+0x6b4>
mov    %ebx,%edi
mov    $0x3,%esi
call   1120 <listen@plt>
test   %rax,%rax
jne    1946 <main+0x6c6>
lea    0x94(%rsp),%r15
mov    %r15,%rdi
call   1100 <FD_ZERO@plt>
mov    0xc(%rsp),%ecx
cmp    %ebx,%ecx
mov    %ebx,%eax
cmova  %ecx,%eax
mov    %eax,0x68(%rsp)
lea    0xd0(%rsp),%r12
lea    0xc24(%rip),%r13
lea    0xbda(%rip),%r14
mov    %ebx,0x6c(%rsp)
jmp    14cf <main+0x24f>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
mov    %eax,0x8(%rsp)
mov    %ebx,%edi
lea    0x78(%rsp),%rsi
lea    0x74(%rsp),%rdx
call   1160 <accept@plt>
movslq 0x8(%rsp),%rcx
mov    %eax,0x10(%rsp,%rcx,4)
test   %eax,%eax
js     1859 <main+0x5d9>
lea    0xbdf(%rip),%rdi
call   1040 <puts@plt>
movslq 0x8(%rsp),%rax
mov    0x10(%rsp,%rax,4),%edi
mov    0x2b54(%rip),%rax
mov    (%rax),%esi
mov    0x2adb(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
movslq 0x8(%rsp),%rax
mov    0x10(%rsp,%rax,4),%edi
mov    0x2ae1(%rip),%rax
mov    (%rax),%esi
mov    0x2b10(%rip),%rax
mov    (%rax),%edx
call   1060 <fcntl@plt>
mov    %r15,%rdi
call   1100 <FD_ZERO@plt>
mov    0xc(%rsp),%edi
mov    %r15,%rsi
call   1190 <FD_SET@plt>
mov    %ebx,%edi
mov    %r15,%rsi
call   1190 <FD_SET@plt>
movl   $0x0,0x8(%rsp)
mov    0x68(%rsp),%ebp
xor    %eax,%eax
jmp    150e <main+0x28e>
nopl   (%rax)
lea    0x1(%rax),%ecx
mov    %ecx,0x8(%rsp)
cmp    $0x13,%eax
mov    %ecx,%eax
jge    1540 <main+0x2c0>
movslq %eax,%rcx
mov    0x10(%rsp,%rcx,4),%edi
test   %edi,%edi
je     1500 <main+0x280>
mov    %r15,%rsi
call   1190 <FD_SET@plt>
movslq 0x8(%rsp),%rax
mov    0x10(%rsp,%rax,4),%ecx
cmp    %ecx,%ebp
cmovle %ecx,%ebp
jmp    1500 <main+0x280>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movl   $0x1,0xb0(%rsp)
movq   $0x0,0xb8(%rsp)
add    $0x1,%ebp
xor    %ebx,%ebx
mov    %ebp,%edi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
lea    0xb0(%rsp),%r8
call   1110 <select@plt>
movl   $0x0,0x8(%rsp)
jmp    15a0 <main+0x320>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x8(%rsp),%eax
lea    0x1(%rax),%ebx
mov    %ebx,0x8(%rsp)
cmp    $0x13,%eax
jge    1620 <main+0x3a0>
movslq %ebx,%rax
mov    0x10(%rsp,%rax,4),%edi
mov    %r15,%rsi
call   1070 <FD_ISSET@plt>
test   %rax,%rax
je     158c <main+0x30c>
movslq 0x8(%rsp),%rax
mov    0x10(%rsp,%rax,4),%edi
mov    %r12,%rsi
mov    $0x10000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jg     1580 <main+0x300>
js     1608 <main+0x388>
mov    %r13,%rdi
call   1040 <puts@plt>
movslq 0x8(%rsp),%rax
mov    0x10(%rsp,%rax,4),%edi
call   10e0 <close@plt>
movslq 0x8(%rsp),%rax
mov    0x10(%rsp,%rax,4),%edi
mov    %r15,%rsi
call   1170 <FD_CLR@plt>
movslq 0x8(%rsp),%rax
movl   $0x0,0x10(%rsp,%rax,4)
jmp    1590 <main+0x310>
lea    0xa04(%rip),%rdi
call   1150 <perror@plt>
jmp    15d2 <main+0x352>
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%r14
mov    0xc(%rsp),%edi
mov    %r15,%rsi
call   1070 <FD_ISSET@plt>
test   %rax,%rax
lea    0xa10(%rip),%rbx
je     1720 <main+0x4a0>
lea    0xc0(%rsp),%rdi
xor    %esi,%esi
call   10b0 <gettimeofday@plt>
mov    0xc(%rsp),%edi
mov    %r12,%rsi
mov    $0x10000,%edx
xor    %ecx,%ecx
lea    0x98(%rsp),%r8
lea    0x74(%rsp),%r9
call   1130 <recvfrom@plt>
mov    %eax,%ebp
test   %eax,%eax
js     1848 <main+0x5c8>
xor    %r13d,%r13d
lea    0x9b2(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
movl   $0x0,0x8(%rsp)
jmp    16e6 <main+0x466>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1040 <puts@plt>
movslq 0x8(%rsp),%rax
mov    0x10(%rsp,%rax,4),%edi
call   10e0 <close@plt>
movslq 0x8(%rsp),%rax
mov    0x10(%rsp,%rax,4),%edi
mov    %r15,%rsi
call   1170 <FD_CLR@plt>
movslq 0x8(%rsp),%r13
movl   $0x0,0x10(%rsp,%r13,4)
lea    0x1(%r13),%eax
mov    %eax,0x8(%rsp)
cmp    $0x13,%r13d
mov    %eax,%r13d
jge    1720 <main+0x4a0>
movslq %r13d,%rax
cmpl   $0x0,0x10(%rsp,%rax,4)
je     16d5 <main+0x455>
mov    %rbx,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
movslq 0x8(%rsp),%rax
mov    0x10(%rsp,%rax,4),%edi
mov    %r12,%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
test   %eax,%eax
jle    16a0 <main+0x420>
mov    0x8(%rsp),%r13d
jmp    16d5 <main+0x455>
nopl   (%rax)
mov    0x6c(%rsp),%ebx
mov    %ebx,%edi
mov    %r15,%rsi
call   1070 <FD_ISSET@plt>
test   %rax,%rax
mov    %r14,%r13
lea    0x8dd(%rip),%r14
je     14cf <main+0x24f>
cmpl   $0x0,0x10(%rsp)
je     1450 <main+0x1d0>
cmpl   $0x0,0x14(%rsp)
je     182a <main+0x5aa>
cmpl   $0x0,0x18(%rsp)
je     1834 <main+0x5b4>
cmpl   $0x0,0x1c(%rsp)
je     183e <main+0x5be>
cmpl   $0x0,0x20(%rsp)
je     1894 <main+0x614>
cmpl   $0x0,0x24(%rsp)
je     189e <main+0x61e>
cmpl   $0x0,0x28(%rsp)
je     18a8 <main+0x628>
cmpl   $0x0,0x2c(%rsp)
je     18b2 <main+0x632>
cmpl   $0x0,0x30(%rsp)
je     18bc <main+0x63c>
cmpl   $0x0,0x34(%rsp)
je     18c6 <main+0x646>
cmpl   $0x0,0x38(%rsp)
je     18d0 <main+0x650>
cmpl   $0x0,0x3c(%rsp)
je     18da <main+0x65a>
cmpl   $0x0,0x40(%rsp)
je     18e4 <main+0x664>
cmpl   $0x0,0x44(%rsp)
je     18ee <main+0x66e>
cmpl   $0x0,0x48(%rsp)
je     18f8 <main+0x678>
cmpl   $0x0,0x4c(%rsp)
je     1902 <main+0x682>
cmpl   $0x0,0x50(%rsp)
je     190c <main+0x68c>
cmpl   $0x0,0x54(%rsp)
je     1916 <main+0x696>
cmpl   $0x0,0x58(%rsp)
je     1920 <main+0x6a0>
cmpl   $0x0,0x5c(%rsp)
je     192a <main+0x6aa>
movl   $0x14,0x8(%rsp)
jmp    14cf <main+0x24f>
mov    $0x1,%eax
jmp    1452 <main+0x1d2>
mov    $0x2,%eax
jmp    1452 <main+0x1d2>
mov    $0x3,%eax
jmp    1452 <main+0x1d2>
lea    0x7dc(%rip),%rdi
call   1150 <perror@plt>
jmp    1678 <main+0x3f8>
lea    0x7a0(%rip),%rdi
call   1150 <perror@plt>
movslq 0x8(%rsp),%rax
movl   $0x0,0x10(%rsp,%rax,4)
lea    0x7e5(%rip),%rdi
call   1040 <puts@plt>
movslq 0x8(%rsp),%rax
mov    0x10(%rsp,%rax,4),%edi
mov    %r15,%rsi
call   1190 <FD_SET@plt>
jmp    14cf <main+0x24f>
mov    $0x4,%eax
jmp    1452 <main+0x1d2>
mov    $0x5,%eax
jmp    1452 <main+0x1d2>
mov    $0x6,%eax
jmp    1452 <main+0x1d2>
mov    $0x7,%eax
jmp    1452 <main+0x1d2>
mov    $0x8,%eax
jmp    1452 <main+0x1d2>
mov    $0x9,%eax
jmp    1452 <main+0x1d2>
mov    $0xa,%eax
jmp    1452 <main+0x1d2>
mov    $0xb,%eax
jmp    1452 <main+0x1d2>
mov    $0xc,%eax
jmp    1452 <main+0x1d2>
mov    $0xd,%eax
jmp    1452 <main+0x1d2>
mov    $0xe,%eax
jmp    1452 <main+0x1d2>
mov    $0xf,%eax
jmp    1452 <main+0x1d2>
mov    $0x10,%eax
jmp    1452 <main+0x1d2>
mov    $0x11,%eax
jmp    1452 <main+0x1d2>
mov    $0x12,%eax
jmp    1452 <main+0x1d2>
mov    $0x13,%eax
jmp    1452 <main+0x1d2>
lea    0x6cc(%rip),%rdi
jmp    194d <main+0x6cd>
lea    0x6bc(%rip),%rdi
jmp    194d <main+0x6cd>
lea    0x6bf(%rip),%rdi
call   1150 <perror@plt>
mov    $0x1,%edi
call   1180 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@PF_INET = global i8* null
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@INADDR_LOOPBACK = global i32 0
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.1 = [5 x i8] c"bind\00"
@.str.2 = [7 x i8] c"listen\00"
@.str.3 = [5 x i8] c"recv\00"
@.str.4 = [12 x i8] c"disconnect\0A\00"
@.str.5 = [19 x i8] c"receive uplink %d\0A\00"
@.str.6 = [9 x i8] c"recvfrom\00"
@.str.7 = [21 x i8] c"receive downlink %d\0A\00"
@.str.8 = [18 x i8] c"send downlink %d\0A\00"
@.str.9 = [9 x i8] c"connect\0A\00"
@SO_KEEPALIVE = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
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 [20 x i32]
%16 = alloca %struct.sockaddr_in
%17 = alloca %struct.sockaddr_in
%18 = alloca [65536 x i8]
%19 = alloca i32
%20 = alloca %struct.timeval
%21 = alloca %struct.timeval
%22 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%23 = bitcast [20 x i32]* %15 to i8*
store i32 1, i32* %22
%24 = load i32, i32* @SIGCHLD
%25 = load i32, i32* @SIG_IGN
%26 = call i32 @signal(i32 %24, i32 %25)
%27 = load i8*, i8** @AF_INET
%28 = load i32, i32* @SOCK_DGRAM
%29 = call i32 @socket(i8* %27, i32 %28, i32 0)
store i32 %29, i32* %13
%30 = load i8*, i8** @PF_INET
%31 = load i32, i32* @SOCK_STREAM
%32 = call i32 @socket(i8* %30, i32 %31, i32 0)
store i32 %32, i32* %14
%33 = load i32, i32* %13
%34 = icmp slt i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %2
%36 = load i32, i32* %14
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35, %2
%39 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %35
store i32 24, i32* %8
store i32 24, i32* %7
%42 = call i32 @memset(%struct.sockaddr_in* %16, i32 0, i32 24)
%43 = call i32 @memset(%struct.sockaddr_in* %17, i32 0, i32 24)
%44 = load i8*, i8** @AF_INET
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 2
store i8* %44, i8** %45
%46 = load i32, i32* @INADDR_LOOPBACK
%47 = call i32 @htonl(i32 %46)
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 1
%49 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %48, i32 0, i32 0
store i32 %47, i32* %49
%50 = call i8* @htons(i32 7023)
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 0
store i8* %50, i8** %51
%52 = load i8*, i8** @AF_INET
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 2
store i8* %52, i8** %53
%54 = load i32, i32* @INADDR_ANY
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 1
%56 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %55, i32 0, i32 0
store i32 %54, i32* %56
%57 = call i8* @htons(i32 7024)
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 0
store i8* %57, i8** %58
%59 = load i32, i32* %14
%60 = load i32, i32* @SOL_SOCKET
%61 = load i32, i32* @SO_REUSEADDR
%62 = bitcast i32* %22 to i8*
%63 = bitcast i8* %62 to i32*
%64 = call i32 @setsockopt(i32 %59, i32 %60, i32 %61, i32* %63, i32 4)
%65 = load i32, i32* %13
%66 = bitcast %struct.sockaddr_in* %16 to %struct.sockaddr*
%67 = load i32, i32* %7
%68 = call i64 @bind(i32 %65, %struct.sockaddr* %66, i32 %67)
%69 = icmp slt i64 %68, 0
br i1 %69, label %76, label %70
70: ; preds = %41
%71 = load i32, i32* %14
%72 = bitcast %struct.sockaddr_in* %17 to %struct.sockaddr*
%73 = load i32, i32* %7
%74 = call i64 @bind(i32 %71, %struct.sockaddr* %72, i32 %73)
%75 = icmp slt i64 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %70, %41
%77 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %70
%80 = load i32, i32* %14
%81 = call i64 @listen(i32 %80, i32 3)
%82 = icmp ne i64 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %79
%84 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %79
%87 = load i32, i32* %13
%88 = load i32, i32* %14
%89 = icmp sgt i32 %87, %88
br i1 %89, label %90, label %92
90: ; preds = %86
%91 = load i32, i32* %13
br label %94
92: ; preds = %86
%93 = load i32, i32* %14
br label %94
94: ; preds = %92, %90
%95 = phi i32 [ %91, %90 ], [ %93, %92 ]
store i32 %95, i32* %11
%96 = call i32 @FD_ZERO(i32* %19)
br label %97
97: ; preds = %94, %350
%98 = load i32, i32* %13
%99 = load i32, i32* %14
%100 = icmp sgt i32 %98, %99
br i1 %100, label %101, label %103
101: ; preds = %97
%102 = load i32, i32* %13
br label %105
103: ; preds = %97
%104 = load i32, i32* %14
br label %105
105: ; preds = %103, %101
%106 = phi i32 [ %102, %101 ], [ %104, %103 ]
store i32 %106, i32* %11
%107 = call i32 @FD_ZERO(i32* %19)
%108 = load i32, i32* %13
%109 = call i32 @FD_SET(i32 %108, i32* %19)
%110 = load i32, i32* %14
%111 = call i32 @FD_SET(i32 %110, i32* %19)
store i32 0, i32* %12
br label %112
112: ; preds = %143, %105
%113 = load i32, i32* %12
%114 = icmp slt i32 %113, 20
br i1 %114, label %115, label %146
115: ; preds = %112
%116 = load i32, i32* %12
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %117
%119 = load i32, i32* %118
%120 = icmp ne i32 %119, 0
br i1 %120, label %121, label %142
121: ; preds = %115
%122 = load i32, i32* %12
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %123
%125 = load i32, i32* %124
%126 = call i32 @FD_SET(i32 %125, i32* %19)
%127 = load i32, i32* %11
%128 = load i32, i32* %12
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %129
%131 = load i32, i32* %130
%132 = icmp sgt i32 %127, %131
br i1 %132, label %133, label %135
133: ; preds = %121
%134 = load i32, i32* %11
br label %140
135: ; preds = %121
%136 = load i32, i32* %12
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %137
%139 = load i32, i32* %138
br label %140
140: ; preds = %135, %133
%141 = phi i32 [ %134, %133 ], [ %139, %135 ]
store i32 %141, i32* %11
br label %142
142: ; preds = %140, %115
br label %143
143: ; preds = %142
%144 = load i32, i32* %12
%145 = add nsw i32 %144, 1
store i32 %145, i32* %12
br label %112
146: ; preds = %112
%147 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 0
store i32 1, i32* %147
%148 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 1
store i64 0, i64* %148
%149 = load i32, i32* %11
%150 = add nsw i32 %149, 1
%151 = call i32 @select(i32 %150, i32* %19, i32* null, i32* null, %struct.timeval* %20)
store i32 %151, i32* %10
store i32 0, i32* %12
br label %152
152: ; preds = %205, %146
%153 = load i32, i32* %12
%154 = icmp slt i32 %153, 20
br i1 %154, label %155, label %208
155: ; preds = %152
%156 = load i32, i32* %12
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %157
%159 = load i32, i32* %158
%160 = call i64 @FD_ISSET(i32 %159, i32* %19)
%161 = icmp ne i64 %160, 0
br i1 %161, label %162, label %204
162: ; preds = %155
%163 = load i32, i32* %12
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %164
%166 = load i32, i32* %165
%167 = getelementptr inbounds [65536 x i8], [65536 x i8]* %18, i64 0, i64 0
%168 = call i32 @recv(i32 %166, i8* %167, i32 65536, i32 0)
store i32 %168, i32* %9
%169 = load i32, i32* %9
%170 = icmp sle i32 %169, 0
br i1 %170, label %171, label %200
171: ; preds = %162
%172 = load i32, i32* %9
%173 = icmp slt i32 %172, 0
br i1 %173, label %174, label %176
174: ; preds = %171
%175 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %176
176: ; preds = %174, %171
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%178 = load i32, i32* %12
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %179
%181 = load i32, i32* %180
%182 = call i32 @close(i32 %181)
%183 = load i32, i32* %12
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %184
%186 = load i32, i32* %185
%187 = call i32 @FD_CLR(i32 %186, i32* %19)
%188 = load i32, i32* %13
%189 = load i32, i32* %14
%190 = icmp sgt i32 %188, %189
br i1 %190, label %191, label %193
191: ; preds = %176
%192 = load i32, i32* %13
br label %195
193: ; preds = %176
%194 = load i32, i32* %14
br label %195
195: ; preds = %193, %191
%196 = phi i32 [ %192, %191 ], [ %194, %193 ]
store i32 %196, i32* %11
%197 = load i32, i32* %12
%198 = sext i32 %197 to i64
%199 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %198
store i32 0, i32* %199
br label %203
200: ; preds = %162
%201 = load i32, i32* %9
%202 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %201)
br label %203
203: ; preds = %200, %195
br label %204
204: ; preds = %203, %155
br label %205
205: ; preds = %204
%206 = load i32, i32* %12
%207 = add nsw i32 %206, 1
store i32 %207, i32* %12
br label %152
208: ; preds = %152
%209 = load i32, i32* %13
%210 = call i64 @FD_ISSET(i32 %209, i32* %19)
%211 = icmp ne i64 %210, 0
br i1 %211, label %212, label %276
212: ; preds = %208
%213 = call i32 @gettimeofday(%struct.timeval* %21, i32* null)
%214 = load i32, i32* %13
%215 = getelementptr inbounds [65536 x i8], [65536 x i8]* %18, i64 0, i64 0
%216 = bitcast %struct.sockaddr_in* %16 to %struct.sockaddr*
%217 = call i32 @recvfrom(i32 %214, i8* %215, i32 65536, i32 0, %struct.sockaddr* %216, i32* %6)
store i32 %217, i32* %9
%218 = load i32, i32* %9
%219 = icmp slt i32 %218, 0
br i1 %219, label %220, label %222
220: ; preds = %212
%221 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %222
222: ; preds = %220, %212
%223 = load i32, i32* %9
%224 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %223)
store i32 0, i32* %12
br label %225
225: ; preds = %272, %222
%226 = load i32, i32* %12
%227 = icmp slt i32 %226, 20
br i1 %227, label %228, label %275
228: ; preds = %225
%229 = load i32, i32* %12
%230 = sext i32 %229 to i64
%231 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %230
%232 = load i32, i32* %231
%233 = icmp ne i32 %232, 0
br i1 %233, label %234, label %271
234: ; preds = %228
%235 = load i32, i32* %12
%236 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %235)
%237 = load i32, i32* %12
%238 = sext i32 %237 to i64
%239 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %238
%240 = load i32, i32* %239
%241 = getelementptr inbounds [65536 x i8], [65536 x i8]* %18, i64 0, i64 0
%242 = load i32, i32* %9
%243 = call i32 @send(i32 %240, i8* %241, i32 %242, i32 0)
store i32 %243, i32* %10
%244 = load i32, i32* %10
%245 = icmp sle i32 %244, 0
br i1 %245, label %246, label %270
246: ; preds = %234
%247 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%248 = load i32, i32* %12
%249 = sext i32 %248 to i64
%250 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %249
%251 = load i32, i32* %250
%252 = call i32 @close(i32 %251)
%253 = load i32, i32* %12
%254 = sext i32 %253 to i64
%255 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %254
%256 = load i32, i32* %255
%257 = call i32 @FD_CLR(i32 %256, i32* %19)
%258 = load i32, i32* %13
%259 = load i32, i32* %14
%260 = icmp sgt i32 %258, %259
br i1 %260, label %261, label %263
261: ; preds = %246
%262 = load i32, i32* %13
br label %265
263: ; preds = %246
%264 = load i32, i32* %14
br label %265
265: ; preds = %263, %261
%266 = phi i32 [ %262, %261 ], [ %264, %263 ]
store i32 %266, i32* %11
%267 = load i32, i32* %12
%268 = sext i32 %267 to i64
%269 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %268
store i32 0, i32* %269
br label %270
270: ; preds = %265, %234
br label %271
271: ; preds = %270, %228
br label %272
272: ; preds = %271
%273 = load i32, i32* %12
%274 = add nsw i32 %273, 1
store i32 %274, i32* %12
br label %225
275: ; preds = %225
br label %276
276: ; preds = %275, %208
%277 = load i32, i32* %14
%278 = call i64 @FD_ISSET(i32 %277, i32* %19)
%279 = icmp ne i64 %278, 0
br i1 %279, label %280, label %350
280: ; preds = %276
store i32 0, i32* %12
br label %281
281: ; preds = %346, %280
%282 = load i32, i32* %12
%283 = icmp slt i32 %282, 20
br i1 %283, label %284, label %349
284: ; preds = %281
%285 = load i32, i32* %12
%286 = sext i32 %285 to i64
%287 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %286
%288 = load i32, i32* %287
%289 = icmp eq i32 %288, 0
br i1 %289, label %290, label %345
290: ; preds = %284
%291 = load i32, i32* %14
%292 = bitcast %struct.sockaddr_in* %17 to %struct.sockaddr*
%293 = call i32 @accept(i32 %291, %struct.sockaddr* %292, i32* %6)
%294 = load i32, i32* %12
%295 = sext i32 %294 to i64
%296 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %295
store i32 %293, i32* %296
%297 = load i32, i32* %12
%298 = sext i32 %297 to i64
%299 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %298
%300 = load i32, i32* %299
%301 = icmp slt i32 %300, 0
br i1 %301, label %302, label %307
302: ; preds = %290
%303 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%304 = load i32, i32* %12
%305 = sext i32 %304 to i64
%306 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %305
store i32 0, i32* %306
br label %323
307: ; preds = %290
%308 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%309 = load i32, i32* %12
%310 = sext i32 %309 to i64
%311 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %310
%312 = load i32, i32* %311
%313 = load i32, i32* @SOL_SOCKET
%314 = load i32, i32* @SO_KEEPALIVE
%315 = call i32 @setsockopt(i32 %312, i32 %313, i32 %314, i32* %12, i32 4)
%316 = load i32, i32* %12
%317 = sext i32 %316 to i64
%318 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %317
%319 = load i32, i32* %318
%320 = load i32, i32* @F_SETFL
%321 = load i32, i32* @O_NONBLOCK
%322 = call i32 @fcntl(i32 %319, i32 %320, i32 %321)
br label %349
323: ; preds = %302
%324 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%325 = load i32, i32* %12
%326 = sext i32 %325 to i64
%327 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %326
%328 = load i32, i32* %327
%329 = call i32 @FD_SET(i32 %328, i32* %19)
%330 = load i32, i32* %11
%331 = load i32, i32* %12
%332 = sext i32 %331 to i64
%333 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %332
%334 = load i32, i32* %333
%335 = icmp sgt i32 %330, %334
br i1 %335, label %336, label %338
336: ; preds = %323
%337 = load i32, i32* %11
br label %343
338: ; preds = %323
%339 = load i32, i32* %12
%340 = sext i32 %339 to i64
%341 = getelementptr inbounds [20 x i32], [20 x i32]* %15, i64 0, i64 %340
%342 = load i32, i32* %341
br label %343
343: ; preds = %338, %336
%344 = phi i32 [ %337, %336 ], [ %342, %338 ]
store i32 %344, i32* %11
br label %349
345: ; preds = %284
br label %346
346: ; preds = %345
%347 = load i32, i32* %12
%348 = add nsw i32 %347, 1
store i32 %348, i32* %12
br label %281
349: ; preds = %343, %307, %281
br label %350
350: ; preds = %349, %276
br label %97
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@PF_INET = global i8* null
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@INADDR_LOOPBACK = global i32 0
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.1 = [5 x i8] c"bind\00"
@.str.2 = [7 x i8] c"listen\00"
@.str.3 = [5 x i8] c"recv\00"
@.str.5 = [19 x i8] c"receive uplink %d\0A\00"
@.str.6 = [9 x i8] c"recvfrom\00"
@.str.7 = [21 x i8] c"receive downlink %d\0A\00"
@.str.8 = [18 x i8] c"send downlink %d\0A\00"
@SO_KEEPALIVE = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@str.10 = [8 x i8] c"connect\00"
@str.12 = [11 x i8] c"disconnect\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [20 x i32]
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.sockaddr_in
%8 = alloca [65536 x i8]
%9 = alloca i32
%10 = alloca %struct.timeval
%11 = alloca %struct.timeval
%12 = alloca i32
%13 = bitcast i32* %3 to i8*
%14 = bitcast i32* %4 to i8*
%15 = bitcast [20 x i32]* %5 to i8*
%16 = bitcast %struct.sockaddr_in* %6 to i8*
%17 = bitcast %struct.sockaddr_in* %7 to i8*
%18 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%19 = bitcast i32* %9 to i8*
%20 = bitcast %struct.timeval* %10 to i8*
%21 = bitcast %struct.timeval* %11 to i8*
%22 = bitcast i32* %12 to i8*
store i32 1, i32* %12
%23 = load i32, i32* @SIGCHLD
%24 = load i32, i32* @SIG_IGN
%25 = tail call i32 @signal(i32 %23, i32 %24)
%26 = load i8*, i8** @AF_INET
%27 = load i32, i32* @SOCK_DGRAM
%28 = tail call i32 @socket(i8* %26, i32 %27, i32 0)
%29 = load i8*, i8** @PF_INET
%30 = load i32, i32* @SOCK_STREAM
%31 = tail call i32 @socket(i8* %29, i32 %30, i32 0)
%32 = icmp slt i32 %28, 0
%33 = icmp slt i32 %31, 0
%34 = select i1 %32, i1 true, i1 %33
br i1 %34, label %35, label %38
35: ; preds = %2
%36 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %2
%39 = call i32 @memset(%struct.sockaddr_in* %6, i32 0, i32 24)
%40 = call i32 @memset(%struct.sockaddr_in* %7, i32 0, i32 24)
%41 = load i8*, i8** @AF_INET
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
store i8* %41, i8** %42
%43 = load i32, i32* @INADDR_LOOPBACK
%44 = call i32 @htonl(i32 %43)
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1, i32 0
store i32 %44, i32* %45
%46 = call i8* @htons(i32 7023)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
store i8* %46, i8** %47
%48 = load i8*, i8** @AF_INET
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 2
store i8* %48, i8** %49
%50 = load i32, i32* @INADDR_ANY
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 1, i32 0
store i32 %50, i32* %51
%52 = call i8* @htons(i32 7024)
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 0
store i8* %52, i8** %53
%54 = load i32, i32* @SOL_SOCKET
%55 = load i32, i32* @SO_REUSEADDR
%56 = call i32 @setsockopt(i32 %31, i32 %54, i32 %55, i32* %12, i32 4)
%57 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%58 = call i64 @bind(i32 %28, %struct.sockaddr* %57, i32 24)
%59 = icmp slt i64 %58, 0
br i1 %59, label %64, label %60
60: ; preds = %38
%61 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%62 = call i64 @bind(i32 %31, %struct.sockaddr* %61, i32 24)
%63 = icmp slt i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %60, %38
%65 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %60
%68 = call i64 @listen(i32 %31, i32 3)
%69 = icmp eq i64 %68, 0
br i1 %69, label %73, label %70
70: ; preds = %67
%71 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %67
%74 = icmp ugt i32 %28, %31
%75 = call i32 @FD_ZERO(i32* %9)
%76 = select i1 %74, i32 %28, i32 %31
%77 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 0
%78 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 1
%79 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 0
%80 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 1
%81 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 2
%82 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 3
%83 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 4
%84 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 5
%85 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 6
%86 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 7
%87 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 8
%88 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 9
%89 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 10
%90 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 11
%91 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 12
%92 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 13
%93 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 14
%94 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 15
%95 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 16
%96 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 17
%97 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 18
%98 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 19
br label %99
99: ; preds = %311, %73
%100 = call i32 @FD_ZERO(i32* %9)
%101 = call i32 @FD_SET(i32 %28, i32* %9)
%102 = call i32 @FD_SET(i32 %31, i32* %9)
store i32 0, i32* %4
br label %103
103: ; preds = %99, %118
%104 = phi i32 [ %76, %99 ], [ %120, %118 ]
%105 = phi i32 [ 0, %99 ], [ %121, %118 ]
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %106
%108 = load i32, i32* %107
%109 = icmp eq i32 %108, 0
br i1 %109, label %118, label %110
110: ; preds = %103
%111 = call i32 @FD_SET(i32 %108, i32* %9)
%112 = load i32, i32* %4
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %113
%115 = load i32, i32* %114
%116 = icmp sgt i32 %104, %115
%117 = select i1 %116, i32 %104, i32 %115
br label %118
118: ; preds = %103, %110
%119 = phi i32 [ %112, %110 ], [ %105, %103 ]
%120 = phi i32 [ %117, %110 ], [ %104, %103 ]
%121 = add nsw i32 %119, 1
store i32 %121, i32* %4
%122 = icmp slt i32 %119, 19
br i1 %122, label %103, label %123
123: ; preds = %118
store i32 1, i32* %77
store i64 0, i64* %78
%124 = add nsw i32 %120, 1
%125 = call i32 @select(i32 %124, i32* %9, i32* null, i32* null, %struct.timeval* %10)
store i32 0, i32* %4
br label %126
126: ; preds = %123, %163
%127 = phi i32 [ 0, %123 ], [ %165, %163 ]
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %128
%130 = load i32, i32* %129
%131 = call i64 @FD_ISSET(i32 %130, i32* %9)
%132 = icmp eq i64 %131, 0
br i1 %132, label %161, label %133
133: ; preds = %126
%134 = load i32, i32* %4
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %135
%137 = load i32, i32* %136
%138 = call i32 @recv(i32 %137, i8* %18, i32 65536, i32 0)
%139 = icmp slt i32 %138, 1
br i1 %139, label %140, label %159
140: ; preds = %133
%141 = icmp slt i32 %138, 0
br i1 %141, label %142, label %144
142: ; preds = %140
%143 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %144
144: ; preds = %142, %140
%145 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.12, i64 0, i64 0))
%146 = load i32, i32* %4
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %147
%149 = load i32, i32* %148
%150 = call i32 @close(i32 %149)
%151 = load i32, i32* %4
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %152
%154 = load i32, i32* %153
%155 = call i32 @FD_CLR(i32 %154, i32* %9)
%156 = load i32, i32* %4
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %157
store i32 0, i32* %158
br label %163
159: ; preds = %133
%160 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %138)
br label %161
161: ; preds = %159, %126
%162 = load i32, i32* %4
br label %163
163: ; preds = %161, %144
%164 = phi i32 [ %162, %161 ], [ %156, %144 ]
%165 = add nsw i32 %164, 1
store i32 %165, i32* %4
%166 = icmp slt i32 %164, 19
br i1 %166, label %126, label %167
167: ; preds = %163
%168 = call i64 @FD_ISSET(i32 %28, i32* %9)
%169 = icmp eq i64 %168, 0
br i1 %169, label %213, label %170
170: ; preds = %167
%171 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%172 = call i32 @recvfrom(i32 %28, i8* %18, i32 65536, i32 0, %struct.sockaddr* %57, i32* %3)
%173 = icmp slt i32 %172, 0
br i1 %173, label %174, label %176
174: ; preds = %170
%175 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %176
176: ; preds = %174, %170
%177 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %172)
store i32 0, i32* %4
br label %178
178: ; preds = %176, %209
%179 = phi i32 [ 0, %176 ], [ %211, %209 ]
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %180
%182 = load i32, i32* %181
%183 = icmp eq i32 %182, 0
br i1 %183, label %209, label %184
184: ; preds = %178
%185 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %179)
%186 = load i32, i32* %4
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %187
%189 = load i32, i32* %188
%190 = call i32 @send(i32 %189, i8* %18, i32 %172, i32 0)
%191 = icmp slt i32 %190, 1
br i1 %191, label %194, label %192
192: ; preds = %184
%193 = load i32, i32* %4
br label %209
194: ; preds = %184
%195 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.12, i64 0, i64 0))
%196 = load i32, i32* %4
%197 = sext i32 %196 to i64
%198 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %197
%199 = load i32, i32* %198
%200 = call i32 @close(i32 %199)
%201 = load i32, i32* %4
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %202
%204 = load i32, i32* %203
%205 = call i32 @FD_CLR(i32 %204, i32* %9)
%206 = load i32, i32* %4
%207 = sext i32 %206 to i64
%208 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %207
store i32 0, i32* %208
br label %209
209: ; preds = %192, %178, %194
%210 = phi i32 [ %193, %192 ], [ %179, %178 ], [ %206, %194 ]
%211 = add nsw i32 %210, 1
store i32 %211, i32* %4
%212 = icmp slt i32 %210, 19
br i1 %212, label %178, label %213
213: ; preds = %209, %167
%214 = call i64 @FD_ISSET(i32 %31, i32* %9)
%215 = icmp eq i64 %214, 0
br i1 %215, label %311, label %216
216: ; preds = %213
%217 = load i32, i32* %79
%218 = icmp eq i32 %217, 0
br i1 %218, label %219, label %253
219: ; preds = %307, %304, %301, %298, %295, %292, %289, %286, %283, %280, %277, %274, %271, %268, %265, %262, %259, %256, %253, %216
%220 = phi i32 [ 0, %216 ], [ 1, %253 ], [ 2, %256 ], [ 3, %259 ], [ 4, %262 ], [ 5, %265 ], [ 6, %268 ], [ 7, %271 ], [ 8, %274 ], [ 9, %277 ], [ 10, %280 ], [ 11, %283 ], [ 12, %286 ], [ 13, %289 ], [ 14, %292 ], [ 15, %295 ], [ 16, %298 ], [ 17, %301 ], [ 18, %304 ], [ 19, %307 ]
store i32 %220, i32* %4
%221 = call i32 @accept(i32 %31, %struct.sockaddr* %61, i32* %3)
%222 = load i32, i32* %4
%223 = sext i32 %222 to i64
%224 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %223
store i32 %221, i32* %224
%225 = icmp slt i32 %221, 0
br i1 %225, label %226, label %237
226: ; preds = %219
%227 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%228 = load i32, i32* %4
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %229
store i32 0, i32* %230
%231 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.10, i64 0, i64 0))
%232 = load i32, i32* %4
%233 = sext i32 %232 to i64
%234 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %233
%235 = load i32, i32* %234
%236 = call i32 @FD_SET(i32 %235, i32* %9)
br label %311
237: ; preds = %219
%238 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.10, i64 0, i64 0))
%239 = load i32, i32* %4
%240 = sext i32 %239 to i64
%241 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %240
%242 = load i32, i32* %241
%243 = load i32, i32* @SOL_SOCKET
%244 = load i32, i32* @SO_KEEPALIVE
%245 = call i32 @setsockopt(i32 %242, i32 %243, i32 %244, i32* %4, i32 4)
%246 = load i32, i32* %4
%247 = sext i32 %246 to i64
%248 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %247
%249 = load i32, i32* %248
%250 = load i32, i32* @F_SETFL
%251 = load i32, i32* @O_NONBLOCK
%252 = call i32 @fcntl(i32 %249, i32 %250, i32 %251)
br label %311
253: ; preds = %216
%254 = load i32, i32* %80
%255 = icmp eq i32 %254, 0
br i1 %255, label %219, label %256
256: ; preds = %253
%257 = load i32, i32* %81
%258 = icmp eq i32 %257, 0
br i1 %258, label %219, label %259
259: ; preds = %256
%260 = load i32, i32* %82
%261 = icmp eq i32 %260, 0
br i1 %261, label %219, label %262
262: ; preds = %259
%263 = load i32, i32* %83
%264 = icmp eq i32 %263, 0
br i1 %264, label %219, label %265
265: ; preds = %262
%266 = load i32, i32* %84
%267 = icmp eq i32 %266, 0
br i1 %267, label %219, label %268
268: ; preds = %265
%269 = load i32, i32* %85
%270 = icmp eq i32 %269, 0
br i1 %270, label %219, label %271
271: ; preds = %268
%272 = load i32, i32* %86
%273 = icmp eq i32 %272, 0
br i1 %273, label %219, label %274
274: ; preds = %271
%275 = load i32, i32* %87
%276 = icmp eq i32 %275, 0
br i1 %276, label %219, label %277
277: ; preds = %274
%278 = load i32, i32* %88
%279 = icmp eq i32 %278, 0
br i1 %279, label %219, label %280
280: ; preds = %277
%281 = load i32, i32* %89
%282 = icmp eq i32 %281, 0
br i1 %282, label %219, label %283
283: ; preds = %280
%284 = load i32, i32* %90
%285 = icmp eq i32 %284, 0
br i1 %285, label %219, label %286
286: ; preds = %283
%287 = load i32, i32* %91
%288 = icmp eq i32 %287, 0
br i1 %288, label %219, label %289
289: ; preds = %286
%290 = load i32, i32* %92
%291 = icmp eq i32 %290, 0
br i1 %291, label %219, label %292
292: ; preds = %289
%293 = load i32, i32* %93
%294 = icmp eq i32 %293, 0
br i1 %294, label %219, label %295
295: ; preds = %292
%296 = load i32, i32* %94
%297 = icmp eq i32 %296, 0
br i1 %297, label %219, label %298
298: ; preds = %295
%299 = load i32, i32* %95
%300 = icmp eq i32 %299, 0
br i1 %300, label %219, label %301
301: ; preds = %298
%302 = load i32, i32* %96
%303 = icmp eq i32 %302, 0
br i1 %303, label %219, label %304
304: ; preds = %301
%305 = load i32, i32* %97
%306 = icmp eq i32 %305, 0
br i1 %306, label %219, label %307
307: ; preds = %304
%308 = load i32, i32* %98
%309 = icmp eq i32 %308, 0
br i1 %309, label %219, label %310
310: ; preds = %307
store i32 20, i32* %4
br label %311
311: ; preds = %310, %237, %226, %213
br label %99
}