#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ clnt_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ FD_CLR(int, int /*<<< orphan*/ *);
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ error_handling(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/,
           struct timeval *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  int serv_sock, clnt_sock;
  struct sockaddr_in serv_addr, clnt_addr;
  struct timeval timeout;
  fd_set reads, cpy_reads;
  socklen_t adr_sz;
  int fd_max, str_len, fd_num, i;
  char buf[200];
  if (argc != 1) {
    printf("arg errro!");
    exit(1);
  }
  serv_sock = socket(PF_INET, SOCK_STREAM, 0);
  memset(&serv_addr, 0, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = inet_addr("10.0.2.15");
  serv_addr.sin_port = htons(9000);
  if (bind(serv_sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == -1)
    error_handling("bind error");
  if (listen(serv_sock, 5) == -1)
    error_handling("listen error");
  FD_ZERO(&reads);
  FD_SET(serv_sock, &reads);
  fd_max = serv_sock;
  while (1) {
    cpy_reads = reads;
    timeout.tv_sec = 5;
    timeout.tv_usec = 0;
    fd_num = select(fd_max + 1, &cpy_reads, 0, 0, &timeout);
    if (fd_num == -1) {
      break;
    }
    if (fd_num == 0) {
      continue;
    }
    for (i = 0; i < fd_max + 1; ++i) {
      if (FD_ISSET(i, &cpy_reads)) {
        if (i == serv_sock) {
          adr_sz = sizeof(clnt_addr);
          clnt_sock = accept(serv_sock, (struct sockaddr *)&clnt_addr, &adr_sz);
          FD_SET(clnt_sock, &reads);
          if (fd_max < clnt_sock)
            fd_max = clnt_sock;
          printf("connected client : %d \n", clnt_sock);
        } else {
          str_len = read(i, buf, 200);
          if (str_len == 0) {
            FD_CLR(i, &reads);
            close(i);
            printf("closed client : %d\n", i);
          } else {
            write(i, buf, str_len);
          }
        }
      }
    }
  }
  close(serv_sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     125b <main+0x3b>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
mov    0x2d6d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    0xd71(%rip),%rdi
call   10a0 <inet_addr@plt>
mov    %eax,-0x24(%rbp)
mov    $0x2328,%edi
call   1050 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   10f0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12d5 <main+0xb5>
lea    0xd45(%rip),%rdi
call   10d0 <error_handling@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   10e0 <listen@plt>
cmp    $0xffffffff,%eax
jne    12f7 <main+0xd7>
lea    0xd2e(%rip),%rdi
call   10d0 <error_handling@plt>
lea    -0x4c(%rbp),%rdi
call   10b0 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x4c(%rbp),%rsi
call   1130 <FD_SET@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x50(%rbp)
movl   $0x5,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x58(%rbp),%edi
add    $0x1,%edi
lea    -0x50(%rbp),%rsi
xor    %ecx,%ecx
lea    -0x48(%rbp),%r8
mov    %ecx,%edx
call   10c0 <select@plt>
mov    %eax,-0x60(%rbp)
cmpl   $0xffffffff,-0x60(%rbp)
jne    1350 <main+0x130>
jmp    1466 <main+0x246>
cmpl   $0x0,-0x60(%rbp)
jne    135f <main+0x13f>
jmp    1312 <main+0xf2>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1461 <main+0x241>
mov    -0x64(%rbp),%edi
lea    -0x50(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     144e <main+0x22e>
mov    -0x64(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    13e7 <main+0x1c7>
movl   $0xc,-0x54(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x54(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x4c(%rbp),%rsi
call   1130 <FD_SET@plt>
mov    -0x58(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    13d1 <main+0x1b1>
mov    -0x18(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x18(%rbp),%esi
lea    0xc52(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1449 <main+0x229>
mov    -0x64(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0xc8,%edx
call   1090 <read@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jne    1432 <main+0x212>
mov    -0x64(%rbp),%edi
lea    -0x4c(%rbp),%rsi
call   1110 <FD_CLR@plt>
mov    -0x64(%rbp),%edi
call   1080 <close@plt>
mov    -0x64(%rbp),%esi
lea    0xc1f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1444 <main+0x224>
mov    -0x64(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    -0x5c(%rbp),%edx
call   1030 <write@plt>
jmp    1449 <main+0x229>
jmp    144e <main+0x22e>
jmp    1453 <main+0x233>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1366 <main+0x146>
jmp    1312 <main+0xf2>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
cmp    $0x1,%edi
jne    1417 <main+0x1f7>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,%r15d
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
lea    0xd8d(%rip),%rdi
call   10a0 <inet_addr@plt>
mov    %eax,0x14(%rsp)
mov    $0x2328,%edi
call   1050 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   10f0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12b6 <main+0x96>
lea    0xd64(%rip),%rdi
call   10d0 <error_handling@plt>
mov    %r15d,%edi
mov    $0x5,%esi
call   10e0 <listen@plt>
cmp    $0xffffffff,%eax
jne    12d4 <main+0xb4>
lea    0xd51(%rip),%rdi
call   10d0 <error_handling@plt>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   10b0 <FD_ZERO@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
call   1130 <FD_SET@plt>
lea    0xc(%rsp),%rbx
lea    0x20(%rsp),%r13
mov    %r15d,%r14d
lea    0x1(%r14),%ebp
nopl   (%rax)
mov    0x4(%rsp),%eax
mov    %eax,0xc(%rsp)
movl   $0x5,0x20(%rsp)
movq   $0x0,0x28(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r13,%r8
call   10c0 <select@plt>
test   %eax,%eax
je     1300 <main+0xe0>
cmp    $0xffffffff,%eax
je     13fb <main+0x1db>
test   %r14d,%r14d
js     1300 <main+0xe0>
xor    %r12d,%r12d
lea    0x40(%rsp),%rbp
jmp    13a5 <main+0x185>
cs nopw 0x0(%rax,%rax,1)
movl   $0xc,0x8(%rsp)
mov    %r15d,%edi
lea    0x30(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1100 <accept@plt>
mov    %eax,%ebp
mov    %eax,%edi
lea    0x4(%rsp),%rsi
call   1130 <FD_SET@plt>
cmp    %ebp,%r14d
cmovl  %ebp,%r14d
lea    0xca7(%rip),%rdi
mov    %ebp,%esi
lea    0x40(%rsp),%rbp
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x1(%r12),%eax
cmp    %r14d,%r12d
mov    %eax,%r12d
jge    12f9 <main+0xd9>
mov    %r12d,%edi
mov    %rbx,%rsi
call   1040 <FD_ISSET@plt>
test   %rax,%rax
je     1394 <main+0x174>
cmp    %r12d,%r15d
je     1350 <main+0x130>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0xc8,%edx
call   1090 <read@plt>
mov    %r12d,%edi
test   %eax,%eax
je     13dd <main+0x1bd>
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
jmp    1394 <main+0x174>
lea    0x4(%rsp),%rsi
call   1110 <FD_CLR@plt>
mov    %r12d,%edi
call   1080 <close@plt>
lea    0xc4f(%rip),%rdi
mov    %r12d,%esi
jmp    138d <main+0x16d>
mov    %r15d,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbe2(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [11 x i8] c"arg errro!\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@AF_INET = global i32 0
@.str.1 = [10 x i8] c"10.0.2.15\00"
@.str.2 = [11 x i8] c"bind error\00"
@.str.3 = [13 x i8] c"listen error\00"
@.str.4 = [24 x i8] c"connected client : %d \0A\00"
@.str.5 = [20 x i8] c"closed client : %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.sockaddr_in
%10 = alloca %struct.timeval
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [200 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 1
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %2
%25 = load i32, i32* @PF_INET
%26 = load i32, i32* @SOCK_STREAM
%27 = call i32 @socket(i32 %25, i32 %26, i32 0)
store i32 %27, i32* %6
%28 = call i32 @memset(%struct.sockaddr_in* %8, i32 0, i32 12)
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %29, i32* %30
%31 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%33 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %32, i32 0, i32 0
store i32 %31, i32* %33
%34 = call i32 @htons(i32 9000)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %34, i32* %35
%36 = load i32, i32* %6
%37 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%38 = call i32 @bind(i32 %36, %struct.sockaddr* %37, i32 12)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %42
40: ; preds = %24
%41 = call i32 @error_handling(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %40, %24
%43 = load i32, i32* %6
%44 = call i32 @listen(i32 %43, i32 5)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 @error_handling(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %48
48: ; preds = %46, %42
%49 = call i32 @FD_ZERO(i32* %11)
%50 = load i32, i32* %6
%51 = call i32 @FD_SET(i32 %50, i32* %11)
%52 = load i32, i32* %6
store i32 %52, i32* %14
br label %53
53: ; preds = %48, %66, %119
%54 = load i32, i32* %11
store i32 %54, i32* %12
%55 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
store i32 5, i32* %55
%56 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
store i64 0, i64* %56
%57 = load i32, i32* %14
%58 = add nsw i32 %57, 1
%59 = call i32 @select(i32 %58, i32* %12, i32 0, i32 0, %struct.timeval* %10)
store i32 %59, i32* %16
%60 = load i32, i32* %16
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %63
62: ; preds = %53
br label %120
63: ; preds = %53
%64 = load i32, i32* %16
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %63
br label %53
67: ; preds = %63
store i32 0, i32* %17
br label %68
68: ; preds = %116, %67
%69 = load i32, i32* %17
%70 = load i32, i32* %14
%71 = add nsw i32 %70, 1
%72 = icmp slt i32 %69, %71
br i1 %72, label %73, label %119
73: ; preds = %68
%74 = load i32, i32* %17
%75 = call i64 @FD_ISSET(i32 %74, i32* %12)
%76 = icmp ne i64 %75, 0
br i1 %76, label %77, label %115
77: ; preds = %73
%78 = load i32, i32* %17
%79 = load i32, i32* %6
%80 = icmp eq i32 %78, %79
br i1 %80, label %81, label %95
81: ; preds = %77
store i32 12, i32* %13
%82 = load i32, i32* %6
%83 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%84 = call i32 @accept(i32 %82, %struct.sockaddr* %83, i32* %13)
store i32 %84, i32* %7
%85 = load i32, i32* %7
%86 = call i32 @FD_SET(i32 %85, i32* %11)
%87 = load i32, i32* %14
%88 = load i32, i32* %7
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %92
90: ; preds = %81
%91 = load i32, i32* %7
store i32 %91, i32* %14
br label %92
92: ; preds = %90, %81
%93 = load i32, i32* %7
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %93)
br label %114
95: ; preds = %77
%96 = load i32, i32* %17
%97 = getelementptr inbounds [200 x i8], [200 x i8]* %18, i64 0, i64 0
%98 = call i32 @read(i32 %96, i8* %97, i32 200)
store i32 %98, i32* %15
%99 = load i32, i32* %15
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %108
101: ; preds = %95
%102 = load i32, i32* %17
%103 = call i32 @FD_CLR(i32 %102, i32* %11)
%104 = load i32, i32* %17
%105 = call i32 @close(i32 %104)
%106 = load i32, i32* %17
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %106)
br label %113
108: ; preds = %95
%109 = load i32, i32* %17
%110 = getelementptr inbounds [200 x i8], [200 x i8]* %18, i64 0, i64 0
%111 = load i32, i32* %15
%112 = call i32 @write(i32 %109, i8* %110, i32 %111)
br label %113
113: ; preds = %108, %101
br label %114
114: ; preds = %113, %92
br label %115
115: ; preds = %114, %73
br label %116
116: ; preds = %115
%117 = load i32, i32* %17
%118 = add nsw i32 %117, 1
store i32 %118, i32* %17
br label %68
119: ; preds = %68
br label %53
120: ; preds = %62
%121 = load i32, i32* %6
%122 = call i32 @close(i32 %121)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [11 x i8] c"arg errro!\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@AF_INET = global i32 0
@.str.1 = [10 x i8] c"10.0.2.15\00"
@.str.2 = [11 x i8] c"bind error\00"
@.str.3 = [13 x i8] c"listen error\00"
@.str.4 = [24 x i8] c"connected client : %d \0A\00"
@.str.5 = [20 x i8] c"closed client : %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.timeval
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [200 x i8]
%10 = bitcast %struct.sockaddr_in* %3 to i8*
%11 = bitcast %struct.sockaddr_in* %4 to i8*
%12 = bitcast %struct.timeval* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = bitcast i32* %8 to i8*
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%17 = icmp eq i32 %0, 1
br i1 %17, label %21, label %18
18: ; preds = %2
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i32, i32* @PF_INET
%23 = load i32, i32* @SOCK_STREAM
%24 = tail call i32 @socket(i32 %22, i32 %23, i32 0)
%25 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%26 = load i32, i32* @AF_INET
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %26, i32* %27
%28 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %28, i32* %29
%30 = call i32 @htons(i32 9000)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %30, i32* %31
%32 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%33 = call i32 @bind(i32 %24, %struct.sockaddr* %32, i32 12)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %21
%36 = call i32 @error_handling(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %35, %21
%38 = call i32 @listen(i32 %24, i32 5)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @error_handling(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %37
%43 = call i32 @FD_ZERO(i32* %6)
%44 = call i32 @FD_SET(i32 %24, i32* %6)
%45 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%46 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%47 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
br label %48
48: ; preds = %79, %42
%49 = phi i32 [ %24, %42 ], [ %80, %79 ]
%50 = add nsw i32 %49, 1
%51 = icmp slt i32 %49, 0
br label %52
52: ; preds = %48, %56
br label %53
53: ; preds = %52, %53
%54 = load i32, i32* %6
store i32 %54, i32* %7
store i32 5, i32* %45
store i64 0, i64* %46
%55 = call i32 @select(i32 %50, i32* %7, i32 0, i32 0, %struct.timeval* %5)
switch i32 %55, label %56 [
i32 -1, label %83
i32 0, label %53
]
56: ; preds = %53
br i1 %51, label %52, label %57
57: ; preds = %56, %79
%58 = phi i32 [ %81, %79 ], [ 0, %56 ]
%59 = phi i32 [ %80, %79 ], [ %49, %56 ]
%60 = call i64 @FD_ISSET(i32 %58, i32* %7)
%61 = icmp eq i64 %60, 0
br i1 %61, label %79, label %62
62: ; preds = %57
%63 = icmp eq i32 %58, %24
br i1 %63, label %64, label %70
64: ; preds = %62
store i32 12, i32* %8
%65 = call i32 @accept(i32 %24, %struct.sockaddr* %47, i32* %8)
%66 = call i32 @FD_SET(i32 %65, i32* %6)
%67 = icmp slt i32 %59, %65
%68 = select i1 %67, i32 %65, i32 %59
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %65)
br label %79
70: ; preds = %62
%71 = call i32 @read(i32 %58, i8* %16, i32 200)
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %77
73: ; preds = %70
%74 = call i32 @FD_CLR(i32 %58, i32* %6)
%75 = call i32 @close(i32 %58)
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %58)
br label %79
77: ; preds = %70
%78 = call i32 @write(i32 %58, i8* %16, i32 %71)
br label %79
79: ; preds = %57, %73, %77, %64
%80 = phi i32 [ %68, %64 ], [ %59, %73 ], [ %59, %77 ], [ %59, %57 ]
%81 = add nuw nsw i32 %58, 1
%82 = icmp slt i32 %58, %80
br i1 %82, label %57, label %48
83: ; preds = %53
%84 = call i32 @close(i32 %24)
ret i32 0
}