#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 {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ addr_server;
typedef int /*<<< orphan*/ addr_client;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, unsigned int *);
unsigned short atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(unsigned short);
char *inet_ntoa(TYPE_1__);
scalar_t__ listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int sock_server, sock_client;
  struct sockaddr_in addr_server, addr_client;
  unsigned short port_server;
  unsigned int client_addr_len;
  int readlen;
  char buf[1500];
  if (argc != 2) {
    printf("Usage: a.out [SERVERPORT]\n");
    exit(1);
  }
  port_server = atoi(argv[1]);
  if ((sock_server = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
    printf("socket() error\n");
    exit(1);
  }
  memset(&addr_server, 0, sizeof(addr_server));
  addr_server.sin_family = AF_INET;
  addr_server.sin_addr.s_addr = htonl(INADDR_ANY);
  addr_server.sin_port = htons(port_server);
  if (bind(sock_server, (struct sockaddr *)&addr_server, sizeof(addr_server)) <
      0) {
    printf("bind() error\n");
    exit(1);
  }
  if (listen(sock_server, 5) < 0) {
    printf("listen() error\n");
    exit(1);
  }
  while (1) {
    client_addr_len = sizeof(addr_client);
    if ((sock_client = accept(sock_server, (struct sockaddr *)&addr_client,
                              &client_addr_len)) < 0) {
      printf("accept() error\n");
      exit(1);
    }
    printf("Connected %s\n", inet_ntoa(addr_client.sin_addr));
    while (1) {
      if ((readlen = recv(sock_client, buf, 1500, 0)) < 0) {
        printf("recv() error\n");
        exit(1);
      }
      if (readlen > 0) {
        if (send(sock_client, buf, readlen, 0) != readlen) {
          printf("send() error\n");
          exit(1);
        }
        buf[readlen] = '\0';
        printf("Echo %s to %s\n", buf, inet_ntoa(addr_client.sin_addr));
      } else if (readlen == 0) {
        printf("Disconnected %s\n", inet_ntoa(addr_client.sin_addr));
        close(sock_client);
        break;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x630,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     121b <main+0x3b>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <atoi@plt>
mov    %ax,-0x3a(%rbp)
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
mov    0x2d8c(%rip),%rax
mov    (%rax),%esi
mov    0x2d93(%rip),%rax
mov    (%rax),%edx
call   1100 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1270 <main+0x90>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2d61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d4d(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x28(%rbp)
movzwl -0x3a(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
cmp    $0x0,%rax
jge    12dc <main+0xfc>
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
cmp    $0x0,%rax
jge    130b <main+0x12b>
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1310 <main+0x130>
movl   $0xc,-0x40(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   10d0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    134b <main+0x16b>
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x38(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xcfc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
lea    -0x620(%rbp),%rsi
mov    $0x5dc,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x44(%rbp)
cmp    $0x0,%eax
jge    139e <main+0x1be>
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
cmpl   $0x0,-0x44(%rbp)
jle    141c <main+0x23c>
mov    -0x18(%rbp),%edi
lea    -0x620(%rbp),%rsi
mov    -0x44(%rbp),%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    -0x44(%rbp),%eax
je     13dd <main+0x1fd>
lea    0xca9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
movslq -0x44(%rbp),%rax
movb   $0x0,-0x620(%rbp,%rax,1)
lea    -0x620(%rbp),%rax
mov    %rax,-0x628(%rbp)
mov    -0x38(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    -0x628(%rbp),%rsi
mov    %rax,%rdx
lea    0xc73(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1451 <main+0x271>
cmpl   $0x0,-0x44(%rbp)
jne    144c <main+0x26c>
mov    -0x38(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xc5a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
call   10a0 <close@plt>
jmp    1456 <main+0x276>
jmp    1451 <main+0x271>
jmp    1364 <main+0x184>
jmp    1310 <main+0x130>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x618,%rsp
cmp    $0x2,%edi
jne    123e <main+0x4e>
mov    0x8(%rsi),%rdi
call   10f0 <atoi@plt>
mov    %eax,%ebx
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
mov    0x2da7(%rip),%rax
mov    (%rax),%esi
mov    0x2dae(%rip),%rax
mov    (%rax),%edx
call   1110 <socket@plt>
test   %eax,%eax
jns    1254 <main+0x64>
lea    0xe37(%rip),%rdi
jmp    1245 <main+0x55>
lea    0xe3d(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    %eax,%r12d
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   10a0 <memset@plt>
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %eax,0x20(%rsp)
movzwl %bx,%edi
call   1060 <htons@plt>
mov    %eax,0x24(%rsp)
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
test   %rax,%rax
jns    12b4 <main+0xc4>
lea    0xdb4(%rip),%rdi
jmp    1245 <main+0x55>
mov    %r12d,%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
test   %rax,%rax
jns    12d2 <main+0xe2>
lea    0xd8a(%rip),%rdi
jmp    1245 <main+0x55>
movl   $0xc,0xc(%rsp)
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r12d,%edi
call   10e0 <accept@plt>
test   %eax,%eax
jns    12fc <main+0x10c>
lea    0xd51(%rip),%rdi
jmp    1245 <main+0x55>
mov    %eax,%ebp
lea    0x30(%rsp),%rbx
lea    0xc(%rsp),%r14
lea    0xcff(%rip),%r15
jmp    135f <main+0x16f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%edi
call   1050 <inet_ntoa@plt>
lea    0xced(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
movl   $0xc,0xc(%rsp)
mov    %r12d,%edi
lea    0x10(%rsp),%rsi
mov    %r14,%rdx
call   10e0 <accept@plt>
mov    %eax,%ebp
test   %eax,%eax
js     12f0 <main+0x100>
mov    0x10(%rsp),%edi
call   1050 <inet_ntoa@plt>
lea    0xc91(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x5dc,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%r13d
test   %eax,%eax
js     13d4 <main+0x1e4>
test   %r13d,%r13d
je     1320 <main+0x130>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13d,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    %r13d,%eax
jne    13e0 <main+0x1f0>
mov    %r13d,%eax
movb   $0x0,0x30(%rsp,%rax,1)
mov    0x10(%rsp),%edi
call   1050 <inet_ntoa@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1380 <main+0x190>
lea    0xc60(%rip),%rdi
jmp    1245 <main+0x55>
lea    0xc47(%rip),%rdi
jmp    1245 <main+0x55>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [27 x i8] c"Usage: a.out [SERVERPORT]\0A\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.1 = [16 x i8] c"socket() error\0A\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str.2 = [14 x i8] c"bind() error\0A\00"
@.str.3 = [16 x i8] c"listen() error\0A\00"
@.str.4 = [16 x i8] c"accept() error\0A\00"
@.str.5 = [14 x i8] c"Connected %s\0A\00"
@.str.6 = [14 x i8] c"recv() error\0A\00"
@.str.7 = [14 x i8] c"send() error\0A\00"
@.str.8 = [15 x i8] c"Echo %s to %s\0A\00"
@.str.9 = [17 x i8] c"Disconnected %s\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 i16
%11 = alloca i32
%12 = alloca i32
%13 = alloca [1500 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 2
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call zeroext i16 @atoi(i8* %22)
store i16 %23, i16* %10
%24 = load i32, i32* @PF_INET
%25 = load i32, i32* @SOCK_STREAM
%26 = load i32, i32* @IPPROTO_TCP
%27 = call i32 @socket(i32 %24, i32 %25, i32 %26)
store i32 %27, i32* %6
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %19
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %19
%33 = call i32 @memset(%struct.sockaddr_in* %8, i32 0, i32 12)
%34 = load i32, i32* @AF_INET
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %34, i32* %35
%36 = load i32, i32* @INADDR_ANY
%37 = call i32 @htonl(i32 %36)
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%39 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %38, i32 0, i32 0
store i32 %37, i32* %39
%40 = load i16, i16* %10
%41 = call i32 @htons(i16 zeroext %40)
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
store i32 %41, i32* %42
%43 = load i32, i32* %6
%44 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%45 = call i64 @bind(i32 %43, %struct.sockaddr* %44, i32 12)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %32
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %32
%51 = load i32, i32* %6
%52 = call i64 @listen(i32 %51, i32 5)
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %50
br label %58
58: ; preds = %57, %116
store i32 12, i32* %11
%59 = load i32, i32* %6
%60 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%61 = call i32 @accept(i32 %59, %struct.sockaddr* %60, i32* %11)
store i32 %61, i32* %7
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %58
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %58
%67 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%68 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %67, i32 0, i32 0
%69 = load i32, i32* %68
%70 = call i8* @inet_ntoa(i32 %69)
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %66, %115
%73 = load i32, i32* %7
%74 = getelementptr inbounds [1500 x i8], [1500 x i8]* %13, i64 0, i64 0
%75 = call i32 @recv(i32 %73, i8* %74, i32 1500, i32 0)
store i32 %75, i32* %12
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %72
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %72
%81 = load i32, i32* %12
%82 = icmp sgt i32 %81, 0
br i1 %82, label %83, label %103
83: ; preds = %80
%84 = load i32, i32* %7
%85 = getelementptr inbounds [1500 x i8], [1500 x i8]* %13, i64 0, i64 0
%86 = load i32, i32* %12
%87 = call i32 @send(i32 %84, i8* %85, i32 %86, i32 0)
%88 = load i32, i32* %12
%89 = icmp ne i32 %87, %88
br i1 %89, label %90, label %93
90: ; preds = %83
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %83
%94 = load i32, i32* %12
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [1500 x i8], [1500 x i8]* %13, i64 0, i64 %95
store i8 0, i8* %96
%97 = getelementptr inbounds [1500 x i8], [1500 x i8]* %13, i64 0, i64 0
%98 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%99 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %98, i32 0, i32 0
%100 = load i32, i32* %99
%101 = call i8* @inet_ntoa(i32 %100)
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %97, i8* %101)
br label %115
103: ; preds = %80
%104 = load i32, i32* %12
%105 = icmp eq i32 %104, 0
br i1 %105, label %106, label %114
106: ; preds = %103
%107 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%108 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %107, i32 0, i32 0
%109 = load i32, i32* %108
%110 = call i8* @inet_ntoa(i32 %109)
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %110)
%112 = load i32, i32* %7
%113 = call i32 @close(i32 %112)
br label %116
114: ; preds = %103
br label %115
115: ; preds = %114, %93
br label %72
116: ; preds = %106
br label %58
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str.5 = [14 x i8] c"Connected %s\0A\00"
@.str.8 = [15 x i8] c"Echo %s to %s\0A\00"
@.str.9 = [17 x i8] c"Disconnected %s\0A\00"
@str = [13 x i8] c"send() error\00"
@str.10 = [13 x i8] c"recv() error\00"
@str.11 = [15 x i8] c"accept() error\00"
@str.12 = [15 x i8] c"listen() error\00"
@str.13 = [13 x i8] c"bind() error\00"
@str.14 = [15 x i8] c"socket() error\00"
@str.15 = [26 x i8] c"Usage: a.out [SERVERPORT]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca [1500 x i8]
%7 = bitcast %struct.sockaddr_in* %3 to i8*
%8 = bitcast %struct.sockaddr_in* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = getelementptr inbounds [1500 x i8], [1500 x i8]* %6, i64 0, i64 0
%11 = icmp eq i32 %0, 2
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.15, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call zeroext i16 @atoi(i8* %17)
%19 = load i32, i32* @PF_INET
%20 = load i32, i32* @SOCK_STREAM
%21 = load i32, i32* @IPPROTO_TCP
%22 = tail call i32 @socket(i32 %19, i32 %20, i32 %21)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %15
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0))
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %15
%28 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %29, i32* %30
%31 = load i32, i32* @INADDR_ANY
%32 = call i32 @htonl(i32 %31)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %32, i32* %33
%34 = call i32 @htons(i16 zeroext %18)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %34, i32* %35
%36 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%37 = call i64 @bind(i32 %22, %struct.sockaddr* %36, i32 12)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %27
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %27
%43 = call i64 @listen(i32 %22, i32 5)
%44 = icmp slt i64 %43, 0
br i1 %44, label %51, label %45
45: ; preds = %42
%46 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
store i32 12, i32* %5
%47 = call i32 @accept(i32 %22, %struct.sockaddr* %46, i32* %5)
%48 = icmp slt i32 %47, 0
br i1 %48, label %54, label %49
49: ; preds = %45
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
br label %57
51: ; preds = %42
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.12, i64 0, i64 0))
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %84, %45
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %49, %84
%58 = phi i32 [ %47, %49 ], [ %89, %84 ]
%59 = load i32, i32* %50
%60 = call i8* @inet_ntoa(i32 %59)
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %60)
%62 = call i32 @recv(i32 %58, i8* %10, i32 1500, i32 0)
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %57, %76
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.10, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %57, %76
%68 = phi i32 [ %82, %76 ], [ %62, %57 ]
%69 = icmp eq i32 %68, 0
br i1 %69, label %84, label %70
70: ; preds = %67
%71 = call i32 @send(i32 %58, i8* %10, i32 %68, i32 0)
%72 = icmp eq i32 %71, %68
br i1 %72, label %76, label %73
73: ; preds = %70
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %70
%77 = zext i32 %68 to i64
%78 = getelementptr inbounds [1500 x i8], [1500 x i8]* %6, i64 0, i64 %77
store i8 0, i8* %78
%79 = load i32, i32* %50
%80 = call i8* @inet_ntoa(i32 %79)
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %10, i8* %80)
%82 = call i32 @recv(i32 %58, i8* %10, i32 1500, i32 0)
%83 = icmp slt i32 %82, 0
br i1 %83, label %64, label %67
84: ; preds = %67
%85 = load i32, i32* %50
%86 = call i8* @inet_ntoa(i32 %85)
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %86)
%88 = call i32 @close(i32 %58)
store i32 12, i32* %5
%89 = call i32 @accept(i32 %22, %struct.sockaddr* %46, i32* %5)
%90 = icmp slt i32 %89, 0
br i1 %90, label %54, label %57
}