#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;
};
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*/ server;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ F_SETFL;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ O_NONBLOCK;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
scalar_t__ bind(int, struct sockaddr_in *, int);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
scalar_t__ fcntl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ listen(int, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
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*/);
main() {
  int sock, length;
  struct sockaddr_in server;
  int msgsock;
  char buf[1024];
  int rval;
  fd_set ready;
  struct timeval to;
  sock = socket(AF_INET, SOCK_STREAM, 0);
  if (sock < 0) {
    perror("opening stream socket");
    exit(1);
  }
  printf("Socket  #%d\n", sock);
  int one = 1;
  if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) {
    perror("ioctl stream socket");
    exit(1);
  };
  server.sin_family = AF_INET;
  server.sin_addr.s_addr = INADDR_ANY;
  server.sin_port = htons(3333);
  if (bind(sock, &server, sizeof(server))) {
    perror("binding stream socket");
    exit(1);
  }
  printf("Socket has port #%d\n", ntohs(server.sin_port));
  listen(sock, 5);
  do {
    FD_ZERO(&ready);
    FD_SET(sock, &ready);
    to.tv_sec = 5;
    int ss = select(sock + 1, &ready, NULL, NULL, &to);
    printf("after select %d \n", ss);
    if (FD_ISSET(sock, &ready)) {
      printf("in loop\n");
      msgsock = accept(sock, (struct sockaddr *)0, (int *)0);
      if (msgsock == -1)
        perror("accept");
      else
        do {
          bzero(buf, sizeof(buf));
          if ((rval = read(msgsock, buf, 1024)) < 0)
            perror("reading stream message");
          else if (rval == 2)
            printf("Ending connection\n");
          else
            printf("%d-->%s\n", rval, buf);
        } while (rval > 2);
      close(msgsock);
    } else
      printf("Do something else\n");
  } while (1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    125e <main+0x4e>
lea    0xdb1(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x8(%rbp),%esi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x434(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2d45(%rip),%rax
mov    (%rax),%esi
mov    0x2d54(%rip),%rax
mov    (%rax),%edx
call   1030 <fcntl@plt>
cmp    $0x0,%rax
jge    12b3 <main+0xa3>
lea    0xd7f(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2d2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2d12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    $0xd05,%edi
call   1050 <htons@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
je     1309 <main+0xf9>
lea    0xd3d(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x18(%rbp),%edi
call   10c0 <ntohs@plt>
mov    %eax,%esi
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
lea    -0x428(%rbp),%rdi
call   1090 <FD_ZERO@plt>
mov    -0x8(%rbp),%edi
lea    -0x428(%rbp),%rsi
call   1120 <FD_SET@plt>
movl   $0x5,-0x430(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
lea    -0x428(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x430(%rbp),%r8
mov    %rcx,%rdx
call   10a0 <select@plt>
mov    %eax,-0x438(%rbp)
mov    -0x438(%rbp),%esi
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0x428(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     148f <main+0x27f>
lea    0xcc7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1100 <accept@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    13e1 <main+0x1d1>
lea    0xca6(%rip),%rdi
call   10e0 <perror@plt>
jmp    1482 <main+0x272>
jmp    13e6 <main+0x1d6>
lea    -0x420(%rbp),%rdi
mov    $0x400,%esi
call   10f0 <bzero@plt>
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1080 <read@plt>
mov    %eax,-0x424(%rbp)
cmp    $0x0,%eax
jge    142b <main+0x21b>
lea    0xc63(%rip),%rdi
call   10e0 <perror@plt>
jmp    146b <main+0x25b>
cmpl   $0x2,-0x424(%rbp)
jne    144b <main+0x23b>
lea    0xc5c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1466 <main+0x256>
mov    -0x424(%rbp),%esi
lea    -0x420(%rbp),%rdx
lea    0xc4f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    146b <main+0x25b>
jmp    1470 <main+0x260>
cmpl   $0x2,-0x424(%rbp)
jg     13e6 <main+0x1d6>
jmp    1482 <main+0x272>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
jmp    149d <main+0x28d>
lea    0xc21(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14a2 <main+0x292>
mov    $0x1,%al
test   $0x1,%al
jne    132e <main+0x11e>
jmp    14b1 <main+0x2a1>
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    0x2db0(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d7f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
test   %eax,%eax
js     141a <main+0x1fa>
mov    %eax,%r14d
lea    0xdba(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%esi
mov    0x2d6b(%rip),%rax
mov    (%rax),%edx
mov    %r14d,%edi
call   1040 <fcntl@plt>
test   %rax,%rax
js     1423 <main+0x203>
mov    (%rbx),%eax
mov    %eax,0x18(%rsp)
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    $0xd05,%edi
call   1060 <htons@plt>
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0xc,%edx
call   10e0 <bind@plt>
test   %rax,%rax
jne    142c <main+0x20c>
mov    0x10(%rsp),%edi
call   10d0 <ntohs@plt>
lea    0xd79(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14d,%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
mov    %r14d,%r12d
add    $0x1,%r12d
lea    0x1c(%rsp),%rbp
lea    0x8(%rsp),%rbx
lea    0x20(%rsp),%r13
lea    0xd8b(%rip),%r15
mov    %r14d,0xc(%rsp)
jmp    131c <main+0xfc>
xchg   %ax,%ax
lea    0xd84(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   10a0 <FD_ZERO@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1130 <FD_SET@plt>
movl   $0x5,0x8(%rsp)
mov    %r12d,%edi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   10b0 <select@plt>
lea    0xd12(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1310 <main+0xf0>
mov    %r12d,%ebx
lea    0xd3a(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1110 <accept@plt>
mov    %eax,%r12d
cmp    $0xffffffff,%eax
jne    13a0 <main+0x180>
lea    0xce1(%rip),%rdi
call   10f0 <perror@plt>
jmp    1400 <main+0x1e0>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x400,%esi
call   1100 <bzero@plt>
mov    %r12d,%edi
mov    %r13,%rsi
mov    $0x400,%edx
call   1090 <read@plt>
test   %eax,%eax
js     13e1 <main+0x1c1>
mov    %eax,%r14d
cmp    $0x2,%eax
je     13ef <main+0x1cf>
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0x2,%r14d
ja     13a0 <main+0x180>
jmp    1400 <main+0x1e0>
lea    0xc93(%rip),%rdi
call   10f0 <perror@plt>
jmp    1400 <main+0x1e0>
lea    0xcbf(%rip),%rdi
call   1030 <puts@plt>
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
call   1080 <close@plt>
mov    %ebx,%r12d
mov    0xc(%rsp),%r14d
lea    0x8(%rsp),%rbx
jmp    131c <main+0xfc>
lea    0xbdf(%rip),%rdi
jmp    1433 <main+0x213>
lea    0xbf9(%rip),%rdi
jmp    1433 <main+0x213>
lea    0xc04(%rip),%rdi
call   10f0 <perror@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 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [22 x i8] c"opening stream socket\00"
@.str.1 = [13 x i8] c"Socket #%d\0A\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.2 = [20 x i8] c"ioctl stream socket\00"
@INADDR_ANY = global i32 0
@.str.3 = [22 x i8] c"binding stream socket\00"
@.str.4 = [21 x i8] c"Socket has port #%d\0A\00"
@.str.5 = [18 x i8] c"after select %d \0A\00"
@.str.6 = [9 x i8] c"in loop\0A\00"
@.str.7 = [7 x i8] c"accept\00"
@.str.8 = [23 x i8] c"reading stream message\00"
@.str.9 = [19 x i8] c"Ending connection\0A\00"
@.str.10 = [9 x i8] c"%d-->%s\0A\00"
@.str.11 = [19 x i8] c"Do something else\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.timeval
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = load i32, i32* @AF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = call i32 @socket(i32 %12, i32 %13, i32 0)
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %0
%18 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %0
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %21)
store i32 1, i32* %10
%23 = load i32, i32* %2
%24 = load i32, i32* @F_SETFL
%25 = load i32, i32* @O_NONBLOCK
%26 = call i64 @fcntl(i32 %23, i32 %24, i32 %25)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %20
%29 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %20
%32 = load i32, i32* @AF_INET
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 2
store i32 %32, i32* %33
%34 = load i32, i32* @INADDR_ANY
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 1
%36 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %35, i32 0, i32 0
store i32 %34, i32* %36
%37 = call i32 @htons(i32 3333)
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
store i32 %37, i32* %38
%39 = load i32, i32* %2
%40 = call i64 @bind(i32 %39, %struct.sockaddr_in* %4, i32 12)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %31
%43 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %31
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
%47 = load i32, i32* %46
%48 = call i32 @ntohs(i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %2
%51 = call i32 @listen(i32 %50, i32 5)
br label %52
52: ; preds = %104, %45
%53 = call i32 @FD_ZERO(i32* %8)
%54 = load i32, i32* %2
%55 = call i32 @FD_SET(i32 %54, i32* %8)
%56 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
store i32 5, i32* %56
%57 = load i32, i32* %2
%58 = add nsw i32 %57, 1
%59 = call i32 @select(i32 %58, i32* %8, i32* null, i32* null, %struct.timeval* %9)
store i32 %59, i32* %11
%60 = load i32, i32* %11
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %2
%63 = call i64 @FD_ISSET(i32 %62, i32* %8)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %101
65: ; preds = %52
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%67 = load i32, i32* %2
%68 = call i32 @accept(i32 %67, %struct.sockaddr* null, i32* null)
store i32 %68, i32* %5
%69 = load i32, i32* %5
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %73
71: ; preds = %65
%72 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %98
73: ; preds = %65
br label %74
74: ; preds = %94, %73
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%76 = call i32 @bzero(i8* %75, i32 1024)
%77 = load i32, i32* %5
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%79 = call i32 @read(i32 %77, i8* %78, i32 1024)
store i32 %79, i32* %7
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %74
%82 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %93
83: ; preds = %74
%84 = load i32, i32* %7
%85 = icmp eq i32 %84, 2
br i1 %85, label %86, label %88
86: ; preds = %83
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
br label %92
88: ; preds = %83
%89 = load i32, i32* %7
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %89, i8* %90)
br label %92
92: ; preds = %88, %86
br label %93
93: ; preds = %92, %81
br label %94
94: ; preds = %93
%95 = load i32, i32* %7
%96 = icmp sgt i32 %95, 2
br i1 %96, label %74, label %97
97: ; preds = %94
br label %98
98: ; preds = %97, %71
%99 = load i32, i32* %5
%100 = call i32 @close(i32 %99)
br label %103
101: ; preds = %52
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
br label %103
103: ; preds = %101, %98
br label %104
104: ; preds = %103
br i1 true, label %52, label %105
105: ; preds = %104
%106 = load i32, i32* %1
ret i32 %106
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [22 x i8] c"opening stream socket\00"
@.str.1 = [13 x i8] c"Socket #%d\0A\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.2 = [20 x i8] c"ioctl stream socket\00"
@INADDR_ANY = global i32 0
@.str.3 = [22 x i8] c"binding stream socket\00"
@.str.4 = [21 x i8] c"Socket has port #%d\0A\00"
@.str.5 = [18 x i8] c"after select %d \0A\00"
@.str.7 = [7 x i8] c"accept\00"
@.str.8 = [23 x i8] c"reading stream message\00"
@.str.10 = [9 x i8] c"%d-->%s\0A\00"
@str = [18 x i8] c"Do something else\00"
@str.12 = [8 x i8] c"in loop\00"
@str.13 = [18 x i8] c"Ending connection\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca %struct.timeval
%5 = bitcast %struct.sockaddr_in* %1 to i8*
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%7 = bitcast i32* %3 to i8*
%8 = bitcast %struct.timeval* %4 to i8*
%9 = load i32, i32* @AF_INET
%10 = load i32, i32* @SOCK_STREAM
%11 = tail call i32 @socket(i32 %9, i32 %10, i32 0)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%18 = load i32, i32* @F_SETFL
%19 = load i32, i32* @O_NONBLOCK
%20 = tail call i64 @fcntl(i32 %11, i32 %18, i32 %19)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %16
%26 = load i32, i32* @AF_INET
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %26, i32* %27
%28 = load i32, i32* @INADDR_ANY
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %28, i32* %29
%30 = tail call i32 @htons(i32 3333)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %30, i32* %31
%32 = call i64 @bind(i32 %11, %struct.sockaddr_in* %1, i32 12)
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %25
%35 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %25
%38 = load i32, i32* %31
%39 = call i32 @ntohs(i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %39)
%41 = call i32 @listen(i32 %11, i32 5)
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%43 = add nuw nsw i32 %11, 1
br label %44
44: ; preds = %74, %37
%45 = call i32 @FD_ZERO(i32* %3)
%46 = call i32 @FD_SET(i32 %11, i32* %3)
store i32 5, i32* %42
%47 = call i32 @select(i32 %43, i32* %3, i32* null, i32* null, %struct.timeval* %4)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %47)
%49 = call i64 @FD_ISSET(i32 %11, i32* %3)
%50 = icmp eq i64 %49, 0
br i1 %50, label %72, label %51
51: ; preds = %44
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.12, i64 0, i64 0))
%53 = call i32 @accept(i32 %11, %struct.sockaddr* null, i32* null)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %70
57: ; preds = %51, %67
%58 = call i32 @bzero(i8* %6, i32 1024)
%59 = call i32 @read(i32 %53, i8* %6, i32 1024)
%60 = icmp slt i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %70
63: ; preds = %57
%64 = icmp eq i32 %59, 2
br i1 %64, label %65, label %67
65: ; preds = %63
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.13, i64 0, i64 0))
br label %70
67: ; preds = %63
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %59, i8* %6)
%69 = icmp ugt i32 %59, 2
br i1 %69, label %57, label %70
70: ; preds = %67, %65, %61, %55
%71 = call i32 @close(i32 %53)
br label %74
72: ; preds = %44
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %74
74: ; preds = %72, %70
br label %44
}