#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 {
  TYPE_1__ sin_addr;
  scalar_t__ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ server;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ client;
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*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
scalar_t__ getsockname(int, struct sockaddr *, int *);
char *inet_ntoa(TYPE_1__);
int /*<<< orphan*/ listen(int, int);
int ntohs(scalar_t__);
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*/);
int main() {
  int sock;
  socklen_t length;
  struct sockaddr_in server;
  int msgsock;
  char buf[1024];
  int rval;
  fd_set ready;
  struct timeval to;
  struct sockaddr_in client;
  char *client_addr;
  sock = socket(AF_INET, SOCK_STREAM, 0);
  if (sock < 0) {
    perror("opening stream socket");
    exit(1);
  }
  server.sin_family = AF_INET;
  server.sin_addr.s_addr = INADDR_ANY;
  server.sin_port = 0;
  if (bind(sock, (struct sockaddr *)&server, sizeof(server))) {
    perror("binding stream socket");
    exit(1);
  }
  length = sizeof(server);
  if (getsockname(sock, (struct sockaddr *)&server, &length)) {
    perror("getting socket name");
    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;
    to.tv_usec = 0;
    if (select(sock + 1, &ready, 0, 0, &to) < 0) {
      perror("select");
      continue;
    }
    if (FD_ISSET(sock, &ready)) {
      length = sizeof(client);
      msgsock = accept(sock, (struct sockaddr *)&client, &length);
      client_addr = inet_ntoa(client.sin_addr);
      printf("Client connection from %s!\n", client_addr);
      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 == 0)
            printf("Ending connection from %s.\n", client_addr);
          else
            printf("Client (%s) sent: %s", client_addr, buf);
        } while (rval > 0);
      close(msgsock);
    } else
      printf("Do something else\n");
  } while (1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    0x2d9e(%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   10d0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x18,%edx
call   10c0 <bind@plt>
cmp    $0x0,%rax
je     12af <main+0x9f>
lea    0xd76(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
movl   $0x18,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1100 <getsockname@plt>
cmp    $0x0,%rax
je     12e6 <main+0xd6>
lea    0xd55(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x20(%rbp),%rdi
call   10b0 <ntohs@plt>
mov    %eax,%esi
lea    0xd48(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0x5,%esi
call   10a0 <listen@plt>
lea    -0x438(%rbp),%rdi
call   1080 <FD_ZERO@plt>
mov    -0x8(%rbp),%edi
lea    -0x438(%rbp),%rsi
call   1120 <FD_SET@plt>
movl   $0x5,-0x448(%rbp)
movq   $0x0,-0x440(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
lea    -0x438(%rbp),%rsi
xor    %ecx,%ecx
lea    -0x448(%rbp),%r8
mov    %ecx,%edx
call   1090 <select@plt>
cmp    $0x0,%rax
jge    1374 <main+0x164>
lea    0xceb(%rip),%rdi
call   10d0 <perror@plt>
jmp    14b5 <main+0x2a5>
mov    -0x8(%rbp),%edi
lea    -0x438(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     14a2 <main+0x292>
movl   $0x18,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x460(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x460(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x468(%rbp)
mov    -0x468(%rbp),%rsi
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0xffffffff,-0x2c(%rbp)
jne    13ec <main+0x1dc>
lea    0xc96(%rip),%rdi
call   10d0 <perror@plt>
jmp    1495 <main+0x285>
jmp    13f1 <main+0x1e1>
lea    -0x430(%rbp),%rdi
mov    $0x400,%esi
call   10e0 <bzero@plt>
mov    -0x2c(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x400,%edx
call   1070 <read@plt>
mov    %eax,-0x434(%rbp)
cmp    $0x0,%eax
jge    1436 <main+0x226>
lea    0xc53(%rip),%rdi
call   10d0 <perror@plt>
jmp    147e <main+0x26e>
cmpl   $0x0,-0x434(%rbp)
jne    145d <main+0x24d>
mov    -0x468(%rbp),%rsi
lea    0xc45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1479 <main+0x269>
mov    -0x468(%rbp),%rsi
lea    -0x430(%rbp),%rdx
lea    0xc40(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    147e <main+0x26e>
jmp    1483 <main+0x273>
cmpl   $0x0,-0x434(%rbp)
jg     13f1 <main+0x1e1>
jmp    1495 <main+0x285>
mov    -0x2c(%rbp),%edi
call   1060 <close@plt>
jmp    14b0 <main+0x2a0>
lea    0xc1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14b5 <main+0x2a5>
mov    $0x1,%al
test   $0x1,%al
jne    130c <main+0xfc>
jmp    14c4 <main+0x2b4>
xor    %eax,%eax
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x458,%rsp
mov    0x2db0(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d8f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
test   %eax,%eax
js     1430 <main+0x210>
mov    %eax,%r14d
mov    (%rbx),%eax
mov    %eax,0x28(%rsp)
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x18(%rsp),%rsi
mov    %r14d,%edi
mov    $0x18,%edx
call   10d0 <bind@plt>
test   %rax,%rax
jne    1439 <main+0x219>
movl   $0x18,(%rsp)
lea    0x18(%rsp),%rsi
mov    %rsp,%rdx
mov    %r14d,%edi
call   1110 <getsockname@plt>
test   %rax,%rax
jne    1442 <main+0x222>
mov    0x20(%rsp),%rdi
call   10c0 <ntohs@plt>
lea    0xd83(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14d,%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
mov    %r14d,%r15d
add    $0x1,%r15d
lea    0x34(%rsp),%rbp
lea    0x8(%rsp),%rbx
lea    0x50(%rsp),%r13
lea    0xdc2(%rip),%r12
mov    %r14d,0x4(%rsp)
jmp    130c <main+0xec>
nopw   0x0(%rax,%rax,1)
lea    0xd4e(%rip),%rdi
call   10e0 <perror@plt>
mov    %rbp,%rdi
call   1090 <FD_ZERO@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1130 <FD_SET@plt>
movl   $0x5,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    %r15d,%edi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   10a0 <select@plt>
test   %rax,%rax
js     1300 <main+0xe0>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1040 <FD_ISSET@plt>
test   %rax,%rax
jne    1370 <main+0x150>
lea    0xd69(%rip),%rdi
call   1030 <puts@plt>
jmp    130c <main+0xec>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15d,%ebx
movl   $0x18,(%rsp)
mov    %r14d,%edi
lea    0x38(%rsp),%rsi
mov    %rsp,%rdx
call   1100 <accept@plt>
mov    %eax,%r15d
mov    0x38(%rsp),%edi
call   1050 <inet_ntoa@plt>
mov    %rax,%r14
lea    0xcbc(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0xffffffff,%r15d
jne    13c0 <main+0x1a0>
lea    0xcc1(%rip),%rdi
jmp    13fe <main+0x1de>
nopl   0x0(%rax)
mov    %r13,%rdi
mov    $0x400,%esi
call   10f0 <bzero@plt>
mov    %r15d,%edi
mov    %r13,%rsi
mov    $0x400,%edx
call   1080 <read@plt>
test   %eax,%eax
js     13f7 <main+0x1d7>
test   %eax,%eax
je     141d <main+0x1fd>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13c0 <main+0x1a0>
lea    0xc81(%rip),%rdi
call   10e0 <perror@plt>
mov    %r15d,%edi
call   1070 <close@plt>
mov    %ebx,%r15d
mov    0x4(%rsp),%r14d
lea    0x8(%rsp),%rbx
jmp    130c <main+0xec>
lea    0xc72(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1403 <main+0x1e3>
lea    0xbc9(%rip),%rdi
jmp    1449 <main+0x229>
lea    0xbd6(%rip),%rdi
jmp    1449 <main+0x229>
lea    0xbe3(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i64, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [22 x i8] c"opening stream socket\00"
@INADDR_ANY = global i32 0
@.str.1 = [22 x i8] c"binding stream socket\00"
@.str.2 = [20 x i8] c"getting socket name\00"
@.str.3 = [21 x i8] c"Socket has port #%d\0A\00"
@.str.4 = [7 x i8] c"select\00"
@.str.5 = [28 x i8] c"Client connection from %s!\0A\00"
@.str.6 = [7 x i8] c"accept\00"
@.str.7 = [23 x i8] c"reading stream message\00"
@.str.8 = [28 x i8] c"Ending connection from %s.\0A\00"
@.str.9 = [21 x i8] c"Client (%s) sent: %s\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 %struct.sockaddr_in
%11 = alloca i8*
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* @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 2
store i32 %21, i32* %22
%23 = load i32, i32* @INADDR_ANY
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
%25 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %24, i32 0, i32 0
store i32 %23, i32* %25
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 1
store i64 0, i64* %26
%27 = load i32, i32* %2
%28 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%29 = call i64 @bind(i32 %27, %struct.sockaddr* %28, i32 24)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %20
%32 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %20
store i32 24, i32* %3
%35 = load i32, i32* %2
%36 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%37 = call i64 @getsockname(i32 %35, %struct.sockaddr* %36, i32* %3)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %34
%40 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %34
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 1
%44 = load i64, i64* %43
%45 = call i32 @ntohs(i64 %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 = %111, %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 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
store i64 0, i64* %54
%55 = load i32, i32* %2
%56 = add nsw i32 %55, 1
%57 = call i64 @select(i32 %56, i32* %8, i32 0, i32 0, %struct.timeval* %9)
%58 = icmp slt i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %49
%60 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %111
61: ; preds = %49
%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 %108
65: ; preds = %61
store i32 24, i32* %3
%66 = load i32, i32* %2
%67 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%68 = call i32 @accept(i32 %66, %struct.sockaddr* %67, i32* %3)
store i32 %68, i32* %5
%69 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%70 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %69, i32 0, i32 0
%71 = load i32, i32* %70
%72 = call i8* @inet_ntoa(i32 %71)
store i8* %72, i8** %11
%73 = load i8*, i8** %11
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %73)
%75 = load i32, i32* %5
%76 = icmp eq i32 %75, -1
br i1 %76, label %77, label %79
77: ; preds = %65
%78 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %105
79: ; preds = %65
br label %80
80: ; preds = %101, %79
%81 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%82 = call i32 @bzero(i8* %81, i32 1024)
%83 = load i32, i32* %5
%84 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%85 = call i32 @read(i32 %83, i8* %84, i32 1024)
store i32 %85, i32* %7
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %80
%88 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %100
89: ; preds = %80
%90 = load i32, i32* %7
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %95
92: ; preds = %89
%93 = load i8*, i8** %11
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i8* %93)
br label %99
95: ; preds = %89
%96 = load i8*, i8** %11
%97 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* %96, i8* %97)
br label %99
99: ; preds = %95, %92
br label %100
100: ; preds = %99, %87
br label %101
101: ; preds = %100
%102 = load i32, i32* %7
%103 = icmp sgt i32 %102, 0
br i1 %103, label %80, label %104
104: ; preds = %101
br label %105
105: ; preds = %104, %77
%106 = load i32, i32* %5
%107 = call i32 @close(i32 %106)
br label %110
108: ; preds = %61
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %110
110: ; preds = %108, %105
br label %111
111: ; preds = %110, %59
br i1 true, label %49, label %112
112: ; preds = %111
ret i32 0
}

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