#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 ssize_t;
typedef int /*<<< orphan*/ servaddr;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ FD_CLR(int, int /*<<< orphan*/ *);
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int FD_SETSIZE;
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int listen(int, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  int listenfd, connfd, sockfd, maxfd, maxi, i;
  int ready;
  int client[128];
  int len;
  ssize_t n;
  fd_set rset, allset;
  char buffer[1024];
  struct sockaddr_in servaddr;
  printf("Start server\n");
  if ((listenfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
    printf("Create socket failed, errno: %d\n", errno);
    exit(EXIT_FAILURE);
  }
  printf("listen fd is %d\n", listenfd);
  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = AF_UNIX;
  servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
  servaddr.sin_port = htons(29876);
  if (bind(listenfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) == -1) {
    printf("Bind failed, errno: %d\n", errno);
    exit(EXIT_FAILURE);
  }
  if (listen(listenfd, 100) == -1) {
    printf("Listen failed, errno: %d\n", errno);
    exit(EXIT_FAILURE);
  }
  maxfd = listenfd;
  maxi = -1;
  for (i = 0; i < 128; i++)
    client[i] = -1;
  FD_ZERO(&allset);
  FD_SET(listenfd, &allset);
  while (1) {
    rset = allset;
    if ((ready = select(maxfd + 1, &rset, NULL, NULL, NULL)) == -1) {
      printf("Listen failed, errno: %d\n", errno);
      exit(EXIT_FAILURE);
    }
    if (ready <= 0)
      continue;
    if (FD_ISSET(listenfd, &rset)) {
      printf("Start accpet ... \n");
      if ((connfd == accept(listenfd, NULL, 0)) == -1) {
        printf("Accept Error: %d\n", errno);
        continue;
      }
      printf("Accept fd: %d\n", connfd);
      for (i = 0; i < 128; i++) {
        if (client[i] < 0) {
          client[i] = connfd;
          break;
        }
      }
      printf("Save fd in postion %d in client array\n", i);
      if (connfd > FD_SETSIZE) {
        printf("connfd is %d, larger that FD_SETSIZE %d\n", connfd, FD_SETSIZE);
      }
      if (i == 128) {
        printf("Too many ...\n");
        close(connfd);
        continue;
      }
      FD_SET(connfd, &allset);
      if (connfd > maxfd)
        maxfd = connfd;
      if (i > maxi)
        maxi = i;
    }
    printf("maxi: %d\n", maxi);
    for (i = 0; i <= maxi; i++) {
      if ((sockfd = client[i]) <= 0)
        continue;
      printf("locate fd in postion %d in client array, sockfd is %d\n", i,
             client[i]);
      if (FD_ISSET(client[i], &rset) == 0)
        continue;
      printf("valid fd in postion %d in client array, sockfd is %d\n", i,
             client[i]);
      sockfd = client[i];
      memset(buffer, 0, sizeof(buffer));
      n = read(sockfd, buffer, 1024);
      printf("socket recv n: %d\n", n);
      if (n < 0) {
        printf("Read socket %d error!\n", sockfd);
        close(sockfd);
        FD_CLR(sockfd, &allset);
        client[i] = 1;
        continue;
      }
      if (n == 0) {
        printf("Read socket %d end now.\n", sockfd);
        close(sockfd);
        FD_CLR(sockfd, &allset);
        client[i] = 1;
        continue;
      }
      printf("locate fd in postion %d in client array, sockfd is %d\n", i,
             client[i]);
      sockfd = client[i];
      memset(buffer, 0, sizeof(buffer));
      n = read(sockfd, buffer, 1024);
      printf("socket recv n: %d\n", n);
      if (n < 0) {
        printf("Read socket %d error!\n", sockfd);
        close(sockfd);
        FD_CLR(sockfd, &allset);
        client[i] = 1;
        continue;
      }
      if (n == 0) {
        printf("Read socket %d end now.\n", sockfd);
        close(sockfd);
        FD_CLR(sockfd, &allset);
        client[i] = 1;
        continue;
      }
      printf("Server recv len: %d, string: %s\n", n, buffer);
      if (strcmp(buffer, "q") == 0) {
        close(sockfd);
        FD_CLR(sockfd, &allset);
        client[i] = 1;
        continue;
      }
      printf("Server send: %s\n", buffer);
      write(sockfd, buffer, n);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x660,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
mov    0x2d69(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    12a1 <main+0x71>
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    -0x14(%rbp),%esi
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x650(%rbp),%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    0x2d1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x648(%rbp)
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x64c(%rbp)
mov    $0x74b4,%edi
call   1050 <htons@plt>
mov    %eax,-0x650(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x650(%rbp),%rsi
mov    $0xc,%edx
call   10f0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1338 <main+0x108>
mov    0x2ca6(%rip),%rax
mov    (%rax),%esi
lea    0xd1d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2c87(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x64,%esi
call   10e0 <listen@plt>
cmp    $0xffffffff,%eax
jne    1373 <main+0x143>
mov    0x2c6b(%rip),%rax
mov    (%rax),%esi
lea    0xcfa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2c4c(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x80,-0x28(%rbp)
jge    13b1 <main+0x181>
movslq -0x28(%rbp),%rax
movl   $0xffffffff,-0x230(%rbp,%rax,4)
ff ff ff ff
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1387 <main+0x157>
lea    -0x240(%rbp),%rdi
call   10c0 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x240(%rbp),%rsi
call   1140 <FD_SET@plt>
mov    -0x240(%rbp),%eax
mov    %eax,-0x23c(%rbp)
mov    -0x20(%rbp),%edi
add    $0x1,%edi
lea    -0x23c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10d0 <select@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
jne    1426 <main+0x1f6>
mov    0x2bb8(%rip),%rax
mov    (%rax),%esi
lea    0xc47(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2b99(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
cmpl   $0x0,-0x2c(%rbp)
jg     1435 <main+0x205>
jmp    13cc <main+0x19c>
mov    -0x14(%rbp),%edi
lea    -0x23c(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     15a4 <main+0x374>
lea    0xc1d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x654(%rbp)
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1110 <accept@plt>
mov    %eax,%ecx
mov    -0x654(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0xffffffff,%eax
jne    14aa <main+0x27a>
mov    0x2b2b(%rip),%rax
mov    (%rax),%esi
lea    0xbe7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13cc <main+0x19c>
mov    -0x18(%rbp),%esi
lea    0xbe3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x80,-0x28(%rbp)
jge    1507 <main+0x2d7>
movslq -0x28(%rbp),%rax
cmpl   $0x0,-0x230(%rbp,%rax,4)
jge    14f4 <main+0x2c4>
mov    -0x18(%rbp),%ecx
movslq -0x28(%rbp),%rax
mov    %ecx,-0x230(%rbp,%rax,4)
jmp    1507 <main+0x2d7>
jmp    14f9 <main+0x2c9>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    14c2 <main+0x292>
mov    -0x28(%rbp),%esi
lea    0xb95(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%eax
mov    0x2aa6(%rip),%rcx
cmp    (%rcx),%eax
jle    1544 <main+0x314>
mov    -0x18(%rbp),%esi
mov    0x2a94(%rip),%rax
mov    (%rax),%edx
lea    0xb90(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x80,-0x28(%rbp)
jne    156c <main+0x33c>
lea    0xb9e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
jmp    13cc <main+0x19c>
mov    -0x18(%rbp),%edi
lea    -0x240(%rbp),%rsi
call   1140 <FD_SET@plt>
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    158d <main+0x35d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    159f <main+0x36f>
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    15a4 <main+0x374>
mov    -0x24(%rbp),%esi
lea    0xb56(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     18bb <main+0x68b>
movslq -0x28(%rbp),%rax
mov    -0x230(%rbp,%rax,4),%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jg     15e4 <main+0x3b4>
jmp    18ad <main+0x67d>
mov    -0x28(%rbp),%esi
movslq -0x28(%rbp),%rax
mov    -0x230(%rbp,%rax,4),%edx
lea    0xb15(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x28(%rbp),%rax
mov    -0x230(%rbp,%rax,4),%edi
lea    -0x23c(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
jne    1626 <main+0x3f6>
jmp    18ad <main+0x67d>
mov    -0x28(%rbp),%esi
movslq -0x28(%rbp),%rax
mov    -0x230(%rbp,%rax,4),%edx
lea    0xb0a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x28(%rbp),%rax
mov    -0x230(%rbp,%rax,4),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x640(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    -0x1c(%rbp),%edi
lea    -0x640(%rbp),%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
mov    %eax,-0x238(%rbp)
mov    -0x238(%rbp),%esi
lea    0xaf1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x238(%rbp)
jge    16da <main+0x4aa>
mov    -0x1c(%rbp),%esi
lea    0xae6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0x1c(%rbp),%edi
lea    -0x240(%rbp),%rsi
call   1120 <FD_CLR@plt>
movslq -0x28(%rbp),%rax
movl   $0x1,-0x230(%rbp,%rax,4)
jmp    18ad <main+0x67d>
cmpl   $0x0,-0x238(%rbp)
jne    1723 <main+0x4f3>
mov    -0x1c(%rbp),%esi
lea    0xab4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0x1c(%rbp),%edi
lea    -0x240(%rbp),%rsi
call   1120 <FD_CLR@plt>
movslq -0x28(%rbp),%rax
movl   $0x1,-0x230(%rbp,%rax,4)
jmp    18ad <main+0x67d>
mov    -0x28(%rbp),%esi
movslq -0x28(%rbp),%rax
mov    -0x230(%rbp,%rax,4),%edx
lea    0x9d6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x28(%rbp),%rax
mov    -0x230(%rbp,%rax,4),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x640(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    -0x1c(%rbp),%edi
lea    -0x640(%rbp),%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
mov    %eax,-0x238(%rbp)
mov    -0x238(%rbp),%esi
lea    0x9f4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x238(%rbp)
jge    17d7 <main+0x5a7>
mov    -0x1c(%rbp),%esi
lea    0x9e9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0x1c(%rbp),%edi
lea    -0x240(%rbp),%rsi
call   1120 <FD_CLR@plt>
movslq -0x28(%rbp),%rax
movl   $0x1,-0x230(%rbp,%rax,4)
jmp    18ad <main+0x67d>
cmpl   $0x0,-0x238(%rbp)
jne    1820 <main+0x5f0>
mov    -0x1c(%rbp),%esi
lea    0x9b7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0x1c(%rbp),%edi
lea    -0x240(%rbp),%rsi
call   1120 <FD_CLR@plt>
movslq -0x28(%rbp),%rax
movl   $0x1,-0x230(%rbp,%rax,4)
jmp    18ad <main+0x67d>
mov    -0x238(%rbp),%esi
lea    -0x640(%rbp),%rdx
lea    0x98a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x640(%rbp),%rdi
lea    0x996(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1883 <main+0x653>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0x1c(%rbp),%edi
lea    -0x240(%rbp),%rsi
call   1120 <FD_CLR@plt>
movslq -0x28(%rbp),%rax
movl   $0x1,-0x230(%rbp,%rax,4)
jmp    18ad <main+0x67d>
lea    -0x640(%rbp),%rsi
lea    0x950(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%edi
lea    -0x640(%rbp),%rsi
mov    -0x238(%rbp),%edx
call   1030 <write@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    15bc <main+0x38c>
jmp    13cc <main+0x19c>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x628,%rsp
lea    0xf30(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d84(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d62(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
cmp    $0xffffffff,%eax
jne    1291 <main+0x51>
mov    0x2d45(%rip),%rax
mov    (%rax),%esi
lea    0xd74(%rip),%rdi
jmp    1377 <main+0x137>
mov    %eax,%r15d
lea    0xd86(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   1110 <bzero@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x18(%rsp)
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0x14(%rsp)
mov    $0x74b4,%edi
call   1060 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1100 <bind@plt>
cmp    $0xffffffff,%eax
jne    1304 <main+0xc4>
mov    0x2ccf(%rip),%rax
mov    (%rax),%esi
lea    0xd30(%rip),%rdi
jmp    1377 <main+0x137>
mov    %r15d,%edi
mov    $0x64,%esi
call   10f0 <listen@plt>
cmp    $0xffffffff,%eax
je     1367 <main+0x127>
lea    0x20(%rsp),%rdi
mov    $0x200,%edx
mov    $0xff,%esi
call   1090 <memset@plt>
mov    %rsp,%rbp
mov    %rbp,%rdi
call   10d0 <FD_ZERO@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
call   1150 <FD_SET@plt>
mov    %r15d,%edi
add    $0x1,%edi
mov    (%rsp),%eax
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    %edi,0x8(%rsp)
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <select@plt>
cmp    $0xffffffff,%eax
jne    138c <main+0x14c>
mov    0x2c5a(%rip),%rax
mov    (%rax),%esi
lea    0xcd3(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    $0xffffffff,%ebx
lea    0x220(%rsp),%r14
mov    %r15d,0xc(%rsp)
jmp    13c6 <main+0x186>
mov    (%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rsp),%edi
lea    0x4(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <select@plt>
cmp    $0xffffffff,%eax
mov    0xc(%rsp),%r15d
je     1367 <main+0x127>
test   %eax,%eax
jle    1461 <main+0x221>
mov    %r15d,%edi
lea    0x4(%rsp),%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     14b8 <main+0x278>
lea    0xdaa(%rip),%rdi
call   1030 <puts@plt>
mov    %r15d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1120 <accept@plt>
lea    0xc61(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %ebp,%ebp
nopl   0x0(%rax)
cmpl   $0x0,0x20(%rsp,%rbp,4)
js     149b <main+0x25b>
cmpl   $0x0,0x24(%rsp,%rbp,4)
js     148b <main+0x24b>
cmpl   $0x0,0x28(%rsp,%rbp,4)
js     1491 <main+0x251>
cmpl   $0x0,0x2c(%rsp,%rbp,4)
js     1497 <main+0x257>
add    $0x4,%rbp
cmp    $0x80,%rbp
jne    1410 <main+0x1d0>
lea    0xc2f(%rip),%rdi
mov    $0x80,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd50(%rip),%rdi
call   1030 <puts@plt>
call   10a0 <close@plt>
mov    (%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rsp),%edi
lea    0x4(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <select@plt>
cmp    $0xffffffff,%eax
jne    13c6 <main+0x186>
jmp    1367 <main+0x127>
add    $0x1,%rbp
jmp    149b <main+0x25b>
add    $0x2,%rbp
jmp    149b <main+0x25b>
add    $0x3,%rbp
lea    0xbd1(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,%rsi
call   1150 <FD_SET@plt>
cmp    %ebp,%ebx
cmovl  %ebp,%ebx
lea    0xbdb(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
test   %ebx,%ebx
js     13a0 <main+0x160>
lea    0x1(%rbx),%r15d
xor    %r12d,%r12d
jmp    151a <main+0x2da>
nopl   0x0(%rax)
lea    0xc3d(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13d,%edi
call   10a0 <close@plt>
mov    %r13d,%edi
mov    %rsp,%rsi
call   1130 <FD_CLR@plt>
movl   $0x1,0x20(%rsp,%r12,4)
add    $0x1,%r12
cmp    %r12,%r15
je     13a0 <main+0x160>
mov    0x20(%rsp,%r12,4),%r13d
test   %r13d,%r13d
jle    150d <main+0x2cd>
lea    0xb79(%rip),%rdi
mov    %r12d,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13d,%edi
lea    0x4(%rsp),%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     150d <main+0x2cd>
lea    0xb8a(%rip),%rdi
mov    %r12d,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   10b0 <read@plt>
mov    %eax,%ebp
lea    0xb8b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
test   %ebp,%ebp
js     14e0 <main+0x2a0>
je     163a <main+0x3fa>
lea    0xb00(%rip),%rdi
mov    %r12d,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   10b0 <read@plt>
mov    %eax,%ebp
lea    0xb38(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
test   %ebp,%ebp
js     14e0 <main+0x2a0>
je     163a <main+0x3fa>
lea    0xb61(%rip),%rdi
mov    %ebp,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
lea    0xb6c(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     14f1 <main+0x2b1>
lea    0xb59(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13d,%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <write@plt>
jmp    150d <main+0x2cd>
lea    0xafa(%rip),%rdi
jmp    14e7 <main+0x2a7>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [14 x i8] c"Start server\0A\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [33 x i8] c"Create socket failed, errno: %d\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [17 x i8] c"listen fd is %d\0A\00"
@INADDR_ANY = global i32 0
@.str.3 = [24 x i8] c"Bind failed, errno: %d\0A\00"
@.str.4 = [26 x i8] c"Listen failed, errno: %d\0A\00"
@.str.5 = [19 x i8] c"Start accpet ... \0A\00"
@.str.6 = [18 x i8] c"Accept Error: %d\0A\00"
@.str.7 = [15 x i8] c"Accept fd: %d\0A\00"
@.str.8 = [39 x i8] c"Save fd in postion %d in client array\0A\00"
@FD_SETSIZE = global i32 0
@.str.9 = [41 x i8] c"connfd is %d, larger that FD_SETSIZE %d\0A\00"
@.str.10 = [14 x i8] c"Too many ...\0A\00"
@.str.11 = [10 x i8] c"maxi: %d\0A\00"
@.str.12 = [55 x i8] c"locate fd in postion %d in client array, sockfd is %d\0A\00"
@.str.13 = [54 x i8] c"valid fd in postion %d in client array, sockfd is %d\0A\00"
@.str.14 = [19 x i8] c"socket recv n: %d\0A\00"
@.str.15 = [23 x i8] c"Read socket %d error!\0A\00"
@.str.16 = [25 x i8] c"Read socket %d end now.\0A\00"
@.str.17 = [33 x i8] c"Server recv len: %d, string: %s\0A\00"
@.str.18 = [2 x i8] c"q\00"
@.str.19 = [17 x i8] c"Server send: %s\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 i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [128 x i32]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [1024 x i8]
%19 = alloca %struct.sockaddr_in
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* @AF_UNIX
%22 = load i32, i32* @SOCK_STREAM
%23 = call i32 @socket(i32 %21, i32 %22, i32 0)
store i32 %23, i32* %6
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %30
25: ; preds = %2
%26 = load i32, i32* @errno
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %2
%31 = load i32, i32* %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = call i32 @bzero(%struct.sockaddr_in* %19, i32 12)
%34 = load i32, i32* @AF_UNIX
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %19, i32 0, i32 2
store i32 %34, i32* %35
%36 = load i32, i32* @INADDR_ANY
%37 = call i32 @htonl(i32 %36)
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %19, i32 0, i32 1
%39 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %38, i32 0, i32 0
store i32 %37, i32* %39
%40 = call i32 @htons(i32 29876)
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %19, i32 0, i32 0
store i32 %40, i32* %41
%42 = load i32, i32* %6
%43 = bitcast %struct.sockaddr_in* %19 to %struct.sockaddr*
%44 = call i32 @bind(i32 %42, %struct.sockaddr* %43, i32 12)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %51
46: ; preds = %30
%47 = load i32, i32* @errno
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %47)
%49 = load i32, i32* @EXIT_FAILURE
%50 = call i32 @exit(i32 %49)
unreachable
51: ; preds = %30
%52 = load i32, i32* %6
%53 = call i32 @listen(i32 %52, i32 100)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %60
55: ; preds = %51
%56 = load i32, i32* @errno
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %56)
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %51
%61 = load i32, i32* %6
store i32 %61, i32* %9
store i32 -1, i32* %10
store i32 0, i32* %11
br label %62
62: ; preds = %69, %60
%63 = load i32, i32* %11
%64 = icmp slt i32 %63, 128
br i1 %64, label %65, label %72
65: ; preds = %62
%66 = load i32, i32* %11
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %67
store i32 -1, i32* %68
br label %69
69: ; preds = %65
%70 = load i32, i32* %11
%71 = add nsw i32 %70, 1
store i32 %71, i32* %11
br label %62
72: ; preds = %62
%73 = call i32 @FD_ZERO(i32* %17)
%74 = load i32, i32* %6
%75 = call i32 @FD_SET(i32 %74, i32* %17)
br label %76
76: ; preds = %72, %90, %103, %140, %298
%77 = load i32, i32* %17
store i32 %77, i32* %16
%78 = load i32, i32* %9
%79 = add nsw i32 %78, 1
%80 = call i32 @select(i32 %79, i32* %16, i32* null, i32* null, i32* null)
store i32 %80, i32* %12
%81 = icmp eq i32 %80, -1
br i1 %81, label %82, label %87
82: ; preds = %76
%83 = load i32, i32* @errno
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %83)
%85 = load i32, i32* @EXIT_FAILURE
%86 = call i32 @exit(i32 %85)
unreachable
87: ; preds = %76
%88 = load i32, i32* %12
%89 = icmp sle i32 %88, 0
br i1 %89, label %90, label %91
90: ; preds = %87
br label %76
91: ; preds = %87
%92 = load i32, i32* %6
%93 = call i64 @FD_ISSET(i32 %92, i32* %16)
%94 = icmp ne i64 %93, 0
br i1 %94, label %95, label %159
95: ; preds = %91
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%97 = load i32, i32* %7
%98 = load i32, i32* %6
%99 = call i32 @accept(i32 %98, i32* null, i32 0)
%100 = icmp eq i32 %97, %99
%101 = zext i1 %100 to i32
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %106
103: ; preds = %95
%104 = load i32, i32* @errno
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %104)
br label %76
106: ; preds = %95
%107 = load i32, i32* %7
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %107)
store i32 0, i32* %11
br label %109
109: ; preds = %124, %106
%110 = load i32, i32* %11
%111 = icmp slt i32 %110, 128
br i1 %111, label %112, label %127
112: ; preds = %109
%113 = load i32, i32* %11
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %114
%116 = load i32, i32* %115
%117 = icmp slt i32 %116, 0
br i1 %117, label %118, label %123
118: ; preds = %112
%119 = load i32, i32* %7
%120 = load i32, i32* %11
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %121
store i32 %119, i32* %122
br label %127
123: ; preds = %112
br label %124
124: ; preds = %123
%125 = load i32, i32* %11
%126 = add nsw i32 %125, 1
store i32 %126, i32* %11
br label %109
127: ; preds = %118, %109
%128 = load i32, i32* %11
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i32 %128)
%130 = load i32, i32* %7
%131 = load i32, i32* @FD_SETSIZE
%132 = icmp sgt i32 %130, %131
br i1 %132, label %133, label %137
133: ; preds = %127
%134 = load i32, i32* %7
%135 = load i32, i32* @FD_SETSIZE
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i32 %134, i32 %135)
br label %137
137: ; preds = %133, %127
%138 = load i32, i32* %11
%139 = icmp eq i32 %138, 128
br i1 %139, label %140, label %144
140: ; preds = %137
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%142 = load i32, i32* %7
%143 = call i32 @close(i32 %142)
br label %76
144: ; preds = %137
%145 = load i32, i32* %7
%146 = call i32 @FD_SET(i32 %145, i32* %17)
%147 = load i32, i32* %7
%148 = load i32, i32* %9
%149 = icmp sgt i32 %147, %148
br i1 %149, label %150, label %152
150: ; preds = %144
%151 = load i32, i32* %7
store i32 %151, i32* %9
br label %152
152: ; preds = %150, %144
%153 = load i32, i32* %11
%154 = load i32, i32* %10
%155 = icmp sgt i32 %153, %154
br i1 %155, label %156, label %158
156: ; preds = %152
%157 = load i32, i32* %11
store i32 %157, i32* %10
br label %158
158: ; preds = %156, %152
br label %159
159: ; preds = %158, %91
%160 = load i32, i32* %10
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 %160)
store i32 0, i32* %11
br label %162
162: ; preds = %295, %159
%163 = load i32, i32* %11
%164 = load i32, i32* %10
%165 = icmp sle i32 %163, %164
br i1 %165, label %166, label %298
166: ; preds = %162
%167 = load i32, i32* %11
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %168
%170 = load i32, i32* %169
store i32 %170, i32* %8
%171 = icmp sle i32 %170, 0
br i1 %171, label %172, label %173
172: ; preds = %166
br label %295
173: ; preds = %166
%174 = load i32, i32* %11
%175 = load i32, i32* %11
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %176
%178 = load i32, i32* %177
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.12, i64 0, i64 0), i32 %174, i32 %178)
%180 = load i32, i32* %11
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %181
%183 = load i32, i32* %182
%184 = call i64 @FD_ISSET(i32 %183, i32* %16)
%185 = icmp eq i64 %184, 0
br i1 %185, label %186, label %187
186: ; preds = %173
br label %295
187: ; preds = %173
%188 = load i32, i32* %11
%189 = load i32, i32* %11
%190 = sext i32 %189 to i64
%191 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %190
%192 = load i32, i32* %191
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.13, i64 0, i64 0), i32 %188, i32 %192)
%194 = load i32, i32* %11
%195 = sext i32 %194 to i64
%196 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %195
%197 = load i32, i32* %196
store i32 %197, i32* %8
%198 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%199 = call i32 @memset(i8* %198, i32 0, i32 1024)
%200 = load i32, i32* %8
%201 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%202 = call i32 @read(i32 %200, i8* %201, i32 1024)
store i32 %202, i32* %15
%203 = load i32, i32* %15
%204 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i32 %203)
%205 = load i32, i32* %15
%206 = icmp slt i32 %205, 0
br i1 %206, label %207, label %217
207: ; preds = %187
%208 = load i32, i32* %8
%209 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i32 %208)
%210 = load i32, i32* %8
%211 = call i32 @close(i32 %210)
%212 = load i32, i32* %8
%213 = call i32 @FD_CLR(i32 %212, i32* %17)
%214 = load i32, i32* %11
%215 = sext i32 %214 to i64
%216 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %215
store i32 1, i32* %216
br label %295
217: ; preds = %187
%218 = load i32, i32* %15
%219 = icmp eq i32 %218, 0
br i1 %219, label %220, label %230
220: ; preds = %217
%221 = load i32, i32* %8
%222 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.16, i64 0, i64 0), i32 %221)
%223 = load i32, i32* %8
%224 = call i32 @close(i32 %223)
%225 = load i32, i32* %8
%226 = call i32 @FD_CLR(i32 %225, i32* %17)
%227 = load i32, i32* %11
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %228
store i32 1, i32* %229
br label %295
230: ; preds = %217
%231 = load i32, i32* %11
%232 = load i32, i32* %11
%233 = sext i32 %232 to i64
%234 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %233
%235 = load i32, i32* %234
%236 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.12, i64 0, i64 0), i32 %231, i32 %235)
%237 = load i32, i32* %11
%238 = sext i32 %237 to i64
%239 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %238
%240 = load i32, i32* %239
store i32 %240, i32* %8
%241 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%242 = call i32 @memset(i8* %241, i32 0, i32 1024)
%243 = load i32, i32* %8
%244 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%245 = call i32 @read(i32 %243, i8* %244, i32 1024)
store i32 %245, i32* %15
%246 = load i32, i32* %15
%247 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i32 %246)
%248 = load i32, i32* %15
%249 = icmp slt i32 %248, 0
br i1 %249, label %250, label %260
250: ; preds = %230
%251 = load i32, i32* %8
%252 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i32 %251)
%253 = load i32, i32* %8
%254 = call i32 @close(i32 %253)
%255 = load i32, i32* %8
%256 = call i32 @FD_CLR(i32 %255, i32* %17)
%257 = load i32, i32* %11
%258 = sext i32 %257 to i64
%259 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %258
store i32 1, i32* %259
br label %295
260: ; preds = %230
%261 = load i32, i32* %15
%262 = icmp eq i32 %261, 0
br i1 %262, label %263, label %273
263: ; preds = %260
%264 = load i32, i32* %8
%265 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.16, i64 0, i64 0), i32 %264)
%266 = load i32, i32* %8
%267 = call i32 @close(i32 %266)
%268 = load i32, i32* %8
%269 = call i32 @FD_CLR(i32 %268, i32* %17)
%270 = load i32, i32* %11
%271 = sext i32 %270 to i64
%272 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %271
store i32 1, i32* %272
br label %295
273: ; preds = %260
%274 = load i32, i32* %15
%275 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%276 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.17, i64 0, i64 0), i32 %274, i8* %275)
%277 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%278 = call i64 @strcmp(i8* %277, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%279 = icmp eq i64 %278, 0
br i1 %279, label %280, label %288
280: ; preds = %273
%281 = load i32, i32* %8
%282 = call i32 @close(i32 %281)
%283 = load i32, i32* %8
%284 = call i32 @FD_CLR(i32 %283, i32* %17)
%285 = load i32, i32* %11
%286 = sext i32 %285 to i64
%287 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %286
store i32 1, i32* %287
br label %295
288: ; preds = %273
%289 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%290 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i64 0, i64 0), i8* %289)
%291 = load i32, i32* %8
%292 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%293 = load i32, i32* %15
%294 = call i32 @write(i32 %291, i8* %292, i32 %293)
br label %295
295: ; preds = %288, %280, %263, %250, %220, %207, %186, %172
%296 = load i32, i32* %11
%297 = add nsw i32 %296, 1
store i32 %297, i32* %11
br label %162
298: ; preds = %162
br label %76
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [33 x i8] c"Create socket failed, errno: %d\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [17 x i8] c"listen fd is %d\0A\00"
@INADDR_ANY = global i32 0
@.str.3 = [24 x i8] c"Bind failed, errno: %d\0A\00"
@.str.4 = [26 x i8] c"Listen failed, errno: %d\0A\00"
@.str.7 = [15 x i8] c"Accept fd: %d\0A\00"
@.str.8 = [39 x i8] c"Save fd in postion %d in client array\0A\00"
@FD_SETSIZE = global i32 0
@.str.11 = [10 x i8] c"maxi: %d\0A\00"
@.str.12 = [55 x i8] c"locate fd in postion %d in client array, sockfd is %d\0A\00"
@.str.13 = [54 x i8] c"valid fd in postion %d in client array, sockfd is %d\0A\00"
@.str.14 = [19 x i8] c"socket recv n: %d\0A\00"
@.str.15 = [23 x i8] c"Read socket %d error!\0A\00"
@.str.16 = [25 x i8] c"Read socket %d end now.\0A\00"
@.str.17 = [33 x i8] c"Server recv len: %d, string: %s\0A\00"
@.str.18 = [2 x i8] c"q\00"
@.str.19 = [17 x i8] c"Server send: %s\0A\00"
@str = [13 x i8] c"Start server\00"
@str.20 = [18 x i8] c"Start accpet ... \00"
@str.21 = [13 x i8] c"Too many ...\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i32]
%4 = bitcast [128 x i32]* %3 to i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca %struct.sockaddr_in
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%12 = bitcast %struct.sockaddr_in* %8 to i8*
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%14 = load i32, i32* @AF_UNIX
%15 = load i32, i32* @SOCK_STREAM
%16 = tail call i32 @socket(i32 %14, i32 %15, i32 0)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i32, i32* @errno
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%25 = call i32 @bzero(%struct.sockaddr_in* %8, i32 12)
%26 = load i32, i32* @AF_UNIX
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 2
store i32 %26, i32* %27
%28 = load i32, i32* @INADDR_ANY
%29 = tail call i32 @htonl(i32 %28)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 1, i32 0
store i32 %29, i32* %30
%31 = tail call i32 @htons(i32 29876)
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 0
store i32 %31, i32* %32
%33 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%34 = call i32 @bind(i32 %16, %struct.sockaddr* %33, i32 12)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %41
36: ; preds = %23
%37 = load i32, i32* @errno
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %23
%42 = call i32 @listen(i32 %16, i32 100)
%43 = icmp eq i32 %42, -1
br i1 %43, label %51, label %44
44: ; preds = %41
%45 = call i32 @FD_ZERO(i32* %6)
%46 = call i32 @FD_SET(i32 %16, i32* %6)
%47 = add nuw nsw i32 %16, 1
%48 = load i32, i32* %6
store i32 %48, i32* %5
%49 = call i32 @select(i32 %47, i32* %5, i32* null, i32* null, i32* null)
%50 = icmp eq i32 %49, -1
br i1 %50, label %63, label %60
51: ; preds = %41
%52 = load i32, i32* @errno
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %52)
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %175, %116
%57 = load i32, i32* %6
store i32 %57, i32* %5
%58 = call i32 @select(i32 %47, i32* %5, i32* null, i32* null, i32* null)
%59 = icmp eq i32 %58, -1
br i1 %59, label %63, label %60
60: ; preds = %44, %56
%61 = phi i32 [ %58, %56 ], [ %49, %44 ]
%62 = phi i32 [ %117, %56 ], [ -1, %44 ]
br label %68
63: ; preds = %56, %105, %44
%64 = load i32, i32* @errno
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %64)
%66 = load i32, i32* @EXIT_FAILURE
%67 = call i32 @exit(i32 %66)
unreachable
68: ; preds = %60, %105
%69 = phi i32 [ %61, %60 ], [ %107, %105 ]
%70 = icmp slt i32 %69, 1
br i1 %70, label %105, label %71
71: ; preds = %68
%72 = call i64 @FD_ISSET(i32 %16, i32* %5)
%73 = icmp eq i64 %72, 0
br i1 %73, label %116, label %74
74: ; preds = %71
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.20, i64 0, i64 0))
%76 = call i32 @accept(i32 %16, i32* null, i32 0)
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 undef)
br label %78
78: ; preds = %98, %74
%79 = phi i64 [ 0, %74 ], [ %99, %98 ]
%80 = getelementptr inbounds [128 x i32], [128 x i32]* %3, i64 0, i64 %79
%81 = load i32, i32* %80
%82 = icmp slt i32 %81, 0
br i1 %82, label %109, label %83
83: ; preds = %78
%84 = or i64 %79, 1
%85 = getelementptr inbounds [128 x i32], [128 x i32]* %3, i64 0, i64 %84
%86 = load i32, i32* %85
%87 = icmp slt i32 %86, 0
br i1 %87, label %109, label %88
88: ; preds = %83
%89 = or i64 %79, 2
%90 = getelementptr inbounds [128 x i32], [128 x i32]* %3, i64 0, i64 %89
%91 = load i32, i32* %90
%92 = icmp slt i32 %91, 0
br i1 %92, label %109, label %93
93: ; preds = %88
%94 = or i64 %79, 3
%95 = getelementptr inbounds [128 x i32], [128 x i32]* %3, i64 0, i64 %94
%96 = load i32, i32* %95
%97 = icmp slt i32 %96, 0
br i1 %97, label %109, label %98
98: ; preds = %93
%99 = add nuw nsw i64 %79, 4
%100 = icmp eq i64 %99, 128
br i1 %100, label %101, label %78
101: ; preds = %98
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i32 128)
%103 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.21, i64 0, i64 0))
%104 = call i32 @close(i32 undef)
br label %105
105: ; preds = %101, %68
%106 = load i32, i32* %6
store i32 %106, i32* %5
%107 = call i32 @select(i32 %47, i32* %5, i32* null, i32* null, i32* null)
%108 = icmp eq i32 %107, -1
br i1 %108, label %63, label %68
109: ; preds = %93, %88, %83, %78
%110 = phi i64 [ %79, %78 ], [ %84, %83 ], [ %89, %88 ], [ %94, %93 ]
%111 = trunc i64 %110 to i32
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i32 %111)
%113 = call i32 @FD_SET(i32 undef, i32* %6)
%114 = icmp slt i32 %62, %111
%115 = select i1 %114, i32 %111, i32 %62
br label %116
116: ; preds = %71, %109
%117 = phi i32 [ %115, %109 ], [ %62, %71 ]
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 %117)
%119 = icmp slt i32 %117, 0
br i1 %119, label %56, label %120
120: ; preds = %116
%121 = add nuw i32 %117, 1
%122 = zext i32 %121 to i64
br label %123
123: ; preds = %120, %175
%124 = phi i64 [ 0, %120 ], [ %176, %175 ]
%125 = getelementptr inbounds [128 x i32], [128 x i32]* %3, i64 0, i64 %124
%126 = load i32, i32* %125
%127 = icmp slt i32 %126, 1
br i1 %127, label %175, label %128
128: ; preds = %123
%129 = trunc i64 %124 to i32
%130 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.12, i64 0, i64 0), i32 %129, i32 %126)
%131 = call i64 @FD_ISSET(i32 %126, i32* %5)
%132 = icmp eq i64 %131, 0
br i1 %132, label %175, label %133
133: ; preds = %128
%134 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.13, i64 0, i64 0), i32 %129, i32 %126)
%135 = call i32 @memset(i8* %11, i32 0, i32 1024)
%136 = call i32 @read(i32 %126, i8* %11, i32 1024)
%137 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i32 %136)
%138 = icmp slt i32 %136, 0
br i1 %138, label %139, label %143
139: ; preds = %133
%140 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i32 %126)
%141 = call i32 @close(i32 %126)
%142 = call i32 @FD_CLR(i32 %126, i32* %6)
store i32 1, i32* %125
br label %175
143: ; preds = %133
%144 = icmp eq i32 %136, 0
br i1 %144, label %145, label %149
145: ; preds = %143
%146 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.16, i64 0, i64 0), i32 %126)
%147 = call i32 @close(i32 %126)
%148 = call i32 @FD_CLR(i32 %126, i32* %6)
store i32 1, i32* %125
br label %175
149: ; preds = %143
%150 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.12, i64 0, i64 0), i32 %129, i32 %126)
%151 = call i32 @memset(i8* %11, i32 0, i32 1024)
%152 = call i32 @read(i32 %126, i8* %11, i32 1024)
%153 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i32 %152)
%154 = icmp slt i32 %152, 0
br i1 %154, label %155, label %159
155: ; preds = %149
%156 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i32 %126)
%157 = call i32 @close(i32 %126)
%158 = call i32 @FD_CLR(i32 %126, i32* %6)
store i32 1, i32* %125
br label %175
159: ; preds = %149
%160 = icmp eq i32 %152, 0
br i1 %160, label %161, label %165
161: ; preds = %159
%162 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.16, i64 0, i64 0), i32 %126)
%163 = call i32 @close(i32 %126)
%164 = call i32 @FD_CLR(i32 %126, i32* %6)
store i32 1, i32* %125
br label %175
165: ; preds = %159
%166 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.17, i64 0, i64 0), i32 %152, i8* %11)
%167 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%168 = icmp eq i64 %167, 0
br i1 %168, label %169, label %172
169: ; preds = %165
%170 = call i32 @close(i32 %126)
%171 = call i32 @FD_CLR(i32 %126, i32* %6)
store i32 1, i32* %125
br label %175
172: ; preds = %165
%173 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i64 0, i64 0), i8* %11)
%174 = call i32 @write(i32 %126, i8* %11, i32 %152)
br label %175
175: ; preds = %128, %123, %172, %169, %161, %155, %145, %139
%176 = add nuw nsw i64 %124, 1
%177 = icmp eq i64 %176, %122
br i1 %177, label %56, label %123
}