#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__ {
  void *s_addr;
};
struct sockaddr_in {
  void *sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ server_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int const, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int bind(int const, struct sockaddr *, int);
int close(int const);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
void *htons(int);
int listen(int const, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int recv(int const, char *, int const, int /*<<< orphan*/);
int send(int const, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(void) {
  const int server_sock = socket(AF_INET, SOCK_STREAM, 0);
  if (-1 == server_sock) {
    fprintf(stderr, "Error opening socket: %s\n", strerror(errno));
    exit(1);
  }
  struct sockaddr_in server_addr;
  memset(&server_addr, 0, sizeof(server_addr));
  server_addr.sin_family = AF_INET;
  server_addr.sin_addr.s_addr = htons(INADDR_ANY);
  server_addr.sin_port = htons(20000);
  if (bind(server_sock, (struct sockaddr *)&server_addr, sizeof(server_addr)) ==
      -1) {
    fprintf(stderr, "Error binding socket: %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  printf("Waiting for connections from clients...\n");
  if (listen(server_sock, 10) == -1) {
    fprintf(stderr, "Error listening on socket: %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  while (true) {
    const int client_sock = accept(server_sock, NULL, NULL);
    if (-1 == client_sock) {
      perror("Error opening socket.");
      exit(1);
    }
    printf("Connection established.\n");
    const int buffer_sz = 100;
    char buffer[buffer_sz];
    int bytes_received = -1;
    if ((bytes_received = recv(client_sock, buffer, buffer_sz, 0)) == -1) {
      perror("Failed to receive initial data from client");
      exit(EXIT_FAILURE);
    }
    while (bytes_received > 0) {
      if (send(client_sock, buffer, bytes_received, 0) != bytes_received) {
        perror("Failed to send data to client");
        exit(EXIT_FAILURE);
      }
      if ((bytes_received = recv(client_sock, buffer, buffer_sz, 0)) == -1) {
        perror("Failed to receive additional data from client");
        exit(EXIT_FAILURE);
      }
    }
    if (close(client_sock) == -1) {
      perror("Warning: Error closing client socket.\n");
    }
    printf("Connection closed.\n");
  }
  if (close(server_sock) == -1) {
    perror("Warning: Error closing server socket.\n");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    0x2dc9(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    $0xffffffff,%eax
cmp    -0x8(%rbp),%eax
jne    124f <main+0x6f>
mov    0x2db0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x38(%rbp),%edi
mov    %rax,%rdx
lea    0xdc0(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
call   1040 <htons@plt>
mov    %rax,-0x18(%rbp)
mov    $0x4e20,%edi
call   1040 <htons@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x18,%edx
call   10b0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12df <main+0xff>
mov    0x2d24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    %rax,%rdx
lea    0xd4e(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xd4e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0xa,%esi
call   10a0 <listen@plt>
cmp    $0xffffffff,%eax
jne    133b <main+0x15b>
mov    0x2cc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2cac(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x40(%rbp),%edi
mov    %rax,%rdx
lea    0xd35(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    1340 <main+0x160>
mov    -0x8(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10d0 <accept@plt>
mov    %eax,-0x24(%rbp)
mov    $0xffffffff,%eax
cmp    -0x24(%rbp),%eax
jne    1376 <main+0x196>
lea    0xd15(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xd15(%rip),%rdi
call   1060 <printf@plt>
movl   $0x64,-0x28(%rbp)
mov    %rsp,%rax
mov    %rax,-0x30(%rbp)
mov    %rsp,%rsi
add    $0xffffffffffffff90,%rsi
mov    %rsi,-0x48(%rbp)
mov    %rsi,%rsp
movl   $0xffffffff,-0x34(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
jne    13da <main+0x1fa>
lea    0xce4(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2be5(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    13df <main+0x1ff>
cmpl   $0x0,-0x34(%rbp)
jle    145b <main+0x27b>
mov    -0x48(%rbp),%rsi
mov    -0x24(%rbp),%edi
mov    -0x34(%rbp),%edx
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    -0x34(%rbp),%eax
je     141d <main+0x23d>
lea    0xccc(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2ba2(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x48(%rbp),%rsi
mov    -0x24(%rbp),%edi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
jne    1456 <main+0x276>
lea    0xcb1(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2b69(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    13df <main+0x1ff>
mov    -0x24(%rbp),%edi
call   1080 <close@plt>
cmp    $0xffffffff,%eax
jne    1478 <main+0x298>
lea    0xcaf(%rip),%rdi
call   10c0 <perror@plt>
lea    0xcca(%rip),%rdi
call   1060 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
jmp    1340 <main+0x160>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2df0(%rip),%rbx
mov    (%rbx),%edi
mov    0x2dc7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
cmp    $0xffffffff,%eax
jne    1241 <main+0x61>
mov    0x2dba(%rip),%rax
mov    (%rax),%ebx
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xdd3(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    %eax,%r13d
lea    -0x40(%rbp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    (%rbx),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
call   1050 <htons@plt>
mov    %rax,-0x38(%rbp)
mov    $0x4e20,%edi
call   1050 <htons@plt>
mov    %rax,-0x40(%rbp)
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x18,%edx
call   10b0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12b1 <main+0xd1>
mov    0x2d38(%rip),%rax
mov    (%rax),%ebx
mov    0x2d1f(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xd6b(%rip),%rsi
jmp    12ed <main+0x10d>
lea    0xe4f(%rip),%rdi
call   1040 <puts@plt>
mov    %r13d,%edi
mov    $0xa,%esi
call   10a0 <listen@plt>
cmp    $0xffffffff,%eax
jne    1305 <main+0x125>
mov    0x2cfa(%rip),%rax
mov    (%rax),%ebx
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xd47(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1090 <fprintf@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    %r13d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <accept@plt>
cmp    $0xffffffff,%eax
jne    132c <main+0x14c>
lea    0xd36(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    %eax,%ebx
jmp    1362 <main+0x182>
mov    %ebx,%edi
call   1080 <close@plt>
cmp    $0xffffffff,%eax
je     13d4 <main+0x1f4>
lea    0xe00(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rsp
mov    %r13d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <accept@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1316 <main+0x136>
lea    0xdc6(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%r12
mov    %rsp,%r15
add    $0xffffffffffffff90,%r15
mov    %r15,%rsp
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     13ff <main+0x21f>
mov    %eax,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %r14d,%r14d
jle    1330 <main+0x150>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    %r14d,%eax
jne    13e5 <main+0x205>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    13a0 <main+0x1c0>
jmp    13ee <main+0x20e>
lea    0xd05(%rip),%rdi
call   10c0 <perror@plt>
jmp    1340 <main+0x160>
lea    0xca8(%rip),%rdi
jmp    13f5 <main+0x215>
lea    0xcbd(%rip),%rdi
call   10c0 <perror@plt>
jmp    12f7 <main+0x117>
lea    0xc63(%rip),%rdi
jmp    13f5 <main+0x215>

LLVM IR (-O0):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"Error opening socket: %s\0A\00"
@errno = global i32 0
@INADDR_ANY = global i32 0
@.str.1 = [26 x i8] c"Error binding socket: %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [41 x i8] c"Waiting for connections from clients...\0A\00"
@.str.3 = [31 x i8] c"Error listening on socket: %s\0A\00"
@.str.4 = [22 x i8] c"Error opening socket.\00"
@.str.5 = [25 x i8] c"Connection established.\0A\00"
@.str.6 = [43 x i8] c"Failed to receive initial data from client\00"
@.str.7 = [30 x i8] c"Failed to send data to client\00"
@.str.8 = [46 x i8] c"Failed to receive additional data from client\00"
@.str.9 = [39 x i8] c"Warning: Error closing client socket.\0A\00"
@.str.10 = [20 x i8] c"Connection closed.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %1
%8 = load i32, i32* @AF_INET
%9 = load i32, i32* @SOCK_STREAM
%10 = call i32 @socket(i32 %8, i32 %9, i32 0)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = icmp eq i32 -1, %11
br i1 %12, label %13, label %19
13: ; preds = %0
%14 = load i32, i32* @stderr
%15 = load i32, i32* @errno
%16 = call i8* @strerror(i32 %15)
%17 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %0
%20 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 24)
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 2
store i32 %21, i32* %22
%23 = load i32, i32* @INADDR_ANY
%24 = call i8* @htons(i32 %23)
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %25, i32 0, i32 0
store i8* %24, i8** %26
%27 = call i8* @htons(i32 20000)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
store i8* %27, i8** %28
%29 = load i32, i32* %2
%30 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%31 = call i32 @bind(i32 %29, %struct.sockaddr* %30, i32 24)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %40
33: ; preds = %19
%34 = load i32, i32* @stderr
%35 = load i32, i32* @errno
%36 = call i8* @strerror(i32 %35)
%37 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %36)
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %19
%41 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%42 = load i32, i32* %2
%43 = call i32 @listen(i32 %42, i32 10)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %52
45: ; preds = %40
%46 = load i32, i32* @stderr
%47 = load i32, i32* @errno
%48 = call i8* @strerror(i32 %47)
%49 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %48)
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %40
br label %53
53: ; preds = %52, %101
%54 = load i32, i32* %2
%55 = call i32 @accept(i32 %54, i32* null, i32* null)
store i32 %55, i32* %4
%56 = load i32, i32* %4
%57 = icmp eq i32 -1, %56
br i1 %57, label %58, label %61
58: ; preds = %53
%59 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %53
%62 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
store i32 100, i32* %5
%63 = call i8* @llvm.stacksave()
store i8* %63, i8** %6
%64 = alloca i8, i64 100
store i32 -1, i32* %7
%65 = load i32, i32* %4
%66 = call i32 @recv(i32 %65, i8* %64, i32 100, i32 0)
store i32 %66, i32* %7
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %72
68: ; preds = %61
%69 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%70 = load i32, i32* @EXIT_FAILURE
%71 = call i32 @exit(i32 %70)
unreachable
72: ; preds = %61
br label %73
73: ; preds = %94, %72
%74 = load i32, i32* %7
%75 = icmp sgt i32 %74, 0
br i1 %75, label %76, label %95
76: ; preds = %73
%77 = load i32, i32* %4
%78 = load i32, i32* %7
%79 = call i32 @send(i32 %77, i8* %64, i32 %78, i32 0)
%80 = load i32, i32* %7
%81 = icmp ne i32 %79, %80
br i1 %81, label %82, label %86
82: ; preds = %76
%83 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%84 = load i32, i32* @EXIT_FAILURE
%85 = call i32 @exit(i32 %84)
unreachable
86: ; preds = %76
%87 = load i32, i32* %4
%88 = call i32 @recv(i32 %87, i8* %64, i32 100, i32 0)
store i32 %88, i32* %7
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %94
90: ; preds = %86
%91 = call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0))
%92 = load i32, i32* @EXIT_FAILURE
%93 = call i32 @exit(i32 %92)
unreachable
94: ; preds = %86
br label %73
95: ; preds = %73
%96 = load i32, i32* %4
%97 = call i32 @close(i32 %96)
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %101
99: ; preds = %95
%100 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0))
br label %101
101: ; preds = %99, %95
%102 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%103 = load i8*, i8** %6
br label %53
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"Error opening socket: %s\0A\00"
@errno = global i32 0
@INADDR_ANY = global i32 0
@.str.1 = [26 x i8] c"Error binding socket: %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [31 x i8] c"Error listening on socket: %s\0A\00"
@.str.4 = [22 x i8] c"Error opening socket.\00"
@.str.6 = [43 x i8] c"Failed to receive initial data from client\00"
@.str.7 = [30 x i8] c"Failed to send data to client\00"
@.str.8 = [46 x i8] c"Failed to receive additional data from client\00"
@.str.9 = [39 x i8] c"Warning: Error closing client socket.\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [40 x i8] c"Waiting for connections from clients...\00"
@str.11 = [24 x i8] c"Connection established.\00"
@str.12 = [19 x i8] c"Connection closed.\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = load i32, i32* @AF_INET
%3 = load i32, i32* @SOCK_STREAM
%4 = tail call i32 @socket(i32 %2, i32 %3, i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %12
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = tail call i8* @strerror(i32 %8)
%10 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = bitcast %struct.sockaddr_in* %1 to i8*
%14 = call i32 @memset(%struct.sockaddr_in* %1, i32 0, i32 24)
%15 = load i32, i32* @AF_INET
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %15, i32* %16
%17 = load i32, i32* @INADDR_ANY
%18 = call i8* @htons(i32 %17)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i8* %18, i8** %19
%20 = call i8* @htons(i32 20000)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i8* %20, i8** %21
%22 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%23 = call i32 @bind(i32 %4, %struct.sockaddr* %22, i32 24)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %32
25: ; preds = %12
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %12
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%34 = call i32 @listen(i32 %4, i32 10)
%35 = icmp eq i32 %34, -1
br i1 %35, label %39, label %36
36: ; preds = %32
%37 = call i32 @accept(i32 %4, i32* null, i32* null)
%38 = icmp eq i32 %37, -1
br i1 %38, label %46, label %49
39: ; preds = %32
%40 = load i32, i32* @stderr
%41 = load i32, i32* @errno
%42 = call i8* @strerror(i32 %41)
%43 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %83, %36
%47 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %36, %83
%50 = phi i32 [ %85, %83 ], [ %37, %36 ]
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0))
%52 = call i8* @llvm.stacksave()
%53 = alloca [100 x i8]
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %53, i64 0, i64 0
%55 = call i32 @recv(i32 %50, i8* %54, i32 100, i32 0)
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %61
57: ; preds = %49
%58 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%59 = load i32, i32* @EXIT_FAILURE
%60 = call i32 @exit(i32 %59)
unreachable
61: ; preds = %49, %71
%62 = phi i32 [ %72, %71 ], [ %55, %49 ]
%63 = icmp sgt i32 %62, 0
br i1 %63, label %64, label %78
64: ; preds = %61
%65 = call i32 @send(i32 %50, i8* %54, i32 %62, i32 0)
%66 = icmp eq i32 %65, %62
br i1 %66, label %71, label %67
67: ; preds = %64
%68 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %64
%72 = call i32 @recv(i32 %50, i8* %54, i32 100, i32 0)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %61
74: ; preds = %71
%75 = call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
%77 = call i32 @exit(i32 %76)
unreachable
78: ; preds = %61
%79 = call i32 @close(i32 %50)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0))
br label %83
83: ; preds = %81, %78
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.12, i64 0, i64 0))
%85 = call i32 @accept(i32 %4, i32* null, i32* null)
%86 = icmp eq i32 %85, -1
br i1 %86, label %46, label %49
}