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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int Accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ Bind(int, struct sockaddr *, int);
int /*<<< orphan*/ Close(int);
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*/ Listen(int, int);
int /*<<< orphan*/ Readline(int, char *, int);
int /*<<< orphan*/ SOCK_STREAM;
int Select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int Socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ Writen(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ err_quit(char *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int main(void) {
  int i, maxi, maxfd, listenfd, connfd, sockfd;
  int nready, client[FD_SETSIZE];
  ssize_t n;
  fd_set rset, allset;
  char line[1024];
  struct sockaddr_in srvaddr;
  listenfd = Socket(AF_INET, SOCK_STREAM, 0);
  memset(&srvaddr, 0, sizeof(srvaddr));
  srvaddr.sin_family = AF_INET;
  srvaddr.sin_addr.s_addr = htonl(INADDR_ANY);
  srvaddr.sin_port = htons(9877);
  Bind(listenfd, (struct sockaddr *)&srvaddr, sizeof(srvaddr));
  Listen(listenfd, 1024);
  maxi = -1;
  for (i = 0; i < FD_SETSIZE; ++i)
    client[i] = -1;
  maxfd = listenfd;
  FD_ZERO(&allset);
  FD_SET(listenfd, &allset);
  for (;;) {
    rset = allset;
    nready = Select(maxfd + 1, &rset, NULL, NULL, NULL);
    if (FD_ISSET(listenfd, &rset)) {
      connfd = Accept(listenfd, NULL, NULL);
      for (i = 0; i < FD_SETSIZE; ++i) {
        if (client[i] < 0) {
          client[i] = connfd;
          break;
        }
      }
      if (i == FD_SETSIZE)
        err_quit("too many clients");
      FD_SET(connfd, &allset);
      if (connfd > maxfd)
        maxfd = connfd;
      if (i > maxi)
        maxi = i;
      if (--nready <= 0)
        continue;
    }
    for (i = 0; i <= maxi; ++i) {
      if ((sockfd = client[i]) < 0)
        continue;
      if (FD_ISSET(sockfd, &rset)) {
        if ((n = Readline(sockfd, line, 1024)) == 0) {
          Close(sockfd);
          FD_CLR(sockfd, &allset);
          client[i] = -1;
        } else
          Writen(sockfd, line, n);
        if (--nready <= 0)
          continue;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x458(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
mov    0x2d7e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <Socket@plt>
mov    %eax,-0x14(%rbp)
lea    -0x450(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x448(%rbp)
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0x44c(%rbp)
mov    $0x2695,%edi
call   1050 <htons@plt>
mov    %eax,-0x450(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x450(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <Bind@plt>
mov    -0x14(%rbp),%edi
mov    $0x400,%esi
call   10b0 <Listen@plt>
movl   $0xffffffff,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2ceb(%rip),%rcx
cmp    (%rcx),%eax
jge    1305 <main+0x105>
mov    -0x458(%rbp),%rax
movslq -0x8(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12d3 <main+0xd3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    -0x3c(%rbp),%rdi
call   10a0 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x3c(%rbp),%rsi
call   1120 <FD_SET@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%edi
add    $0x1,%edi
lea    -0x38(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10d0 <Select@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     142c <main+0x22c>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1040 <Accept@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2c4c(%rip),%rcx
cmp    (%rcx),%eax
jge    13c2 <main+0x1c2>
mov    -0x458(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jge    13af <main+0x1af>
mov    -0x458(%rbp),%rax
mov    -0x18(%rbp),%edx
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    13c2 <main+0x1c2>
jmp    13b4 <main+0x1b4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1372 <main+0x172>
mov    -0x8(%rbp),%eax
mov    0x2bfc(%rip),%rcx
cmp    (%rcx),%eax
jne    13e0 <main+0x1e0>
lea    0xc25(%rip),%rdi
call   1080 <err_quit@plt>
mov    -0x18(%rbp),%edi
lea    -0x3c(%rbp),%rsi
call   1120 <FD_SET@plt>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    13fe <main+0x1fe>
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1410 <main+0x210>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jg     1427 <main+0x227>
jmp    1320 <main+0x120>
jmp    142c <main+0x22c>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1500 <main+0x300>
mov    -0x458(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    145e <main+0x25e>
jmp    14f2 <main+0x2f2>
mov    -0x1c(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     14ed <main+0x2ed>
mov    -0x1c(%rbp),%edi
lea    -0x440(%rbp),%rsi
mov    $0x400,%edx
call   1090 <Readline@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jne    14bf <main+0x2bf>
mov    -0x1c(%rbp),%edi
call   10e0 <Close@plt>
mov    -0x1c(%rbp),%edi
lea    -0x3c(%rbp),%rsi
call   1110 <FD_CLR@plt>
mov    -0x458(%rbp),%rax
movslq -0x8(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
jmp    14d1 <main+0x2d1>
mov    -0x1c(%rbp),%edi
lea    -0x440(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1100 <Writen@plt>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jg     14e8 <main+0x2e8>
jmp    14f2 <main+0x2f2>
jmp    14ed <main+0x2ed>
jmp    14f2 <main+0x2f2>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1433 <main+0x233>
jmp    1320 <main+0x120>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    0x2dad(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    0x2dad(%rip),%r13
mov    0x0(%r13),%edi
mov    0x2d8a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <Socket@plt>
mov    %eax,%ebx
lea    -0x50(%rbp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x0(%r13),%eax
mov    %eax,-0x48(%rbp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0x4c(%rbp)
mov    $0x2695,%edi
call   1050 <htons@plt>
mov    %eax,-0x50(%rbp)
mov    %ebx,%edi
mov    %r15,%rsi
mov    %ebx,%r15d
mov    $0xc,%edx
call   10c0 <Bind@plt>
mov    %ebx,%edi
mov    $0x400,%esi
call   10b0 <Listen@plt>
mov    (%r12),%edx
test   %edx,%edx
jle    12c0 <main+0xc0>
shl    $0x2,%rdx
mov    %r14,%rdi
mov    $0xff,%esi
call   1070 <memset@plt>
lea    -0x2c(%rbp),%rbx
mov    %rbx,%rdi
call   10a0 <FD_ZERO@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
call   1120 <FD_SET@plt>
mov    $0xffffffff,%r13d
mov    %r15d,%r12d
mov    %r15d,-0x30(%rbp)
jmp    12fc <main+0xfc>
cs nopw 0x0(%rax,%rax,1)
mov    -0x30(%rbp),%r15d
mov    -0x40(%rbp),%r13
mov    -0x58(%rbp),%r12
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    0x1(%r12),%edi
lea    -0x34(%rbp),%rbx
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10d0 <Select@plt>
mov    %eax,-0x40(%rbp)
mov    %r15d,%edi
mov    %rbx,%rsi
call   1030 <FD_ISSET@plt>
test   %rax,%rax
je     13a0 <main+0x1a0>
xor    %ebx,%ebx
mov    %r15d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <Accept@plt>
mov    %eax,%r15d
mov    0x2c83(%rip),%rax
mov    (%rax),%eax
test   %eax,%eax
jle    1368 <main+0x168>
xor    %ebx,%ebx
nopl   (%rax)
cmpl   $0x0,(%r14,%rbx,4)
js     1364 <main+0x164>
add    $0x1,%rbx
cmp    %rbx,%rax
jne    1350 <main+0x150>
mov    %eax,%ebx
jmp    136c <main+0x16c>
mov    %r15d,(%r14,%rbx,4)
cmp    %eax,%ebx
jne    1378 <main+0x178>
lea    0xc8d(%rip),%rdi
call   1080 <err_quit@plt>
mov    %r15d,%edi
lea    -0x2c(%rbp),%rsi
call   1120 <FD_SET@plt>
cmp    %r12d,%r15d
cmovg  %r15d,%r12d
cmp    %r13d,%ebx
cmovg  %ebx,%r13d
cmpl   $0x2,-0x40(%rbp)
mov    -0x30(%rbp),%r15d
jl     12fc <main+0xfc>
test   %r13d,%r13d
js     12fc <main+0xfc>
mov    %r12,-0x58(%rbp)
mov    %r13,-0x40(%rbp)
lea    0x1(%r13),%r15d
xor    %r13d,%r13d
jmp    13d9 <main+0x1d9>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r12,%rsi
mov    %eax,%edx
call   1100 <Writen@plt>
add    $0x1,%r13
cmp    %r13,%r15
je     12f0 <main+0xf0>
mov    (%r14,%r13,4),%ebx
test   %ebx,%ebx
js     13cc <main+0x1cc>
mov    %ebx,%edi
lea    -0x34(%rbp),%rsi
call   1030 <FD_ISSET@plt>
lea    -0x460(%rbp),%r12
test   %rax,%rax
je     13cc <main+0x1cc>
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0x400,%edx
call   1090 <Readline@plt>
test   %eax,%eax
jne    13c0 <main+0x1c0>
mov    %ebx,%edi
call   10e0 <Close@plt>
mov    %ebx,%edi
lea    -0x2c(%rbp),%rsi
call   1110 <FD_CLR@plt>
movl   $0xffffffff,(%r14,%r13,4)
ff
jmp    13cc <main+0x1cc>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@FD_SETSIZE = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@INADDR_ANY = global i32 0
@.str = [17 x i8] c"too many clients\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [1024 x i8]
%15 = alloca %struct.sockaddr_in
store i32 0, i32* %1
%16 = load i32, i32* @FD_SETSIZE
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %9
%19 = alloca i32, i64 %17
store i64 %17, i64* %10
%20 = load i32, i32* @AF_INET
%21 = load i32, i32* @SOCK_STREAM
%22 = call i32 @Socket(i32 %20, i32 %21, i32 0)
store i32 %22, i32* %5
%23 = call i32 @memset(%struct.sockaddr_in* %15, i32 0, i32 12)
%24 = load i32, i32* @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 2
store i32 %24, i32* %25
%26 = load i32, i32* @INADDR_ANY
%27 = call i32 @htonl(i32 %26)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
%29 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %28, i32 0, i32 0
store i32 %27, i32* %29
%30 = call i32 @htons(i32 9877)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
store i32 %30, i32* %31
%32 = load i32, i32* %5
%33 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
%34 = call i32 @Bind(i32 %32, %struct.sockaddr* %33, i32 12)
%35 = load i32, i32* %5
%36 = call i32 @Listen(i32 %35, i32 1024)
store i32 -1, i32* %3
store i32 0, i32* %2
br label %37
37: ; preds = %45, %0
%38 = load i32, i32* %2
%39 = load i32, i32* @FD_SETSIZE
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %48
41: ; preds = %37
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %19, i64 %43
store i32 -1, i32* %44
br label %45
45: ; preds = %41
%46 = load i32, i32* %2
%47 = add nsw i32 %46, 1
store i32 %47, i32* %2
br label %37
48: ; preds = %37
%49 = load i32, i32* %5
store i32 %49, i32* %4
%50 = call i32 @FD_ZERO(i32* %13)
%51 = load i32, i32* %5
%52 = call i32 @FD_SET(i32 %51, i32* %13)
br label %53
53: ; preds = %153, %107, %48
%54 = load i32, i32* %13
store i32 %54, i32* %12
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
%57 = call i32 @Select(i32 %56, i32* %12, i32* null, i32* null, i32* null)
store i32 %57, i32* %8
%58 = load i32, i32* %5
%59 = call i64 @FD_ISSET(i32 %58, i32* %12)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %109
61: ; preds = %53
%62 = load i32, i32* %5
%63 = call i32 @Accept(i32 %62, i32* null, i32* null)
store i32 %63, i32* %6
store i32 0, i32* %2
br label %64
64: ; preds = %80, %61
%65 = load i32, i32* %2
%66 = load i32, i32* @FD_SETSIZE
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %83
68: ; preds = %64
%69 = load i32, i32* %2
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %19, i64 %70
%72 = load i32, i32* %71
%73 = icmp slt i32 %72, 0
br i1 %73, label %74, label %79
74: ; preds = %68
%75 = load i32, i32* %6
%76 = load i32, i32* %2
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i32, i32* %19, i64 %77
store i32 %75, i32* %78
br label %83
79: ; preds = %68
br label %80
80: ; preds = %79
%81 = load i32, i32* %2
%82 = add nsw i32 %81, 1
store i32 %82, i32* %2
br label %64
83: ; preds = %74, %64
%84 = load i32, i32* %2
%85 = load i32, i32* @FD_SETSIZE
%86 = icmp eq i32 %84, %85
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = call i32 @err_quit(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %89
89: ; preds = %87, %83
%90 = load i32, i32* %6
%91 = call i32 @FD_SET(i32 %90, i32* %13)
%92 = load i32, i32* %6
%93 = load i32, i32* %4
%94 = icmp sgt i32 %92, %93
br i1 %94, label %95, label %97
95: ; preds = %89
%96 = load i32, i32* %6
store i32 %96, i32* %4
br label %97
97: ; preds = %95, %89
%98 = load i32, i32* %2
%99 = load i32, i32* %3
%100 = icmp sgt i32 %98, %99
br i1 %100, label %101, label %103
101: ; preds = %97
%102 = load i32, i32* %2
store i32 %102, i32* %3
br label %103
103: ; preds = %101, %97
%104 = load i32, i32* %8
%105 = add nsw i32 %104, -1
store i32 %105, i32* %8
%106 = icmp sle i32 %105, 0
br i1 %106, label %107, label %108
107: ; preds = %103
br label %53
108: ; preds = %103
br label %109
109: ; preds = %108, %53
store i32 0, i32* %2
br label %110
110: ; preds = %150, %109
%111 = load i32, i32* %2
%112 = load i32, i32* %3
%113 = icmp sle i32 %111, %112
br i1 %113, label %114, label %153
114: ; preds = %110
%115 = load i32, i32* %2
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i32, i32* %19, i64 %116
%118 = load i32, i32* %117
store i32 %118, i32* %7
%119 = icmp slt i32 %118, 0
br i1 %119, label %120, label %121
120: ; preds = %114
br label %150
121: ; preds = %114
%122 = load i32, i32* %7
%123 = call i64 @FD_ISSET(i32 %122, i32* %12)
%124 = icmp ne i64 %123, 0
br i1 %124, label %125, label %149
125: ; preds = %121
%126 = load i32, i32* %7
%127 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%128 = call i32 @Readline(i32 %126, i8* %127, i32 1024)
store i32 %128, i32* %11
%129 = icmp eq i32 %128, 0
br i1 %129, label %130, label %138
130: ; preds = %125
%131 = load i32, i32* %7
%132 = call i32 @Close(i32 %131)
%133 = load i32, i32* %7
%134 = call i32 @FD_CLR(i32 %133, i32* %13)
%135 = load i32, i32* %2
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i32, i32* %19, i64 %136
store i32 -1, i32* %137
br label %143
138: ; preds = %125
%139 = load i32, i32* %7
%140 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%141 = load i32, i32* %11
%142 = call i32 @Writen(i32 %139, i8* %140, i32 %141)
br label %143
143: ; preds = %138, %130
%144 = load i32, i32* %8
%145 = add nsw i32 %144, -1
store i32 %145, i32* %8
%146 = icmp sle i32 %145, 0
br i1 %146, label %147, label %148
147: ; preds = %143
br label %150
148: ; preds = %143
br label %149
149: ; preds = %148, %121
br label %150
150: ; preds = %149, %147, %120
%151 = load i32, i32* %2
%152 = add nsw i32 %151, 1
store i32 %152, i32* %2
br label %110
153: ; preds = %110
br label %53
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@FD_SETSIZE = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@INADDR_ANY = global i32 0
@.str = [17 x i8] c"too many clients\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca %struct.sockaddr_in
%5 = load i32, i32* @FD_SETSIZE
%6 = zext i32 %5 to i64
%7 = alloca i32, i64 %6
%8 = bitcast i32* %1 to i8*
%9 = bitcast i32* %2 to i8*
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%11 = bitcast %struct.sockaddr_in* %4 to i8*
%12 = load i32, i32* @AF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = tail call i32 @Socket(i32 %12, i32 %13, i32 0)
%15 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 12)
%16 = load i32, i32* @AF_INET
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %16, i32* %17
%18 = load i32, i32* @INADDR_ANY
%19 = call i32 @htonl(i32 %18)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %19, i32* %20
%21 = call i32 @htons(i32 9877)
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %21, i32* %22
%23 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%24 = call i32 @Bind(i32 %14, %struct.sockaddr* %23, i32 12)
%25 = call i32 @Listen(i32 %14, i32 1024)
%26 = load i32, i32* @FD_SETSIZE
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %0
%29 = bitcast i32* %7 to i8*
%30 = zext i32 %26 to i64
%31 = shl nuw nsw i64 %30, 2
br label %32
32: ; preds = %28, %0
%33 = call i32 @FD_ZERO(i32* %2)
%34 = call i32 @FD_SET(i32 %14, i32* %2)
br label %35
35: ; preds = %79, %32
%36 = phi i32 [ %14, %32 ], [ %80, %79 ]
%37 = phi i32 [ -1, %32 ], [ %81, %79 ]
%38 = load i32, i32* %2
store i32 %38, i32* %1
%39 = add nsw i32 %36, 1
%40 = call i32 @Select(i32 %39, i32* %1, i32* null, i32* null, i32* null)
%41 = call i64 @FD_ISSET(i32 %14, i32* %1)
%42 = icmp eq i64 %41, 0
br i1 %42, label %75, label %43
43: ; preds = %35
%44 = call i32 @Accept(i32 %14, i32* null, i32* null)
%45 = load i32, i32* @FD_SETSIZE
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %61
47: ; preds = %43
%48 = zext i32 %45 to i64
br label %49
49: ; preds = %47, %58
%50 = phi i64 [ 0, %47 ], [ %59, %58 ]
%51 = getelementptr inbounds i32, i32* %7, i64 %50
%52 = load i32, i32* %51
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %49
%55 = trunc i64 %50 to i32
%56 = and i64 %50, 4294967295
%57 = getelementptr inbounds i32, i32* %7, i64 %56
store i32 %44, i32* %57
br label %61
58: ; preds = %49
%59 = add nuw nsw i64 %50, 1
%60 = icmp eq i64 %59, %48
br i1 %60, label %64, label %49
61: ; preds = %43, %54
%62 = phi i32 [ %55, %54 ], [ 0, %43 ]
%63 = icmp eq i32 %62, %45
br i1 %63, label %64, label %67
64: ; preds = %58, %61
%65 = phi i32 [ %62, %61 ], [ %45, %58 ]
%66 = call i32 @err_quit(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %67
67: ; preds = %64, %61
%68 = phi i32 [ %65, %64 ], [ %62, %61 ]
%69 = call i32 @FD_SET(i32 %44, i32* %2)
%70 = icmp sgt i32 %44, %36
%71 = select i1 %70, i32 %44, i32 %36
%72 = icmp sgt i32 %68, %37
%73 = select i1 %72, i32 %68, i32 %37
%74 = icmp slt i32 %40, 2
br i1 %74, label %79, label %75
75: ; preds = %67, %35
%76 = phi i32 [ %71, %67 ], [ %36, %35 ]
%77 = phi i32 [ %73, %67 ], [ %37, %35 ]
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %101, %75, %67
%80 = phi i32 [ %71, %67 ], [ %76, %75 ], [ %76, %101 ]
%81 = phi i32 [ %73, %67 ], [ %77, %75 ], [ %77, %101 ]
br label %35
82: ; preds = %75
%83 = add nuw i32 %77, 1
%84 = zext i32 %83 to i64
br label %85
85: ; preds = %82, %101
%86 = phi i64 [ 0, %82 ], [ %102, %101 ]
%87 = getelementptr inbounds i32, i32* %7, i64 %86
%88 = load i32, i32* %87
%89 = icmp slt i32 %88, 0
br i1 %89, label %101, label %90
90: ; preds = %85
%91 = call i64 @FD_ISSET(i32 %88, i32* %1)
%92 = icmp eq i64 %91, 0
br i1 %92, label %101, label %93
93: ; preds = %90
%94 = call i32 @Readline(i32 %88, i8* %10, i32 1024)
%95 = icmp eq i32 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %93
%97 = call i32 @Close(i32 %88)
%98 = call i32 @FD_CLR(i32 %88, i32* %2)
store i32 -1, i32* %87
br label %101
99: ; preds = %93
%100 = call i32 @Writen(i32 %88, i8* %10, i32 %94)
br label %101
101: ; preds = %96, %99, %90, %85
%102 = add nuw nsw i64 %86, 1
%103 = icmp eq i64 %102, %84
br i1 %103, label %79, label %85
}