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

/* 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 FD_SETSIZE;
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  int listen_sock, client_sock, ret, nready;
  int client[FD_SETSIZE];
  int max_fd;
  ssize_t n;
  char buf[16];
  socklen_t clilen;
  fd_set allset, rset;
  struct sockaddr_in cliaddr, __me;
  listen_sock = socket(AF_INET, SOCK_STREAM, 0);
  if (listen_sock < 0) {
    perror("Error opening socket");
    return listen_sock;
  }
  memset(&__me, 0, sizeof(__me));
  __me.sin_family = AF_INET;
  __me.sin_addr.s_addr = htonl(INADDR_ANY);
  __me.sin_port = htons(16971);
  ret = bind(listen_sock, (struct sockaddr *)&__me, sizeof(__me));
  if (ret < 0) {
    perror("Error binding");
    return ret;
  }
  ret = listen(listen_sock, 5);
  if (ret < 0) {
    perror("Error on listen");
    return ret;
  }
  FD_ZERO(&allset);
  FD_SET(listen_sock, &allset);
  printf("\n listen fd = %d", listen_sock);
  clilen = sizeof(struct sockaddr);
  max_fd = listen_sock;
  while (1) {
    rset = allset;
    printf("\n Wait for connection\n");
    nready = select(max_fd + 1, &rset, NULL, NULL, NULL);
    printf("\n Connection in progress on nready = %d", nready);
    if (FD_ISSET(listen_sock, &rset)) {
      client_sock = accept(listen_sock, (struct sockaddr *)&cliaddr, &clilen);
      printf("\nAccepted connection %d", client_sock);
      FD_SET(client_sock, &allset);
      if (client_sock > max_fd)
        max_fd = client_sock;
    }
    n = read(client_sock, buf, 16);
    printf("\nSocket read %d characters", (int)n);
    if (n == 0) {
      FD_CLR(client_sock, &allset);
      close(client_sock);
    }
  }
  close(listen_sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
mov    0x2d9a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    126a <main+0x6a>
lea    0xdad(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x7c(%rbp)
jmp    143c <main+0x23c>
lea    -0x78(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0x74(%rbp)
mov    $0x424b,%edi
call   1040 <htons@plt>
mov    %eax,-0x78(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x78(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    12e0 <main+0xe0>
lea    0xd4c(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x7c(%rbp)
jmp    143c <main+0x23c>
mov    -0x8(%rbp),%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1318 <main+0x118>
lea    0xd22(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x7c(%rbp)
jmp    143c <main+0x23c>
lea    -0x58(%rbp),%rdi
call   10a0 <FD_ZERO@plt>
mov    -0x8(%rbp),%edi
lea    -0x58(%rbp),%rsi
call   1110 <FD_SET@plt>
mov    -0x8(%rbp),%esi
lea    0xcfc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x4,-0x54(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1350 <main+0x150>
mov    -0x58(%rbp),%eax
mov    %eax,-0x5c(%rbp)
lea    0xce7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%edi
add    $0x1,%edi
lea    -0x5c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10b0 <select@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xcd0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0x5c(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     13ef <main+0x1ef>
mov    -0x8(%rbp),%edi
lea    -0x68(%rbp),%rsi
lea    -0x54(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xcbe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
lea    -0x58(%rbp),%rsi
call   1110 <FD_SET@plt>
mov    -0xc(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jle    13ea <main+0x1ea>
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    13ef <main+0x1ef>
mov    -0xc(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x10,%edx
call   1090 <read@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,%esi
lea    0xc8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x38(%rbp)
jne    1437 <main+0x237>
mov    -0xc(%rbp),%edi
lea    -0x58(%rbp),%rsi
call   1100 <FD_CLR@plt>
mov    -0xc(%rbp),%edi
call   1080 <close@plt>
jmp    134b <main+0x14b>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    0x2dc3(%rip),%rbx
mov    (%rbx),%edi
mov    0x2da2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,%ebp
test   %eax,%eax
js     13b3 <main+0x1a3>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    (%rbx),%eax
mov    %eax,0x18(%rsp)
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,0x14(%rsp)
mov    $0x424b,%edi
call   1050 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
test   %eax,%eax
js     13c1 <main+0x1b1>
mov    %ebp,%edi
mov    $0x5,%esi
call   10d0 <listen@plt>
test   %eax,%eax
js     13cc <main+0x1bc>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   10b0 <FD_ZERO@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1120 <FD_SET@plt>
lea    0xd6f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movl   $0x4,0xc(%rsp)
lea    0x8(%rsp),%rbx
lea    0xda3(%rip),%r14
mov    %ebp,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x4(%rsp),%eax
mov    %eax,0x8(%rsp)
lea    0xda0(%rip),%rdi
call   1030 <puts@plt>
lea    0x1(%r13),%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10c0 <select@plt>
lea    0xd26(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <FD_ISSET@plt>
test   %rax,%rax
je     136e <main+0x15e>
mov    %ebp,%edi
lea    0x20(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1100 <accept@plt>
mov    %eax,%r15d
lea    0xd1b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15d,%edi
lea    0x4(%rsp),%rsi
call   1120 <FD_SET@plt>
cmp    %r13d,%r15d
cmovg  %r15d,%r13d
mov    %r15d,%edi
lea    0x30(%rsp),%rsi
mov    $0x10,%edx
call   10a0 <read@plt>
mov    %rax,%r12
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r12,%r12
jne    12f0 <main+0xe0>
mov    %r15d,%edi
lea    0x4(%rsp),%rsi
call   1110 <FD_CLR@plt>
mov    %r15d,%edi
call   1090 <close@plt>
jmp    12f0 <main+0xe0>
lea    0xc46(%rip),%rdi
call   10f0 <perror@plt>
jmp    13dc <main+0x1cc>
mov    %eax,%ebx
lea    0xc4b(%rip),%rdi
jmp    13d5 <main+0x1c5>
mov    %eax,%ebx
lea    0xc4e(%rip),%rdi
call   10f0 <perror@plt>
mov    %ebx,%ebp
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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
@.str = [21 x i8] c"Error opening socket\00"
@INADDR_ANY = global i32 0
@.str.1 = [14 x i8] c"Error binding\00"
@.str.2 = [16 x i8] c"Error on listen\00"
@.str.3 = [17 x i8] c"\0A listen fd = %d\00"
@.str.4 = [23 x i8] c"\0A Wait for connection\0A\00"
@.str.5 = [40 x i8] c"\0A Connection in progress on nready = %d\00"
@.str.6 = [24 x i8] c"\0AAccepted connection %d\00"
@.str.7 = [27 x i8] c"\0ASocket read %d characters\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i64
%10 = alloca [16 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.sockaddr_in
%15 = alloca %struct.sockaddr_in
%16 = alloca i32
store i32 0, i32* %1
%17 = load i32, i32* @FD_SETSIZE
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %6
%20 = alloca i32, i64 %18
store i64 %18, i64* %7
%21 = load i32, i32* @AF_INET
%22 = load i32, i32* @SOCK_STREAM
%23 = call i32 @socket(i32 %21, i32 %22, i32 0)
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %0
%27 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%28 = load i32, i32* %2
store i32 %28, i32* %1
store i32 1, i32* %16
br label %103
29: ; preds = %0
%30 = call i32 @memset(%struct.sockaddr_in* %15, i32 0, i32 12)
%31 = load i32, i32* @AF_INET
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 2
store i32 %31, i32* %32
%33 = load i32, i32* @INADDR_ANY
%34 = call i32 @htonl(i32 %33)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, 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 16971)
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
store i32 %37, i32* %38
%39 = load i32, i32* %2
%40 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
%41 = call i32 @bind(i32 %39, %struct.sockaddr* %40, i32 12)
store i32 %41, i32* %4
%42 = load i32, i32* %4
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %29
%45 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%46 = load i32, i32* %4
store i32 %46, i32* %1
store i32 1, i32* %16
br label %103
47: ; preds = %29
%48 = load i32, i32* %2
%49 = call i32 @listen(i32 %48, i32 5)
store i32 %49, i32* %4
%50 = load i32, i32* %4
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %47
%53 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%54 = load i32, i32* %4
store i32 %54, i32* %1
store i32 1, i32* %16
br label %103
55: ; preds = %47
%56 = call i32 @FD_ZERO(i32* %12)
%57 = load i32, i32* %2
%58 = call i32 @FD_SET(i32 %57, i32* %12)
%59 = load i32, i32* %2
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %59)
store i32 4, i32* %11
%61 = load i32, i32* %2
store i32 %61, i32* %8
br label %62
62: ; preds = %102, %55
br label %63
63: ; preds = %62
%64 = load i32, i32* %12
store i32 %64, i32* %13
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%66 = load i32, i32* %8
%67 = add nsw i32 %66, 1
%68 = call i32 @select(i32 %67, i32* %13, i32* null, i32* null, i32* null)
store i32 %68, i32* %5
%69 = load i32, i32* %5
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i32 %69)
%71 = load i32, i32* %2
%72 = call i64 @FD_ISSET(i32 %71, i32* %13)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %88
74: ; preds = %63
%75 = load i32, i32* %2
%76 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr*
%77 = call i32 @accept(i32 %75, %struct.sockaddr* %76, i32* %11)
store i32 %77, i32* %3
%78 = load i32, i32* %3
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %78)
%80 = load i32, i32* %3
%81 = call i32 @FD_SET(i32 %80, i32* %12)
%82 = load i32, i32* %3
%83 = load i32, i32* %8
%84 = icmp sgt i32 %82, %83
br i1 %84, label %85, label %87
85: ; preds = %74
%86 = load i32, i32* %3
store i32 %86, i32* %8
br label %87
87: ; preds = %85, %74
br label %88
88: ; preds = %87, %63
%89 = load i32, i32* %3
%90 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%91 = call i64 @read(i32 %89, i8* %90, i32 16)
store i64 %91, i64* %9
%92 = load i64, i64* %9
%93 = trunc i64 %92 to i32
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %93)
%95 = load i64, i64* %9
%96 = icmp eq i64 %95, 0
br i1 %96, label %97, label %102
97: ; preds = %88
%98 = load i32, i32* %3
%99 = call i32 @FD_CLR(i32 %98, i32* %12)
%100 = load i32, i32* %3
%101 = call i32 @close(i32 %100)
br label %102
102: ; preds = %97, %88
br label %62
103: ; preds = %52, %44, %26
%104 = load i8*, i8** %6
%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.sockaddr = type { i32 }
@FD_SETSIZE = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [21 x i8] c"Error opening socket\00"
@INADDR_ANY = global i32 0
@.str.1 = [14 x i8] c"Error binding\00"
@.str.2 = [16 x i8] c"Error on listen\00"
@.str.3 = [17 x i8] c"\0A listen fd = %d\00"
@.str.5 = [40 x i8] c"\0A Connection in progress on nready = %d\00"
@.str.6 = [24 x i8] c"\0AAccepted connection %d\00"
@.str.7 = [27 x i8] c"\0ASocket read %d characters\00"
@str = [22 x i8] c"\0A Wait for connection\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sockaddr_in
%6 = alloca %struct.sockaddr_in
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast %struct.sockaddr_in* %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 %19
17: ; preds = %0
%18 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %70
19: ; preds = %0
%20 = call i32 @memset(%struct.sockaddr_in* %6, i32 0, i32 12)
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
store i32 %21, i32* %22
%23 = load i32, i32* @INADDR_ANY
%24 = call i32 @htonl(i32 %23)
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1, i32 0
store i32 %24, i32* %25
%26 = call i32 @htons(i32 16971)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
store i32 %26, i32* %27
%28 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%29 = call i32 @bind(i32 %15, %struct.sockaddr* %28, i32 12)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %19
%32 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %70
33: ; preds = %19
%34 = call i32 @listen(i32 %15, i32 5)
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %70
38: ; preds = %33
%39 = call i32 @FD_ZERO(i32* %3)
%40 = call i32 @FD_SET(i32 %15, i32* %3)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %15)
store i32 4, i32* %2
%42 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
br label %43
43: ; preds = %69, %38
%44 = phi i32 [ undef, %38 ], [ %60, %69 ]
%45 = phi i32 [ %15, %38 ], [ %61, %69 ]
%46 = load i32, i32* %3
store i32 %46, i32* %4
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%48 = add nsw i32 %45, 1
%49 = call i32 @select(i32 %48, i32* %4, i32* null, i32* null, i32* null)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i32 %49)
%51 = call i64 @FD_ISSET(i32 %15, i32* %4)
%52 = icmp eq i64 %51, 0
br i1 %52, label %59, label %53
53: ; preds = %43
%54 = call i32 @accept(i32 %15, %struct.sockaddr* %42, i32* %2)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %54)
%56 = call i32 @FD_SET(i32 %54, i32* %3)
%57 = icmp sgt i32 %54, %45
%58 = select i1 %57, i32 %54, i32 %45
br label %59
59: ; preds = %53, %43
%60 = phi i32 [ %44, %43 ], [ %54, %53 ]
%61 = phi i32 [ %45, %43 ], [ %58, %53 ]
%62 = call i64 @read(i32 %60, i8* %7, i32 16)
%63 = trunc i64 %62 to i32
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %63)
%65 = icmp eq i64 %62, 0
br i1 %65, label %66, label %69
66: ; preds = %59
%67 = call i32 @FD_CLR(i32 %60, i32* %3)
%68 = call i32 @close(i32 %60)
br label %69
69: ; preds = %66, %59
br label %43
70: ; preds = %36, %31, %17
%71 = phi i32 [ %15, %17 ], [ %29, %31 ], [ %34, %36 ]
ret i32 %71
}