#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 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*/ socklen_t;
typedef int /*<<< orphan*/ opt;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ address;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ EINTR;
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getpeername(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ htons(int);
char *inet_ntoa(TYPE_1__);
scalar_t__ listen(int, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int read(int, char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ send(int, char *, scalar_t__, int /*<<< orphan*/);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  int opt = (1);
  int master_socket, addrlen, new_socket,
      client_socket[30] = {}, max_clients = 30, activity, i, valread, sd;
  int max_sd;
  struct sockaddr_in address;
  char buffer[1025] = {};
  fd_set readfds;
  FD_ZERO(&readfds);
  char *message = "ECHO Daemon v1.0 \r\n";
  for (i = 0; i < max_clients; i++) {
    client_socket[i] = 0;
  }
  if ((master_socket = socket(AF_INET, SOCK_STREAM, 0)) == 0) {
    perror("socket failed");
    exit(EXIT_FAILURE);
  }
  if (setsockopt(master_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&opt,
                 sizeof(opt)) < 0) {
    perror("setsockopt");
    exit(EXIT_FAILURE);
  }
  address.sin_family = AF_INET;
  address.sin_addr.s_addr = INADDR_ANY;
  address.sin_port = htons((8888));
  if (bind(master_socket, (struct sockaddr *)&address, sizeof(address)) < 0) {
    perror("bind failed");
    exit(EXIT_FAILURE);
  }
  printf("Listener on port %d \n", (8888));
  if (listen(master_socket, 3) < 0) {
    perror("listen");
    exit(EXIT_FAILURE);
  }
  addrlen = sizeof(address);
  puts("Waiting for connections ...");
  while ((1)) {
    FD_ZERO(&readfds);
    FD_SET(master_socket, &readfds);
    max_sd = master_socket;
    for (i = 0; i < max_clients; i++) {
      sd = client_socket[i];
      if (sd > 0) {
        FD_SET(sd, &readfds);
      }
      if (sd > max_sd) {
        max_sd = sd;
      }
    }
    activity = select(max_sd + 1, &readfds, NULL, NULL, NULL);
    if ((activity < 0) && (errno != EINTR)) {
      printf("select error");
    }
    if (FD_ISSET(master_socket, &readfds)) {
      if ((new_socket = accept(master_socket, (struct sockaddr *)&address,
                               (socklen_t *)&addrlen)) < 0) {
        perror("accept");
        exit(EXIT_FAILURE);
      }
      printf("New connection , socket fd is %d , ip is : %s , port : %d \n",
             new_socket, inet_ntoa(address.sin_addr), ntohs(address.sin_port));
      if (send(new_socket, message, strlen(message), 0) != strlen(message)) {
        perror("send");
      }
      puts("Welcome message sent successfully");
      for (i = 0; i < max_clients; i++) {
        if (client_socket[i] == 0) {
          client_socket[i] = new_socket;
          printf("Adding to list of sockets as %d\n", i);
          break;
        }
      }
    }
    for (i = 0; i < max_clients; i++) {
      sd = client_socket[i];
      if (FD_ISSET(sd, &readfds)) {
        if ((valread = read(sd, buffer, 1024)) == 0) {
          getpeername(sd, (struct sockaddr *)&address, (socklen_t *)&addrlen);
          printf("Host disconnected , ip %s , port %d \n",
                 inet_ntoa(address.sin_addr), ntohs(address.sin_port));
          close(sd);
          client_socket[i] = 0;
        } else {
          buffer[valread] = '\0';
          send(sd, buffer, strlen(buffer), 0);
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x520,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x78,%edx
call   10c0 <memset@plt>
movl   $0x1e,-0xa4(%rbp)
lea    -0x4d0(%rbp),%rdi
xor    %esi,%esi
mov    $0x401,%edx
call   10c0 <memset@plt>
lea    -0x4d4(%rbp),%rdi
call   10f0 <FD_ZERO@plt>
lea    0xd3d(%rip),%rax
mov    %rax,-0x4e0(%rbp)
movl   $0x0,-0xac(%rbp)
mov    -0xac(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jge    130c <main+0xac>
movslq -0xac(%rbp),%rax
movl   $0x0,-0xa0(%rbp,%rax,4)
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
jmp    12d4 <main+0x74>
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
mov    0x2cac(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1180 <socket@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    134b <main+0xeb>
lea    0xcdc(%rip),%rdi
call   1140 <perror@plt>
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    -0x18(%rbp),%edi
mov    0x2c93(%rip),%rax
mov    (%rax),%esi
mov    0x2c4a(%rip),%rax
mov    (%rax),%edx
lea    -0x14(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    1393 <main+0x133>
lea    0xca2(%rip),%rdi
call   1140 <perror@plt>
mov    0x2c2c(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    0x2c46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc0(%rbp)
mov    0x2c2f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
mov    $0x22b8,%edi
call   1090 <htons@plt>
mov    %eax,-0xc8(%rbp)
mov    -0x18(%rbp),%edi
lea    -0xc8(%rbp),%rsi
mov    $0xc,%edx
call   1130 <bind@plt>
cmp    $0x0,%rax
jge    13f9 <main+0x199>
lea    0xc47(%rip),%rdi
call   1140 <perror@plt>
mov    0x2bc6(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
lea    0xc39(%rip),%rdi
mov    $0x22b8,%esi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x18(%rbp),%edi
mov    $0x3,%esi
call   1110 <listen@plt>
cmp    $0x0,%rax
jge    143d <main+0x1dd>
lea    0xc25(%rip),%rdi
call   1140 <perror@plt>
mov    0x2b82(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
movl   $0xc,-0x1c(%rbp)
lea    0xc0b(%rip),%rdi
call   1030 <puts@plt>
lea    -0x4d4(%rbp),%rdi
call   10f0 <FD_ZERO@plt>
mov    -0x18(%rbp),%edi
lea    -0x4d4(%rbp),%rsi
call   1170 <FD_SET@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0xb8(%rbp)
movl   $0x0,-0xac(%rbp)
mov    -0xac(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jge    14fa <main+0x29a>
movslq -0xac(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%eax
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jle    14c3 <main+0x263>
mov    -0xb4(%rbp),%edi
lea    -0x4d4(%rbp),%rsi
call   1170 <FD_SET@plt>
mov    -0xb4(%rbp),%eax
cmp    -0xb8(%rbp),%eax
jle    14e1 <main+0x281>
mov    -0xb4(%rbp),%eax
mov    %eax,-0xb8(%rbp)
jmp    14e6 <main+0x286>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
jmp    147e <main+0x21e>
mov    -0xb8(%rbp),%edi
add    $0x1,%edi
lea    -0x4d4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   1100 <select@plt>
mov    %eax,-0xa8(%rbp)
cmpl   $0x0,-0xa8(%rbp)
jge    1555 <main+0x2f5>
mov    0x2a8c(%rip),%rax
mov    (%rax),%rax
mov    0x2a72(%rip),%rcx
cmp    (%rcx),%rax
je     1555 <main+0x2f5>
lea    0xb24(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x18(%rbp),%edi
lea    -0x4d4(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     16db <main+0x47b>
mov    -0x18(%rbp),%edi
lea    -0xc8(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1150 <accept@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jge    15a7 <main+0x347>
lea    0xaeb(%rip),%rdi
call   1140 <perror@plt>
mov    0x2a18(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x504(%rbp)
mov    -0xc4(%rbp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,-0x500(%rbp)
mov    -0xc8(%rbp),%edi
call   1120 <ntohs@plt>
mov    -0x504(%rbp),%esi
mov    -0x500(%rbp),%rdx
mov    %eax,%ecx
lea    0xaa3(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4f4(%rbp)
mov    -0x4e0(%rbp),%rax
mov    %rax,-0x4f0(%rbp)
mov    -0x4e0(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x4f4(%rbp),%edi
mov    -0x4f0(%rbp),%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   10a0 <send@plt>
mov    %rax,-0x4e8(%rbp)
mov    -0x4e0(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,%rcx
mov    -0x4e8(%rbp),%rax
cmp    %rcx,%rax
je     1656 <main+0x3f6>
lea    0xa71(%rip),%rdi
call   1140 <perror@plt>
lea    0xa6a(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0xac(%rbp)
mov    -0xac(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jge    16d6 <main+0x476>
movslq -0xac(%rbp),%rax
cmpl   $0x0,-0xa0(%rbp,%rax,4)
jne    16bd <main+0x45d>
mov    -0x20(%rbp),%ecx
movslq -0xac(%rbp),%rax
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0xac(%rbp),%esi
lea    0xa38(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    16d6 <main+0x476>
jmp    16c2 <main+0x462>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
jmp    166c <main+0x40c>
jmp    16db <main+0x47b>
movl   $0x0,-0xac(%rbp)
mov    -0xac(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jge    1823 <main+0x5c3>
movslq -0xac(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%eax
mov    %eax,-0xb4(%rbp)
mov    -0xb4(%rbp),%edi
lea    -0x4d4(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     180a <main+0x5aa>
mov    -0xb4(%rbp),%edi
lea    -0x4d0(%rbp),%rsi
mov    $0x400,%edx
call   10e0 <read@plt>
mov    %eax,-0xb0(%rbp)
cmp    $0x0,%eax
jne    17b9 <main+0x559>
mov    -0xb4(%rbp),%edi
lea    -0xc8(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1070 <getpeername@plt>
mov    -0xc4(%rbp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,-0x510(%rbp)
mov    -0xc8(%rbp),%edi
call   1120 <ntohs@plt>
mov    -0x510(%rbp),%rsi
mov    %eax,%edx
lea    0x97a(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0xb4(%rbp),%edi
call   10d0 <close@plt>
movslq -0xac(%rbp),%rax
movl   $0x0,-0xa0(%rbp,%rax,4)
jmp    1805 <main+0x5a5>
movslq -0xb0(%rbp),%rax
movb   $0x0,-0x4d0(%rbp,%rax,1)
mov    -0xb4(%rbp),%eax
mov    %eax,-0x51c(%rbp)
lea    -0x4d0(%rbp),%rax
mov    %rax,-0x518(%rbp)
lea    -0x4d0(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x51c(%rbp),%edi
mov    -0x518(%rbp),%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   10a0 <send@plt>
jmp    180a <main+0x5aa>
jmp    180f <main+0x5af>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
jmp    16e5 <main+0x485>
jmp    1450 <main+0x1f0>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4a8,%rsp
movl   $0x1,0x1c(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x90(%rsp)
lea    0xa0(%rsp),%rdi
mov    $0x401,%edx
xor    %esi,%esi
call   10c0 <memset@plt>
lea    0x14(%rsp),%rdi
call   10f0 <FD_ZERO@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movq   $0x0,0x90(%rsp)
mov    0x2cd8(%rip),%rbx
mov    (%rbx),%edi
mov    0x2cb7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1180 <socket@plt>
test   %eax,%eax
jne    132a <main+0xca>
lea    0xcef(%rip),%rdi
jmp    1841 <main+0x5e1>
mov    %eax,%ebp
mov    0x2cb5(%rip),%rax
mov    (%rax),%esi
mov    0x2c6c(%rip),%rax
mov    (%rax),%edx
lea    0x1c(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
jns    1361 <main+0x101>
lea    0xcc6(%rip),%rdi
jmp    1841 <main+0x5e1>
mov    (%rbx),%eax
mov    %eax,0x8(%rsp)
mov    0x2c6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    $0x22b8,%edi
call   1090 <htons@plt>
mov    %eax,(%rsp)
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0xc,%edx
call   1130 <bind@plt>
test   %rax,%rax
jns    13a1 <main+0x141>
lea    0xc91(%rip),%rdi
jmp    1841 <main+0x5e1>
lea    0xc91(%rip),%rdi
mov    $0x22b8,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    %ebp,%edi
mov    $0x3,%esi
call   1110 <listen@plt>
test   %rax,%rax
jns    13d1 <main+0x171>
lea    0xc83(%rip),%rdi
jmp    1841 <main+0x5e1>
mov    %ebp,0x10(%rsp)
movl   $0xc,0x18(%rsp)
lea    0xc72(%rip),%rdi
call   1030 <puts@plt>
lea    0x14(%rsp),%r12
lea    0xa0(%rsp),%r14
lea    0x18(%rsp),%r13
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   10f0 <FD_ZERO@plt>
mov    0x10(%rsp),%ebp
mov    %ebp,%edi
mov    %r12,%rsi
call   1170 <FD_SET@plt>
xor    %ebx,%ebx
jmp    1431 <main+0x1d1>
nopw   0x0(%rax,%rax,1)
cmp    %ebp,%r15d
cmovg  %r15d,%ebp
add    $0x1,%rbx
cmp    $0x1e,%rbx
je     1450 <main+0x1f0>
mov    0x20(%rsp,%rbx,4),%r15d
test   %r15d,%r15d
jle    1420 <main+0x1c0>
mov    %r15d,%edi
mov    %r12,%rsi
call   1170 <FD_SET@plt>
jmp    1420 <main+0x1c0>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %ebp,%edi
mov    %r12,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1100 <select@plt>
test   %eax,%eax
jns    1490 <main+0x230>
mov    0x2b51(%rip),%rax
mov    (%rax),%rax
mov    0x2b37(%rip),%rcx
cmp    (%rcx),%rax
je     1490 <main+0x230>
lea    0xbed(%rip),%rdi
xor    %eax,%eax
call   10b0 <printf@plt>
nopl   0x0(%rax)
mov    0x10(%rsp),%ebx
mov    %ebx,%edi
mov    %r12,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1795 <main+0x535>
mov    %ebx,%edi
mov    %rsp,%rsi
mov    %r13,%rdx
call   1150 <accept@plt>
test   %eax,%eax
js     183a <main+0x5da>
mov    %eax,%r15d
mov    0x4(%rsp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,%rbx
mov    (%rsp),%edi
call   1120 <ntohs@plt>
lea    0xbac(%rip),%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   10b0 <printf@plt>
mov    $0x13,%edx
mov    %r15d,%edi
lea    0xb08(%rip),%rsi
xor    %ecx,%ecx
call   10a0 <send@plt>
cmp    $0x13,%rax
jne    16a5 <main+0x445>
lea    0xbb7(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x20(%rsp)
je     1680 <main+0x420>
cmpl   $0x0,0x24(%rsp)
je     1687 <main+0x427>
cmpl   $0x0,0x28(%rsp)
je     1691 <main+0x431>
cmpl   $0x0,0x2c(%rsp)
je     169b <main+0x43b>
cmpl   $0x0,0x30(%rsp)
je     16b6 <main+0x456>
cmpl   $0x0,0x34(%rsp)
je     16c0 <main+0x460>
cmpl   $0x0,0x38(%rsp)
je     16ca <main+0x46a>
cmpl   $0x0,0x3c(%rsp)
je     16d4 <main+0x474>
cmpl   $0x0,0x40(%rsp)
je     16de <main+0x47e>
cmpl   $0x0,0x44(%rsp)
je     16e8 <main+0x488>
cmpl   $0x0,0x48(%rsp)
je     16f2 <main+0x492>
cmpl   $0x0,0x4c(%rsp)
je     16fc <main+0x49c>
cmpl   $0x0,0x50(%rsp)
je     1706 <main+0x4a6>
cmpl   $0x0,0x54(%rsp)
je     170d <main+0x4ad>
cmpl   $0x0,0x58(%rsp)
je     1714 <main+0x4b4>
cmpl   $0x0,0x5c(%rsp)
je     171b <main+0x4bb>
cmpl   $0x0,0x60(%rsp)
je     1722 <main+0x4c2>
cmpl   $0x0,0x64(%rsp)
je     1729 <main+0x4c9>
cmpl   $0x0,0x68(%rsp)
je     1730 <main+0x4d0>
cmpl   $0x0,0x6c(%rsp)
je     1737 <main+0x4d7>
cmpl   $0x0,0x70(%rsp)
je     173e <main+0x4de>
cmpl   $0x0,0x74(%rsp)
je     1745 <main+0x4e5>
cmpl   $0x0,0x78(%rsp)
je     174c <main+0x4ec>
cmpl   $0x0,0x7c(%rsp)
je     1753 <main+0x4f3>
cmpl   $0x0,0x80(%rsp)
je     175a <main+0x4fa>
cmpl   $0x0,0x84(%rsp)
je     1761 <main+0x501>
cmpl   $0x0,0x88(%rsp)
je     1768 <main+0x508>
cmpl   $0x0,0x8c(%rsp)
je     176f <main+0x50f>
cmpl   $0x0,0x90(%rsp)
je     1776 <main+0x516>
cmpl   $0x0,0x94(%rsp)
jne    1795 <main+0x535>
mov    $0x1d,%esi
jmp    1780 <main+0x520>
nopl   0x0(%rax,%rax,1)
xor    %esi,%esi
jmp    1780 <main+0x520>
mov    $0x1,%esi
jmp    1780 <main+0x520>
mov    $0x2,%esi
jmp    1780 <main+0x520>
mov    $0x3,%esi
jmp    1780 <main+0x520>
lea    0xa16(%rip),%rdi
call   1140 <perror@plt>
jmp    1509 <main+0x2a9>
mov    $0x4,%esi
jmp    1780 <main+0x520>
mov    $0x5,%esi
jmp    1780 <main+0x520>
mov    $0x6,%esi
jmp    1780 <main+0x520>
mov    $0x7,%esi
jmp    1780 <main+0x520>
mov    $0x8,%esi
jmp    1780 <main+0x520>
mov    $0x9,%esi
jmp    1780 <main+0x520>
mov    $0xa,%esi
jmp    1780 <main+0x520>
mov    $0xb,%esi
jmp    1780 <main+0x520>
mov    $0xc,%esi
jmp    1780 <main+0x520>
mov    $0xd,%esi
jmp    1780 <main+0x520>
mov    $0xe,%esi
jmp    1780 <main+0x520>
mov    $0xf,%esi
jmp    1780 <main+0x520>
mov    $0x10,%esi
jmp    1780 <main+0x520>
mov    $0x11,%esi
jmp    1780 <main+0x520>
mov    $0x12,%esi
jmp    1780 <main+0x520>
mov    $0x13,%esi
jmp    1780 <main+0x520>
mov    $0x14,%esi
jmp    1780 <main+0x520>
mov    $0x15,%esi
jmp    1780 <main+0x520>
mov    $0x16,%esi
jmp    1780 <main+0x520>
mov    $0x17,%esi
jmp    1780 <main+0x520>
mov    $0x18,%esi
jmp    1780 <main+0x520>
mov    $0x19,%esi
jmp    1780 <main+0x520>
mov    $0x1a,%esi
jmp    1780 <main+0x520>
mov    $0x1b,%esi
jmp    1780 <main+0x520>
mov    $0x1c,%esi
nopl   0x0(%rax,%rax,1)
mov    %esi,%eax
mov    %r15d,0x20(%rsp,%rax,4)
lea    0x95b(%rip),%rdi
xor    %eax,%eax
call   10b0 <printf@plt>
xor    %ebx,%ebx
jmp    17cf <main+0x56f>
nopl   0x0(%rax)
cltq
movb   $0x0,0xa0(%rsp,%rax,1)
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   10a0 <send@plt>
add    $0x1,%rbx
cmp    $0x1e,%rbx
je     1400 <main+0x1a0>
mov    0x20(%rsp,%rbx,4),%ebp
mov    %ebp,%edi
mov    %r12,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     17c1 <main+0x561>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   10e0 <read@plt>
test   %eax,%eax
jne    17a0 <main+0x540>
mov    %ebp,%edi
mov    %rsp,%rsi
mov    %r13,%rdx
call   1070 <getpeername@plt>
mov    0x4(%rsp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,%r15
mov    (%rsp),%edi
call   1120 <ntohs@plt>
lea    0x8ed(%rip),%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <printf@plt>
mov    %ebp,%edi
call   10d0 <close@plt>
movl   $0x0,0x20(%rsp,%rbx,4)
jmp    17c1 <main+0x561>
lea    0x83e(%rip),%rdi
call   1140 <perror@plt>
mov    0x276b(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [20 x i8] c"ECHO Daemon v1.0 \0D\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [14 x i8] c"socket failed\00"
@EXIT_FAILURE = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [11 x i8] c"setsockopt\00"
@INADDR_ANY = global i32 0
@.str.3 = [12 x i8] c"bind failed\00"
@.str.4 = [22 x i8] c"Listener on port %d \0A\00"
@.str.5 = [7 x i8] c"listen\00"
@.str.6 = [28 x i8] c"Waiting for connections ...\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.7 = [13 x i8] c"select error\00"
@.str.8 = [7 x i8] c"accept\00"
@.str.9 = [60 x i8] c"New connection , socket fd is %d , ip is : %s , port : %d \0A\00"
@.str.10 = [5 x i8] c"send\00"
@.str.11 = [34 x i8] c"Welcome message sent successfully\00"
@.str.12 = [33 x i8] c"Adding to list of sockets as %d\0A\00"
@.str.13 = [38 x i8] c"Host disconnected , ip %s , port %d \0A\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 [30 x i32]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca %struct.sockaddr_in
%18 = alloca [1025 x i8]
%19 = alloca i32
%20 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
%21 = bitcast [30 x i32]* %10 to i8*
store i32 30, i32* %11
%22 = bitcast [1025 x i8]* %18 to i8*
%23 = call i32 @FD_ZERO(i32* %19)
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8** %20
store i32 0, i32* %13
br label %24
24: ; preds = %32, %2
%25 = load i32, i32* %13
%26 = load i32, i32* %11
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = load i32, i32* %13
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [30 x i32], [30 x i32]* %10, i64 0, i64 %30
store i32 0, i32* %31
br label %32
32: ; preds = %28
%33 = load i32, i32* %13
%34 = add nsw i32 %33, 1
store i32 %34, i32* %13
br label %24
35: ; preds = %24
%36 = load i32, i32* @AF_INET
%37 = load i32, i32* @SOCK_STREAM
%38 = call i32 @socket(i32 %36, i32 %37, i32 0)
store i32 %38, i32* %7
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %35
%41 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %35
%45 = load i32, i32* %7
%46 = load i32, i32* @SOL_SOCKET
%47 = load i32, i32* @SO_REUSEADDR
%48 = bitcast i32* %6 to i8*
%49 = call i64 @setsockopt(i32 %45, i32 %46, i32 %47, i8* %48, i32 4)
%50 = icmp slt i64 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %44
%52 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 @exit(i32 %53)
unreachable
55: ; preds = %44
%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 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 1
%60 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %59, i32 0, i32 0
store i32 %58, i32* %60
%61 = call i32 @htons(i32 8888)
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 0
store i32 %61, i32* %62
%63 = load i32, i32* %7
%64 = bitcast %struct.sockaddr_in* %17 to %struct.sockaddr*
%65 = call i64 @bind(i32 %63, %struct.sockaddr* %64, i32 12)
%66 = icmp slt i64 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %55
%68 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %55
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 8888)
%73 = load i32, i32* %7
%74 = call i64 @listen(i32 %73, i32 3)
%75 = icmp slt i64 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %71
%77 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%78 = load i32, i32* @EXIT_FAILURE
%79 = call i32 @exit(i32 %78)
unreachable
80: ; preds = %71
store i32 12, i32* %8
%81 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %82
82: ; preds = %80, %229
%83 = call i32 @FD_ZERO(i32* %19)
%84 = load i32, i32* %7
%85 = call i32 @FD_SET(i32 %84, i32* %19)
%86 = load i32, i32* %7
store i32 %86, i32* %16
store i32 0, i32* %13
br label %87
87: ; preds = %108, %82
%88 = load i32, i32* %13
%89 = load i32, i32* %11
%90 = icmp slt i32 %88, %89
br i1 %90, label %91, label %111
91: ; preds = %87
%92 = load i32, i32* %13
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [30 x i32], [30 x i32]* %10, i64 0, i64 %93
%95 = load i32, i32* %94
store i32 %95, i32* %15
%96 = load i32, i32* %15
%97 = icmp sgt i32 %96, 0
br i1 %97, label %98, label %101
98: ; preds = %91
%99 = load i32, i32* %15
%100 = call i32 @FD_SET(i32 %99, i32* %19)
br label %101
101: ; preds = %98, %91
%102 = load i32, i32* %15
%103 = load i32, i32* %16
%104 = icmp sgt i32 %102, %103
br i1 %104, label %105, label %107
105: ; preds = %101
%106 = load i32, i32* %15
store i32 %106, i32* %16
br label %107
107: ; preds = %105, %101
br label %108
108: ; preds = %107
%109 = load i32, i32* %13
%110 = add nsw i32 %109, 1
store i32 %110, i32* %13
br label %87
111: ; preds = %87
%112 = load i32, i32* %16
%113 = add nsw i32 %112, 1
%114 = call i32 @select(i32 %113, i32* %19, i32* null, i32* null, i32* null)
store i32 %114, i32* %12
%115 = load i32, i32* %12
%116 = icmp slt i32 %115, 0
br i1 %116, label %117, label %123
117: ; preds = %111
%118 = load i64, i64* @errno
%119 = load i64, i64* @EINTR
%120 = icmp ne i64 %118, %119
br i1 %120, label %121, label %123
121: ; preds = %117
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %123
123: ; preds = %121, %117, %111
%124 = load i32, i32* %7
%125 = call i64 @FD_ISSET(i32 %124, i32* %19)
%126 = icmp ne i64 %125, 0
br i1 %126, label %127, label %180
127: ; preds = %123
%128 = load i32, i32* %7
%129 = bitcast %struct.sockaddr_in* %17 to %struct.sockaddr*
%130 = call i32 @accept(i32 %128, %struct.sockaddr* %129, i32* %8)
store i32 %130, i32* %9
%131 = icmp slt i32 %130, 0
br i1 %131, label %132, label %136
132: ; preds = %127
%133 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%134 = load i32, i32* @EXIT_FAILURE
%135 = call i32 @exit(i32 %134)
unreachable
136: ; preds = %127
%137 = load i32, i32* %9
%138 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 1
%139 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %138, i32 0, i32 0
%140 = load i32, i32* %139
%141 = call i8* @inet_ntoa(i32 %140)
%142 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 0
%143 = load i32, i32* %142
%144 = call i32 @ntohs(i32 %143)
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), i32 %137, i8* %141, i32 %144)
%146 = load i32, i32* %9
%147 = load i8*, i8** %20
%148 = load i8*, i8** %20
%149 = call i64 @strlen(i8* %148)
%150 = call i64 @send(i32 %146, i8* %147, i64 %149, i32 0)
%151 = load i8*, i8** %20
%152 = call i64 @strlen(i8* %151)
%153 = icmp ne i64 %150, %152
br i1 %153, label %154, label %156
154: ; preds = %136
%155 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %156
156: ; preds = %154, %136
%157 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %13
br label %158
158: ; preds = %176, %156
%159 = load i32, i32* %13
%160 = load i32, i32* %11
%161 = icmp slt i32 %159, %160
br i1 %161, label %162, label %179
162: ; preds = %158
%163 = load i32, i32* %13
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds [30 x i32], [30 x i32]* %10, i64 0, i64 %164
%166 = load i32, i32* %165
%167 = icmp eq i32 %166, 0
br i1 %167, label %168, label %175
168: ; preds = %162
%169 = load i32, i32* %9
%170 = load i32, i32* %13
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds [30 x i32], [30 x i32]* %10, i64 0, i64 %171
store i32 %169, i32* %172
%173 = load i32, i32* %13
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), i32 %173)
br label %179
175: ; preds = %162
br label %176
176: ; preds = %175
%177 = load i32, i32* %13
%178 = add nsw i32 %177, 1
store i32 %178, i32* %13
br label %158
179: ; preds = %168, %158
br label %180
180: ; preds = %179, %123
store i32 0, i32* %13
br label %181
181: ; preds = %226, %180
%182 = load i32, i32* %13
%183 = load i32, i32* %11
%184 = icmp slt i32 %182, %183
br i1 %184, label %185, label %229
185: ; preds = %181
%186 = load i32, i32* %13
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds [30 x i32], [30 x i32]* %10, i64 0, i64 %187
%189 = load i32, i32* %188
store i32 %189, i32* %15
%190 = load i32, i32* %15
%191 = call i64 @FD_ISSET(i32 %190, i32* %19)
%192 = icmp ne i64 %191, 0
br i1 %192, label %193, label %225
193: ; preds = %185
%194 = load i32, i32* %15
%195 = getelementptr inbounds [1025 x i8], [1025 x i8]* %18, i64 0, i64 0
%196 = call i32 @read(i32 %194, i8* %195, i32 1024)
store i32 %196, i32* %14
%197 = icmp eq i32 %196, 0
br i1 %197, label %198, label %215
198: ; preds = %193
%199 = load i32, i32* %15
%200 = bitcast %struct.sockaddr_in* %17 to %struct.sockaddr*
%201 = call i32 @getpeername(i32 %199, %struct.sockaddr* %200, i32* %8)
%202 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 1
%203 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %202, i32 0, i32 0
%204 = load i32, i32* %203
%205 = call i8* @inet_ntoa(i32 %204)
%206 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 0
%207 = load i32, i32* %206
%208 = call i32 @ntohs(i32 %207)
%209 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i8* %205, i32 %208)
%210 = load i32, i32* %15
%211 = call i32 @close(i32 %210)
%212 = load i32, i32* %13
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds [30 x i32], [30 x i32]* %10, i64 0, i64 %213
store i32 0, i32* %214
br label %224
215: ; preds = %193
%216 = load i32, i32* %14
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds [1025 x i8], [1025 x i8]* %18, i64 0, i64 %217
store i8 0, i8* %218
%219 = load i32, i32* %15
%220 = getelementptr inbounds [1025 x i8], [1025 x i8]* %18, i64 0, i64 0
%221 = getelementptr inbounds [1025 x i8], [1025 x i8]* %18, i64 0, i64 0
%222 = call i64 @strlen(i8* %221)
%223 = call i64 @send(i32 %219, i8* %220, i64 %222, i32 0)
br label %224
224: ; preds = %215, %198
br label %225
225: ; preds = %224, %185
br label %226
226: ; preds = %225
%227 = load i32, i32* %13
%228 = add nsw i32 %227, 1
store i32 %228, i32* %13
br label %181
229: ; preds = %181
br label %82
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [20 x i8] c"ECHO Daemon v1.0 \0D\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [14 x i8] c"socket failed\00"
@EXIT_FAILURE = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [11 x i8] c"setsockopt\00"
@INADDR_ANY = global i32 0
@.str.3 = [12 x i8] c"bind failed\00"
@.str.4 = [22 x i8] c"Listener on port %d \0A\00"
@.str.5 = [7 x i8] c"listen\00"
@.str.6 = [28 x i8] c"Waiting for connections ...\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.7 = [13 x i8] c"select error\00"
@.str.8 = [7 x i8] c"accept\00"
@.str.9 = [60 x i8] c"New connection , socket fd is %d , ip is : %s , port : %d \0A\00"
@.str.10 = [5 x i8] c"send\00"
@.str.11 = [34 x i8] c"Welcome message sent successfully\00"
@.str.12 = [33 x i8] c"Adding to list of sockets as %d\0A\00"
@.str.13 = [38 x i8] c"Host disconnected , ip %s , port %d \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [30 x i32]
%6 = bitcast [30 x i32]* %5 to i8*
%7 = alloca %struct.sockaddr_in
%8 = alloca [1025 x i8]
%9 = alloca i32
%10 = bitcast i32* %3 to i8*
store i32 1, i32* %3
%11 = bitcast i32* %4 to i8*
%12 = bitcast %struct.sockaddr_in* %7 to i8*
%13 = getelementptr inbounds [1025 x i8], [1025 x i8]* %8, i64 0, i64 0
%14 = bitcast i32* %9 to i8*
%15 = call i32 @FD_ZERO(i32* %9)
%16 = load i32, i32* @AF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = call i32 @socket(i32 %16, i32 %17, i32 0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %2
%25 = load i32, i32* @SOL_SOCKET
%26 = load i32, i32* @SO_REUSEADDR
%27 = call i64 @setsockopt(i32 %18, i32 %25, i32 %26, i8* %10, i32 4)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %24
%30 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %24
%34 = load i32, i32* @AF_INET
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 2
store i32 %34, i32* %35
%36 = load i32, i32* @INADDR_ANY
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 1, i32 0
store i32 %36, i32* %37
%38 = call i32 @htons(i32 8888)
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 0
store i32 %38, i32* %39
%40 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%41 = call i64 @bind(i32 %18, %struct.sockaddr* %40, i32 12)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %33
%44 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @exit(i32 %45)
unreachable
47: ; preds = %33
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 8888)
%49 = call i64 @listen(i32 %18, i32 3)
%50 = icmp slt i64 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %47
%52 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 @exit(i32 %53)
unreachable
55: ; preds = %47
store i32 12, i32* %4
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%57 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 0
%58 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 1
%59 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 2
%60 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 3
%61 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 4
%62 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 5
%63 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 6
%64 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 7
%65 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 8
%66 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 9
%67 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 10
%68 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 11
%69 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 12
%70 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 13
%71 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 14
%72 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 15
%73 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 16
%74 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 17
%75 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 18
%76 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 19
%77 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 20
%78 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 21
%79 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 22
%80 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 23
%81 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 24
%82 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 25
%83 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 26
%84 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 27
%85 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 28
%86 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 29
br label %87
87: ; preds = %252, %55
%88 = call i32 @FD_ZERO(i32* %9)
%89 = call i32 @FD_SET(i32 %18, i32* %9)
br label %90
90: ; preds = %87, %98
%91 = phi i64 [ 0, %87 ], [ %101, %98 ]
%92 = phi i32 [ %18, %87 ], [ %100, %98 ]
%93 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 %91
%94 = load i32, i32* %93
%95 = icmp sgt i32 %94, 0
br i1 %95, label %96, label %98
96: ; preds = %90
%97 = call i32 @FD_SET(i32 %94, i32* %9)
br label %98
98: ; preds = %96, %90
%99 = icmp sgt i32 %94, %92
%100 = select i1 %99, i32 %94, i32 %92
%101 = add nuw nsw i64 %91, 1
%102 = icmp eq i64 %101, 30
br i1 %102, label %103, label %90
103: ; preds = %98
%104 = add nsw i32 %100, 1
%105 = call i32 @select(i32 %104, i32* %9, i32* null, i32* null, i32* null)
%106 = icmp slt i32 %105, 0
br i1 %106, label %107, label %113
107: ; preds = %103
%108 = load i64, i64* @errno
%109 = load i64, i64* @EINTR
%110 = icmp eq i64 %108, %109
br i1 %110, label %113, label %111
111: ; preds = %107
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %113
113: ; preds = %111, %107, %103
%114 = call i64 @FD_ISSET(i32 %18, i32* %9)
%115 = icmp eq i64 %114, 0
br i1 %115, label %229, label %116
116: ; preds = %113
%117 = call i32 @accept(i32 %18, %struct.sockaddr* %40, i32* %4)
%118 = icmp slt i32 %117, 0
br i1 %118, label %119, label %123
119: ; preds = %116
%120 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%121 = load i32, i32* @EXIT_FAILURE
%122 = call i32 @exit(i32 %121)
unreachable
123: ; preds = %116
%124 = load i32, i32* %37
%125 = call i8* @inet_ntoa(i32 %124)
%126 = load i32, i32* %39
%127 = call i32 @ntohs(i32 %126)
%128 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), i32 %117, i8* %125, i32 %127)
%129 = call i64 @send(i32 %117, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i64 19, i32 0)
%130 = icmp eq i64 %129, 19
br i1 %130, label %133, label %131
131: ; preds = %123
%132 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %133
133: ; preds = %131, %123
%134 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0))
%135 = load i32, i32* %57
%136 = icmp eq i32 %135, 0
br i1 %136, label %137, label %142
137: ; preds = %226, %223, %220, %217, %214, %211, %208, %205, %202, %199, %196, %193, %190, %187, %184, %181, %178, %175, %172, %169, %166, %163, %160, %157, %154, %151, %148, %145, %142, %133
%138 = phi i32 [ 0, %133 ], [ 1, %142 ], [ 2, %145 ], [ 3, %148 ], [ 4, %151 ], [ 5, %154 ], [ 6, %157 ], [ 7, %160 ], [ 8, %163 ], [ 9, %166 ], [ 10, %169 ], [ 11, %172 ], [ 12, %175 ], [ 13, %178 ], [ 14, %181 ], [ 15, %184 ], [ 16, %187 ], [ 17, %190 ], [ 18, %193 ], [ 19, %196 ], [ 20, %199 ], [ 21, %202 ], [ 22, %205 ], [ 23, %208 ], [ 24, %211 ], [ 25, %214 ], [ 26, %217 ], [ 27, %220 ], [ 28, %223 ], [ 29, %226 ]
%139 = zext i32 %138 to i64
%140 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 %139
store i32 %117, i32* %140
%141 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), i32 %138)
br label %229
142: ; preds = %133
%143 = load i32, i32* %58
%144 = icmp eq i32 %143, 0
br i1 %144, label %137, label %145
145: ; preds = %142
%146 = load i32, i32* %59
%147 = icmp eq i32 %146, 0
br i1 %147, label %137, label %148
148: ; preds = %145
%149 = load i32, i32* %60
%150 = icmp eq i32 %149, 0
br i1 %150, label %137, label %151
151: ; preds = %148
%152 = load i32, i32* %61
%153 = icmp eq i32 %152, 0
br i1 %153, label %137, label %154
154: ; preds = %151
%155 = load i32, i32* %62
%156 = icmp eq i32 %155, 0
br i1 %156, label %137, label %157
157: ; preds = %154
%158 = load i32, i32* %63
%159 = icmp eq i32 %158, 0
br i1 %159, label %137, label %160
160: ; preds = %157
%161 = load i32, i32* %64
%162 = icmp eq i32 %161, 0
br i1 %162, label %137, label %163
163: ; preds = %160
%164 = load i32, i32* %65
%165 = icmp eq i32 %164, 0
br i1 %165, label %137, label %166
166: ; preds = %163
%167 = load i32, i32* %66
%168 = icmp eq i32 %167, 0
br i1 %168, label %137, label %169
169: ; preds = %166
%170 = load i32, i32* %67
%171 = icmp eq i32 %170, 0
br i1 %171, label %137, label %172
172: ; preds = %169
%173 = load i32, i32* %68
%174 = icmp eq i32 %173, 0
br i1 %174, label %137, label %175
175: ; preds = %172
%176 = load i32, i32* %69
%177 = icmp eq i32 %176, 0
br i1 %177, label %137, label %178
178: ; preds = %175
%179 = load i32, i32* %70
%180 = icmp eq i32 %179, 0
br i1 %180, label %137, label %181
181: ; preds = %178
%182 = load i32, i32* %71
%183 = icmp eq i32 %182, 0
br i1 %183, label %137, label %184
184: ; preds = %181
%185 = load i32, i32* %72
%186 = icmp eq i32 %185, 0
br i1 %186, label %137, label %187
187: ; preds = %184
%188 = load i32, i32* %73
%189 = icmp eq i32 %188, 0
br i1 %189, label %137, label %190
190: ; preds = %187
%191 = load i32, i32* %74
%192 = icmp eq i32 %191, 0
br i1 %192, label %137, label %193
193: ; preds = %190
%194 = load i32, i32* %75
%195 = icmp eq i32 %194, 0
br i1 %195, label %137, label %196
196: ; preds = %193
%197 = load i32, i32* %76
%198 = icmp eq i32 %197, 0
br i1 %198, label %137, label %199
199: ; preds = %196
%200 = load i32, i32* %77
%201 = icmp eq i32 %200, 0
br i1 %201, label %137, label %202
202: ; preds = %199
%203 = load i32, i32* %78
%204 = icmp eq i32 %203, 0
br i1 %204, label %137, label %205
205: ; preds = %202
%206 = load i32, i32* %79
%207 = icmp eq i32 %206, 0
br i1 %207, label %137, label %208
208: ; preds = %205
%209 = load i32, i32* %80
%210 = icmp eq i32 %209, 0
br i1 %210, label %137, label %211
211: ; preds = %208
%212 = load i32, i32* %81
%213 = icmp eq i32 %212, 0
br i1 %213, label %137, label %214
214: ; preds = %211
%215 = load i32, i32* %82
%216 = icmp eq i32 %215, 0
br i1 %216, label %137, label %217
217: ; preds = %214
%218 = load i32, i32* %83
%219 = icmp eq i32 %218, 0
br i1 %219, label %137, label %220
220: ; preds = %217
%221 = load i32, i32* %84
%222 = icmp eq i32 %221, 0
br i1 %222, label %137, label %223
223: ; preds = %220
%224 = load i32, i32* %85
%225 = icmp eq i32 %224, 0
br i1 %225, label %137, label %226
226: ; preds = %223
%227 = load i32, i32* %86
%228 = icmp eq i32 %227, 0
br i1 %228, label %137, label %229
229: ; preds = %226, %137, %113
br label %230
230: ; preds = %229, %252
%231 = phi i64 [ %253, %252 ], [ 0, %229 ]
%232 = getelementptr inbounds [30 x i32], [30 x i32]* %5, i64 0, i64 %231
%233 = load i32, i32* %232
%234 = call i64 @FD_ISSET(i32 %233, i32* %9)
%235 = icmp eq i64 %234, 0
br i1 %235, label %252, label %236
236: ; preds = %230
%237 = call i32 @read(i32 %233, i8* %13, i32 1024)
%238 = icmp eq i32 %237, 0
br i1 %238, label %239, label %247
239: ; preds = %236
%240 = call i32 @getpeername(i32 %233, %struct.sockaddr* %40, i32* %4)
%241 = load i32, i32* %37
%242 = call i8* @inet_ntoa(i32 %241)
%243 = load i32, i32* %39
%244 = call i32 @ntohs(i32 %243)
%245 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i8* %242, i32 %244)
%246 = call i32 @close(i32 %233)
store i32 0, i32* %232
br label %252
247: ; preds = %236
%248 = sext i32 %237 to i64
%249 = getelementptr inbounds [1025 x i8], [1025 x i8]* %8, i64 0, i64 %248
store i8 0, i8* %249
%250 = call i64 @strlen(i8* %13)
%251 = call i64 @send(i32 %233, i8* %13, i64 %250, i32 0)
br label %252
252: ; preds = %230, %247, %239
%253 = add nuw nsw i64 %231, 1
%254 = icmp eq i64 %253, 30
br i1 %254, label %87, label %230
}