#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);
scalar_t__ 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);
  }
  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;
    if (select(sock + 1, &ready, 0, 0, &to) < 0) {
      perror("select");
      continue;
    }
    printf("after select\n");
    if (FD_ISSET(sock, &ready)) {
      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>
movl   $0x1,-0x434(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2d56(%rip),%rax
mov    (%rax),%esi
mov    0x2d65(%rip),%rax
mov    (%rax),%edx
call   1030 <fcntl@plt>
cmp    $0x0,%rax
jge    12a2 <main+0x92>
lea    0xd83(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2d3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2d23(%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     12f8 <main+0xe8>
lea    0xd41(%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    0xd37(%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    %ecx,%ecx
lea    -0x430(%rbp),%r8
mov    %ecx,%edx
call   10a0 <select@plt>
cmp    $0x0,%rax
jge    137a <main+0x16a>
lea    0xce5(%rip),%rdi
call   10e0 <perror@plt>
jmp    148f <main+0x27f>
lea    0xcdb(%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     147c <main+0x26c>
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    13ce <main+0x1be>
lea    0xca6(%rip),%rdi
call   10e0 <perror@plt>
jmp    146f <main+0x25f>
jmp    13d3 <main+0x1c3>
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    1418 <main+0x208>
lea    0xc63(%rip),%rdi
call   10e0 <perror@plt>
jmp    1458 <main+0x248>
cmpl   $0x2,-0x424(%rbp)
jne    1438 <main+0x228>
lea    0xc5c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1453 <main+0x243>
mov    -0x424(%rbp),%esi
lea    -0x420(%rbp),%rdx
lea    0xc4f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1458 <main+0x248>
jmp    145d <main+0x24d>
cmpl   $0x2,-0x424(%rbp)
jg     13d3 <main+0x1c3>
jmp    146f <main+0x25f>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
jmp    148a <main+0x27a>
lea    0xc21(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    148f <main+0x27f>
mov    $0x1,%al
test   $0x1,%al
jne    131d <main+0x10d>
jmp    149e <main+0x28e>
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
mov    0x2d6c(%rip),%rax
mov    (%rax),%esi
mov    0x2d7b(%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    0x2d53(%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    0xd7c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14d,%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
mov    %r14d,%r15d
add    $0x1,%r15d
lea    0x1c(%rsp),%rbp
lea    0x8(%rsp),%rbx
lea    0x20(%rsp),%r12
lea    0xd7c(%rip),%r13
mov    %r14d,0xc(%rsp)
jmp    130c <main+0xec>
xchg   %ax,%ax
lea    0xd7b(%rip),%rdi
call   10f0 <perror@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    %r15d,%edi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   10b0 <select@plt>
test   %rax,%rax
js     1300 <main+0xe0>
lea    0xd37(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
jne    1370 <main+0x150>
lea    0xd28(%rip),%rdi
call   1030 <puts@plt>
jmp    130c <main+0xec>
nopl   0x0(%rax,%rax,1)
mov    %r15d,%ebx
mov    %r14d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1110 <accept@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    13a0 <main+0x180>
lea    0xcc7(%rip),%rdi
call   10f0 <perror@plt>
jmp    1400 <main+0x1e0>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    $0x400,%esi
call   1100 <bzero@plt>
mov    %r15d,%edi
mov    %r12,%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    %r13,%rdi
mov    %r14d,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0x2,%r14d
ja     13a0 <main+0x180>
jmp    1400 <main+0x1e0>
lea    0xc74(%rip),%rdi
call   10f0 <perror@plt>
jmp    1400 <main+0x1e0>
lea    0xca5(%rip),%rdi
call   1030 <puts@plt>
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1080 <close@plt>
mov    %ebx,%r15d
mov    0xc(%rsp),%r14d
lea    0x8(%rsp),%rbx
jmp    130c <main+0xec>
lea    0xbdf(%rip),%rdi
jmp    1433 <main+0x213>
lea    0xbec(%rip),%rdi
jmp    1433 <main+0x213>
lea    0xbf7(%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"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [20 x i8] c"ioctl stream socket\00"
@INADDR_ANY = global i32 0
@.str.2 = [22 x i8] c"binding stream socket\00"
@.str.3 = [21 x i8] c"Socket has port #%d\0A\00"
@.str.4 = [7 x i8] c"select\00"
@.str.5 = [14 x i8] c"after select\0A\00"
@.str.6 = [7 x i8] c"accept\00"
@.str.7 = [23 x i8] c"reading stream message\00"
@.str.8 = [19 x i8] c"Ending connection\0A\00"
@.str.9 = [9 x i8] c"%d-->%s\0A\00"
@.str.10 = [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
store i32 0, i32* %1
%11 = load i32, i32* @AF_INET
%12 = load i32, i32* @SOCK_STREAM
%13 = call i32 @socket(i32 %11, i32 %12, i32 0)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %0
%17 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %0
store i32 1, i32* %10
%20 = load i32, i32* %2
%21 = load i32, i32* @F_SETFL
%22 = load i32, i32* @O_NONBLOCK
%23 = call i64 @fcntl(i32 %20, i32 %21, i32 %22)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %19
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 2
store i32 %29, i32* %30
%31 = load i32, i32* @INADDR_ANY
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, 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 3333)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
store i32 %34, i32* %35
%36 = load i32, i32* %2
%37 = call i64 @bind(i32 %36, %struct.sockaddr_in* %4, i32 12)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %28
%40 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %28
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
%44 = load i32, i32* %43
%45 = call i32 @ntohs(i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = load i32, i32* %2
%48 = call i32 @listen(i32 %47, i32 5)
br label %49
49: ; preds = %103, %42
%50 = call i32 @FD_ZERO(i32* %8)
%51 = load i32, i32* %2
%52 = call i32 @FD_SET(i32 %51, i32* %8)
%53 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
store i32 5, i32* %53
%54 = load i32, i32* %2
%55 = add nsw i32 %54, 1
%56 = call i64 @select(i32 %55, i32* %8, i32 0, i32 0, %struct.timeval* %9)
%57 = icmp slt i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %49
%59 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %103
60: ; preds = %49
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%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 %100
65: ; preds = %60
%66 = load i32, i32* %2
%67 = call i32 @accept(i32 %66, %struct.sockaddr* null, i32* null)
store i32 %67, i32* %5
%68 = load i32, i32* %5
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %72
70: ; preds = %65
%71 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %97
72: ; preds = %65
br label %73
73: ; preds = %93, %72
%74 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%75 = call i32 @bzero(i8* %74, i32 1024)
%76 = load i32, i32* %5
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%78 = call i32 @read(i32 %76, i8* %77, i32 1024)
store i32 %78, i32* %7
%79 = icmp slt i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %73
%81 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %92
82: ; preds = %73
%83 = load i32, i32* %7
%84 = icmp eq i32 %83, 2
br i1 %84, label %85, label %87
85: ; preds = %82
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %91
87: ; preds = %82
%88 = load i32, i32* %7
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %88, i8* %89)
br label %91
91: ; preds = %87, %85
br label %92
92: ; preds = %91, %80
br label %93
93: ; preds = %92
%94 = load i32, i32* %7
%95 = icmp sgt i32 %94, 2
br i1 %95, label %73, label %96
96: ; preds = %93
br label %97
97: ; preds = %96, %70
%98 = load i32, i32* %5
%99 = call i32 @close(i32 %98)
br label %102
100: ; preds = %60
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %102
102: ; preds = %100, %97
br label %103
103: ; preds = %102, %58
br i1 true, label %49, label %104
104: ; preds = %103
%105 = load i32, i32* %1
ret i32 %105
}

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