#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*/ serverAddr;
typedef int /*<<< orphan*/ option;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ EINTR;
int EXIT_SUCCESS;
int /*<<< orphan*/ FD_CLR(int, int /*<<< orphan*/ *);
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SETSIZE;
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*/ error(char *);
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*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int read(int, char *, int);
int select(int /*<<< orphan*/, 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 chatServer(void) {
  int option = 1;
  int serverSocket;
  int addrlen;
  int currentSocket;
  int clientId[30] = {0};
  int activity;
  int index;
  int portnum = 12543;
  int valread;
  int clientFd;
  int tempFd;
  struct sockaddr_in serverAddr;
  char buffer[1024];
  fd_set fds;
  char *greetingMessage = "Welcome to SimpleChat v1.0 \r\n";
  if ((serverSocket = socket(AF_INET, SOCK_STREAM, 0)) == 0) {
    error("ERROR: socket() failed");
  }
  if (setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, (char *)&option,
                 sizeof(option)) < 0) {
    error("ERROR: setsocketopt() failed");
  }
  serverAddr.sin_family = AF_INET;
  serverAddr.sin_addr.s_addr = INADDR_ANY;
  serverAddr.sin_port = htons(portnum);
  if (bind(serverSocket, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) <
      0) {
    error("ERROR: bind() failed");
  }
  if (listen(serverSocket, 3) < 0) {
    error("ERROR: listen() failed");
  }
  addrlen = sizeof(serverAddr);
  puts("Waiting for connections...");
  for (;;) {
    FD_ZERO(&fds);
    FD_SET(serverSocket, &fds);
    for (index = 0; index < 30; index++) {
      clientFd = clientId[index];
      if (clientFd > 0) {
        FD_SET(clientFd, &fds);
      }
    }
    activity = select(FD_SETSIZE, &fds, NULL, NULL, NULL);
    if ((activity < 0) && (errno != EINTR)) {
      printf("WARN: select() error");
    }
    if (FD_ISSET(serverSocket, &fds)) {
      if ((currentSocket = accept(serverSocket, (struct sockaddr *)&serverAddr,
                                  (socklen_t *)&addrlen)) < 0) {
        error("ERROR: accept() failed");
      }
      printf("New connection , socket fd is %d , ip is : %s , port : %d \n",
             currentSocket, inet_ntoa(serverAddr.sin_addr),
             ntohs(serverAddr.sin_port));
      if (send(currentSocket, greetingMessage, strlen(greetingMessage), 0) !=
          strlen(greetingMessage)) {
        error("ERROR: send() failed");
      }
      puts("INFO: Client joined successfully");
      for (index = 0; index < 30; index++) {
        clientFd = clientId[index];
        if (clientFd == 0) {
          clientId[index] = currentSocket;
          printf("Adding new client to the sockets list as %d\n", index);
          index = 30;
        }
      }
    }
    for (index = 0; index < 30; index++) {
      clientFd = clientId[index];
      if (FD_ISSET(clientFd, &fds)) {
        if ((valread = read(clientFd, buffer, 1024)) == 0) {
          getpeername(clientFd, (struct sockaddr *)&serverAddr,
                      (socklen_t *)&addrlen);
          printf("Host disconnected , ip %s , port %d \n",
                 inet_ntoa(serverAddr.sin_addr), ntohs(serverAddr.sin_port));
          close(clientFd);
          clientId[index] = 0;
          FD_CLR(clientFd, &fds);
        } else {
          buffer[valread] = '\0';
          for (index = 0; index < 30; index++) {
            tempFd = clientId[index];
            if (0 != tempFd && tempFd != clientFd) {
              send(tempFd, buffer, strlen(buffer), 0);
            }
          }
        }
      }
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<chatServer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x510,%rsp
movl   $0x1,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x78,%edx
call   10c0 <memset@plt>
movl   $0x30ff,-0x9c(%rbp)
lea    0xd6a(%rip),%rax
mov    %rax,-0x4d0(%rbp)
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
mov    0x2d1b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1180 <socket@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    12ce <chatServer+0x6e>
lea    0xd55(%rip),%rdi
call   1140 <error@plt>
mov    -0x8(%rbp),%edi
mov    0x2d10(%rip),%rax
mov    (%rax),%esi
mov    0x2cc7(%rip),%rax
mov    (%rax),%edx
lea    -0x4(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    1308 <chatServer+0xa8>
lea    0xd32(%rip),%rdi
call   1140 <error@plt>
mov    0x2cd1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb0(%rbp)
mov    0x2cba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb4(%rbp)
mov    -0x9c(%rbp),%edi
call   1090 <htons@plt>
mov    %eax,-0xb8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xb8(%rbp),%rsi
mov    $0xc,%edx
call   1130 <bind@plt>
cmp    $0x0,%rax
jge    1361 <chatServer+0x101>
lea    0xcf6(%rip),%rdi
call   1140 <error@plt>
mov    -0x8(%rbp),%edi
mov    $0x3,%esi
call   1110 <listen@plt>
cmp    $0x0,%rax
jge    1384 <chatServer+0x124>
lea    0xce8(%rip),%rdi
call   1140 <error@plt>
movl   $0xc,-0xc(%rbp)
lea    0xcec(%rip),%rdi
call   1030 <puts@plt>
lea    -0x4c4(%rbp),%rdi
call   10f0 <FD_ZERO@plt>
mov    -0x8(%rbp),%edi
lea    -0x4c4(%rbp),%rsi
call   1170 <FD_SET@plt>
movl   $0x0,-0x98(%rbp)
cmpl   $0x1e,-0x98(%rbp)
jge    1415 <chatServer+0x1b5>
movslq -0x98(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%eax
mov    %eax,-0xa4(%rbp)
cmpl   $0x0,-0xa4(%rbp)
jle    13fc <chatServer+0x19c>
mov    -0xa4(%rbp),%edi
lea    -0x4c4(%rbp),%rsi
call   1170 <FD_SET@plt>
jmp    1401 <chatServer+0x1a1>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    13bc <chatServer+0x15c>
mov    0x2ba4(%rip),%rax
mov    (%rax),%edi
lea    -0x4c4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   1100 <select@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x0,-0x94(%rbp)
jge    1470 <chatServer+0x210>
mov    0x2b69(%rip),%rax
mov    (%rax),%rax
mov    0x2b57(%rip),%rcx
cmp    (%rcx),%rax
je     1470 <chatServer+0x210>
lea    0xc30(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0x4c4(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     15f4 <chatServer+0x394>
mov    -0x8(%rbp),%edi
lea    -0xb8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1150 <accept@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    14b4 <chatServer+0x254>
lea    0xbff(%rip),%rdi
call   1140 <error@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4f4(%rbp)
mov    -0xb4(%rbp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,-0x4f0(%rbp)
mov    -0xb8(%rbp),%edi
call   1120 <ntohs@plt>
mov    -0x4f4(%rbp),%esi
mov    -0x4f0(%rbp),%rdx
mov    %eax,%ecx
lea    0xbd5(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4e4(%rbp)
mov    -0x4d0(%rbp),%rax
mov    %rax,-0x4e0(%rbp)
mov    -0x4d0(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x4e4(%rbp),%edi
mov    -0x4e0(%rbp),%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   10a0 <send@plt>
mov    %rax,-0x4d8(%rbp)
mov    -0x4d0(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,%rcx
mov    -0x4d8(%rbp),%rax
cmp    %rcx,%rax
je     1563 <chatServer+0x303>
lea    0xba3(%rip),%rdi
call   1140 <error@plt>
lea    0xbac(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x98(%rbp)
cmpl   $0x1e,-0x98(%rbp)
jge    15ef <chatServer+0x38f>
movslq -0x98(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%eax
mov    %eax,-0xa4(%rbp)
cmpl   $0x0,-0xa4(%rbp)
jne    15d6 <chatServer+0x376>
mov    -0x10(%rbp),%ecx
movslq -0x98(%rbp),%rax
mov    %ecx,-0x90(%rbp,%rax,4)
mov    -0x98(%rbp),%esi
lea    0xb72(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
movl   $0x1e,-0x98(%rbp)
jmp    15db <chatServer+0x37b>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    1579 <chatServer+0x319>
jmp    15f4 <chatServer+0x394>
movl   $0x0,-0x98(%rbp)
cmpl   $0x1e,-0x98(%rbp)
jge    17b2 <chatServer+0x552>
movslq -0x98(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%eax
mov    %eax,-0xa4(%rbp)
mov    -0xa4(%rbp),%edi
lea    -0x4c4(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1799 <chatServer+0x539>
mov    -0xa4(%rbp),%edi
lea    -0x4c0(%rbp),%rsi
mov    $0x400,%edx
call   10e0 <read@plt>
mov    %eax,-0xa0(%rbp)
cmp    $0x0,%eax
jne    16df <chatServer+0x47f>
mov    -0xa4(%rbp),%edi
lea    -0xb8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1070 <getpeername@plt>
mov    -0xb4(%rbp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,-0x500(%rbp)
mov    -0xb8(%rbp),%edi
call   1120 <ntohs@plt>
mov    -0x500(%rbp),%rsi
mov    %eax,%edx
lea    0xac0(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0xa4(%rbp),%edi
call   10d0 <close@plt>
movslq -0x98(%rbp),%rax
movl   $0x0,-0x90(%rbp,%rax,4)
mov    -0xa4(%rbp),%edi
lea    -0x4c4(%rbp),%rsi
call   1160 <FD_CLR@plt>
jmp    1794 <chatServer+0x534>
movslq -0xa0(%rbp),%rax
movb   $0x0,-0x4c0(%rbp,%rax,1)
movl   $0x0,-0x98(%rbp)
cmpl   $0x1e,-0x98(%rbp)
jge    178f <chatServer+0x52f>
movslq -0x98(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%eax
mov    %eax,-0xa8(%rbp)
xor    %eax,%eax
cmp    -0xa8(%rbp),%eax
je     1776 <chatServer+0x516>
mov    -0xa8(%rbp),%eax
cmp    -0xa4(%rbp),%eax
je     1776 <chatServer+0x516>
mov    -0xa8(%rbp),%eax
mov    %eax,-0x50c(%rbp)
lea    -0x4c0(%rbp),%rax
mov    %rax,-0x508(%rbp)
lea    -0x4c0(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x50c(%rbp),%edi
mov    -0x508(%rbp),%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   10a0 <send@plt>
jmp    177b <chatServer+0x51b>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    16f8 <chatServer+0x498>
jmp    1794 <chatServer+0x534>
jmp    1799 <chatServer+0x539>
jmp    179e <chatServer+0x53e>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    15fe <chatServer+0x39e>
jmp    1397 <chatServer+0x137>

x86 assembly (clang, -O2):
<chatServer>:
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)
mov    0x2d3b(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d1a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1170 <socket@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    12c9 <chatServer+0x79>
lea    0xd5a(%rip),%rdi
call   1130 <error@plt>
mov    0x2d18(%rip),%rax
mov    (%rax),%esi
mov    0x2ccf(%rip),%rax
mov    (%rax),%edx
lea    0x1c(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
jns    12fe <chatServer+0xae>
lea    0xd3c(%rip),%rdi
call   1130 <error@plt>
mov    (%rbx),%eax
mov    %eax,0x10(%rsp)
mov    0x2ccd(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    $0x30ff,%edi
call   1090 <htons@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
mov    $0xc,%edx
call   1120 <bind@plt>
test   %rax,%rax
jns    1341 <chatServer+0xf1>
lea    0xd16(%rip),%rdi
call   1130 <error@plt>
mov    %ebp,0x18(%rsp)
mov    %ebp,%edi
mov    $0x3,%esi
call   1100 <listen@plt>
test   %rax,%rax
jns    1362 <chatServer+0x112>
lea    0xd0a(%rip),%rdi
call   1130 <error@plt>
movl   $0xc,0x14(%rsp)
lea    0xd0d(%rip),%rdi
call   1030 <puts@plt>
lea    0x9c(%rsp),%r12
lea    0xa0(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   10e0 <FD_ZERO@plt>
mov    0x18(%rsp),%ebp
mov    %ebp,%edi
mov    %r12,%rsi
call   1160 <FD_SET@plt>
xor    %ebx,%ebx
jmp    13ba <chatServer+0x16a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x1e,%rbx
je     13d0 <chatServer+0x180>
mov    0x20(%rsp,%rbx,4),%edi
test   %edi,%edi
jle    13b0 <chatServer+0x160>
mov    %r12,%rsi
call   1160 <FD_SET@plt>
jmp    13b0 <chatServer+0x160>
nopl   0x0(%rax)
mov    0x2be9(%rip),%rax
mov    (%rax),%edi
mov    %r12,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10f0 <select@plt>
test   %eax,%eax
jns    1410 <chatServer+0x1c0>
mov    0x2bc5(%rip),%rax
mov    (%rax),%rax
mov    0x2bb3(%rip),%rcx
cmp    (%rcx),%rax
je     1410 <chatServer+0x1c0>
lea    0xc90(%rip),%rdi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    %ebp,%edi
mov    %r12,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     17c3 <chatServer+0x573>
mov    %ebp,%edi
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
call   1140 <accept@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    1447 <chatServer+0x1f7>
lea    0xc6c(%rip),%rdi
call   1130 <error@plt>
mov    0xc(%rsp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,%rbp
mov    0x8(%rsp),%edi
call   1110 <ntohs@plt>
lea    0xc62(%rip),%rdi
mov    %r14d,%esi
mov    %rbp,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   10b0 <printf@plt>
mov    $0x1d,%edx
mov    %r14d,%edi
lea    0xb7f(%rip),%rsi
xor    %ecx,%ecx
call   10a0 <send@plt>
cmp    $0x1d,%rax
je     149a <chatServer+0x24a>
lea    0xc6c(%rip),%rdi
call   1130 <error@plt>
lea    0xc75(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x20(%rsp)
je     1620 <chatServer+0x3d0>
cmpl   $0x0,0x24(%rsp)
je     1629 <chatServer+0x3d9>
cmpl   $0x0,0x28(%rsp)
je     1638 <chatServer+0x3e8>
cmpl   $0x0,0x2c(%rsp)
je     1647 <chatServer+0x3f7>
cmpl   $0x0,0x30(%rsp)
je     1656 <chatServer+0x406>
cmpl   $0x0,0x34(%rsp)
je     1665 <chatServer+0x415>
cmpl   $0x0,0x38(%rsp)
je     1674 <chatServer+0x424>
cmpl   $0x0,0x3c(%rsp)
je     1683 <chatServer+0x433>
cmpl   $0x0,0x40(%rsp)
je     1692 <chatServer+0x442>
cmpl   $0x0,0x44(%rsp)
je     16a1 <chatServer+0x451>
cmpl   $0x0,0x48(%rsp)
je     16b0 <chatServer+0x460>
cmpl   $0x0,0x4c(%rsp)
je     16bf <chatServer+0x46f>
cmpl   $0x0,0x50(%rsp)
je     16ce <chatServer+0x47e>
cmpl   $0x0,0x54(%rsp)
je     16dd <chatServer+0x48d>
cmpl   $0x0,0x58(%rsp)
je     16ec <chatServer+0x49c>
cmpl   $0x0,0x5c(%rsp)
je     16fb <chatServer+0x4ab>
cmpl   $0x0,0x60(%rsp)
je     170a <chatServer+0x4ba>
cmpl   $0x0,0x64(%rsp)
je     1719 <chatServer+0x4c9>
cmpl   $0x0,0x68(%rsp)
je     1728 <chatServer+0x4d8>
cmpl   $0x0,0x6c(%rsp)
je     1737 <chatServer+0x4e7>
cmpl   $0x0,0x70(%rsp)
je     1743 <chatServer+0x4f3>
cmpl   $0x0,0x74(%rsp)
je     174f <chatServer+0x4ff>
cmpl   $0x0,0x78(%rsp)
je     175b <chatServer+0x50b>
cmpl   $0x0,0x7c(%rsp)
je     1767 <chatServer+0x517>
cmpl   $0x0,0x80(%rsp)
je     1773 <chatServer+0x523>
cmpl   $0x0,0x84(%rsp)
je     177f <chatServer+0x52f>
cmpl   $0x0,0x88(%rsp)
je     178b <chatServer+0x53b>
cmpl   $0x0,0x8c(%rsp)
je     1797 <chatServer+0x547>
cmpl   $0x0,0x90(%rsp)
je     17a3 <chatServer+0x553>
cmpl   $0x0,0x94(%rsp)
jne    17c3 <chatServer+0x573>
mov    $0x1d,%eax
mov    $0x1d,%esi
jmp    17b0 <chatServer+0x560>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %esi,%esi
xor    %eax,%eax
jmp    17b0 <chatServer+0x560>
mov    $0x1,%eax
mov    $0x1,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x2,%eax
mov    $0x2,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x3,%eax
mov    $0x3,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x4,%eax
mov    $0x4,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x5,%eax
mov    $0x5,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x6,%eax
mov    $0x6,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x7,%eax
mov    $0x7,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x8,%eax
mov    $0x8,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x9,%eax
mov    $0x9,%esi
jmp    17b0 <chatServer+0x560>
mov    $0xa,%eax
mov    $0xa,%esi
jmp    17b0 <chatServer+0x560>
mov    $0xb,%eax
mov    $0xb,%esi
jmp    17b0 <chatServer+0x560>
mov    $0xc,%eax
mov    $0xc,%esi
jmp    17b0 <chatServer+0x560>
mov    $0xd,%eax
mov    $0xd,%esi
jmp    17b0 <chatServer+0x560>
mov    $0xe,%eax
mov    $0xe,%esi
jmp    17b0 <chatServer+0x560>
mov    $0xf,%eax
mov    $0xf,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x10,%eax
mov    $0x10,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x11,%eax
mov    $0x11,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x12,%eax
mov    $0x12,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x13,%eax
mov    $0x13,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x14,%eax
mov    $0x14,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x15,%eax
mov    $0x15,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x16,%eax
mov    $0x16,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x17,%eax
mov    $0x17,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x18,%eax
mov    $0x18,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x19,%eax
mov    $0x19,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x1a,%eax
mov    $0x1a,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x1b,%eax
mov    $0x1b,%esi
jmp    17b0 <chatServer+0x560>
mov    $0x1c,%eax
mov    $0x1c,%esi
nopl   (%rax)
mov    %r14d,0x20(%rsp,%rax,4)
lea    0x97b(%rip),%rdi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    $0xffffffff,%ebx
lea    0x20(%rsp),%r13
jmp    1832 <chatServer+0x5e2>
nop
mov    %ebp,%edi
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
call   1070 <getpeername@plt>
mov    0xc(%rsp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,%r14
mov    0x8(%rsp),%edi
call   1110 <ntohs@plt>
lea    0x967(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <printf@plt>
mov    %ebp,%edi
call   10c0 <close@plt>
movl   $0x0,0x0(%r13)
mov    %ebp,%edi
mov    %r12,%rsi
call   1150 <FD_CLR@plt>
add    $0x1,%ebx
add    $0x4,%r13
cmp    $0x1d,%ebx
jae    1390 <chatServer+0x140>
mov    0x0(%r13),%ebp
mov    %ebp,%edi
mov    %r12,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1822 <chatServer+0x5d2>
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x400,%edx
call   10d0 <read@plt>
test   %eax,%eax
je     17d0 <chatServer+0x580>
cltq
movb   $0x0,0xa0(%rsp,%rax,1)
xor    %ebx,%ebx
jmp    187e <chatServer+0x62e>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x1e,%rbx
je     1390 <chatServer+0x140>
mov    0x20(%rsp,%rbx,4),%r14d
test   %r14d,%r14d
je     1870 <chatServer+0x620>
cmp    %ebp,%r14d
je     1870 <chatServer+0x620>
mov    %r15,%rdi
call   1080 <strlen@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   10a0 <send@plt>
jmp    1870 <chatServer+0x620>

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

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