#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 socklen_t;
typedef int /*<<< orphan*/ client;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int listen(int, int);
int /*<<< orphan*/ printf(char *, int);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc < 2) {
    {
      fprintf(stderr, "Usage: %s [port]\n", argv[0]);
      fflush(stderr);
      exit(1);
    };
  }
  int port = atoi(argv[1]);
  int server_fd, client_fd, err;
  struct sockaddr_in server, client;
  char buf[1024];
  server_fd = socket(AF_INET, SOCK_STREAM, 0);
  if (server_fd < 0) {
    fprintf(stderr, "Could not create socket!\n");
    fflush(stderr);
    exit(1);
  };
  server.sin_family = AF_INET;
  server.sin_port = htons(port);
  server.sin_addr.s_addr = htonl(INADDR_ANY);
  int opt_val = 1;
  setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &opt_val, sizeof opt_val);
  err = bind(server_fd, (struct sockaddr *)&server, sizeof server);
  if (err < 0) {
    fprintf(stderr, "Could not bind socket!\n");
    fflush(stderr);
    exit(1);
  };
  err = listen(server_fd, 128);
  if (err < 0) {
    fprintf(stderr, "Could not listen on socket!\n");
    fflush(stderr);
    exit(1);
  };
  printf("Server is listening on %d\n", port);
  while (1) {
    socklen_t client_len = sizeof(client);
    client_fd = accept(server_fd, (struct sockaddr *)&client_fd, &client_len);
    if (client_fd < 0) {
      fprintf(stderr, "Could not establish new connection\n");
      fflush(stderr);
      exit(1);
    };
    while (1) {
      int read = recv(client_fd, buf, 1024, 0);
      if (!read)
        break;
      if (read < 0) {
        fprintf(stderr, "Client read failed!\n");
        fflush(stderr);
        exit(1);
      };
      err = send(client_fd, buf, read, 0);
      if (err < 0) {
        fprintf(stderr, "Client write failed!\n");
        fflush(stderr);
        exit(1);
      };
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1239 <main+0x59>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    129e <main+0xbe>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
lea    0xd93(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2d3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x444(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2d0e(%rip),%rax
mov    (%rax),%esi
mov    0x2cd5(%rip),%rax
mov    (%rax),%edx
lea    -0x444(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    -0x18(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1344 <main+0x164>
mov    0x2cac(%rip),%rax
mov    (%rax),%edi
lea    0xd07(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c95(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x18(%rbp),%edi
mov    $0x80,%esi
call   10b0 <listen@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    138d <main+0x1ad>
mov    0x2c63(%rip),%rax
mov    (%rax),%edi
lea    0xcd6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c4c(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x14(%rbp),%esi
lea    0xcca(%rip),%rdi
call   1070 <printf@plt>
movl   $0xc,-0x448(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x1c(%rbp),%rsi
lea    -0x448(%rbp),%rdx
call   10d0 <accept@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    13f5 <main+0x215>
mov    0x2bfb(%rip),%rax
mov    (%rax),%edi
lea    0xca6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2be4(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    13fa <main+0x21a>
mov    -0x1c(%rbp),%edi
lea    -0x440(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x44c(%rbp)
cmpl   $0x0,-0x44c(%rbp)
jne    1428 <main+0x248>
jmp    14bc <main+0x2dc>
cmpl   $0x0,-0x44c(%rbp)
jge    1464 <main+0x284>
mov    0x2b8c(%rip),%rax
mov    (%rax),%edi
lea    0xc5b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2b75(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x1c(%rbp),%edi
lea    -0x440(%rbp),%rsi
mov    -0x44c(%rbp),%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    14b7 <main+0x2d7>
mov    0x2b39(%rip),%rax
mov    (%rax),%edi
lea    0xc1d(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2b22(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    13fa <main+0x21a>
jmp    139c <main+0x1bc>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x428,%rsp
cmp    $0x1,%edi
jg     1211 <main+0x31>
mov    0x2dcf(%rip),%rbx
mov    (%rbx),%edi
mov    (%rsi),%rdx
lea    0xdfb(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    13ca <main+0x1ea>
mov    0x8(%rsi),%rdi
call   10e0 <atoi@plt>
mov    %eax,%r14d
mov    0x2dbc(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d92(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
test   %eax,%eax
jns    1250 <main+0x70>
mov    0x2d86(%rip),%rbx
mov    (%rbx),%edi
lea    0xdc7(%rip),%rsi
jmp    13c3 <main+0x1e3>
mov    %eax,%ebx
mov    0x0(%rbp),%eax
mov    %eax,0x18(%rsp)
mov    %r14d,%edi
call   1050 <htons@plt>
mov    %eax,0x14(%rsp)
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0x10(%rsp)
movl   $0x1,0xc(%rsp)
mov    0x2d62(%rip),%rax
mov    (%rax),%esi
mov    0x2d29(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0xc,%edx
call   10c0 <bind@plt>
test   %eax,%eax
jns    12cd <main+0xed>
mov    0x2d09(%rip),%rbx
mov    (%rbx),%edi
lea    0xd64(%rip),%rsi
jmp    13c3 <main+0x1e3>
mov    %ebx,%edi
mov    $0x80,%esi
call   10b0 <listen@plt>
test   %eax,%eax
jns    12f2 <main+0x112>
mov    0x2ce4(%rip),%rbx
mov    (%rbx),%edi
lea    0xd57(%rip),%rsi
jmp    13c3 <main+0x1e3>
lea    0xd68(%rip),%rdi
mov    %r14d,%esi
call   1070 <printf@plt>
movl   $0xc,0x8(%rsp)
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   10d0 <accept@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
jns    1337 <main+0x157>
mov    0x2c9f(%rip),%rbx
mov    (%rbx),%edi
lea    0xd4a(%rip),%rsi
jmp    13c3 <main+0x1e3>
lea    0x20(%rsp),%rbp
lea    0x4(%rsp),%r14
lea    0x8(%rsp),%r15
jmp    136d <main+0x18d>
nopl   0x0(%rax,%rax,1)
movl   $0xc,0x8(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   10d0 <accept@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
js     1322 <main+0x142>
mov    %eax,%edi
nop
mov    %rbp,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
je     1350 <main+0x170>
test   %eax,%eax
js     13a1 <main+0x1c1>
mov    0x4(%rsp),%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
test   %eax,%eax
js     13b3 <main+0x1d3>
mov    0x4(%rsp),%edi
jmp    1370 <main+0x190>
mov    0x2c20(%rip),%rbx
mov    (%rbx),%edi
lea    0xcef(%rip),%rsi
jmp    13c3 <main+0x1e3>
mov    0x2c0e(%rip),%rbx
mov    (%rbx),%edi
lea    0xcf2(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"Usage: %s [port]\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [26 x i8] c"Could not create socket!\0A\00"
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [24 x i8] c"Could not bind socket!\0A\00"
@.str.3 = [29 x i8] c"Could not listen on socket!\0A\00"
@.str.4 = [27 x i8] c"Server is listening on %d\0A\00"
@.str.5 = [36 x i8] c"Could not establish new connection\0A\00"
@.str.6 = [21 x i8] c"Client read failed!\0A\00"
@.str.7 = [22 x i8] c"Client write failed!\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 i32
%9 = alloca i32
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.sockaddr_in
%12 = alloca [1024 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %27
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @stderr
%25 = call i32 @fflush(i32 %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %6
%32 = load i32, i32* @AF_INET
%33 = load i32, i32* @SOCK_STREAM
%34 = call i32 @socket(i32 %32, i32 %33, i32 0)
store i32 %34, i32* %7
%35 = load i32, i32* %7
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %27
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%40 = load i32, i32* @stderr
%41 = call i32 @fflush(i32 %40)
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %27
%44 = load i32, i32* @AF_INET
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %44, i32* %45
%46 = load i32, i32* %6
%47 = call i32 @htons(i32 %46)
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i32 %47, i32* %48
%49 = load i32, i32* @INADDR_ANY
%50 = call i32 @htonl(i32 %49)
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%52 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %51, i32 0, i32 0
store i32 %50, i32* %52
store i32 1, i32* %13
%53 = load i32, i32* %7
%54 = load i32, i32* @SOL_SOCKET
%55 = load i32, i32* @SO_REUSEADDR
%56 = call i32 @setsockopt(i32 %53, i32 %54, i32 %55, i32* %13, i32 4)
%57 = load i32, i32* %7
%58 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%59 = call i32 @bind(i32 %57, %struct.sockaddr* %58, i32 12)
store i32 %59, i32* %9
%60 = load i32, i32* %9
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %68
62: ; preds = %43
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%65 = load i32, i32* @stderr
%66 = call i32 @fflush(i32 %65)
%67 = call i32 @exit(i32 1)
unreachable
68: ; preds = %43
%69 = load i32, i32* %7
%70 = call i32 @listen(i32 %69, i32 128)
store i32 %70, i32* %9
%71 = load i32, i32* %9
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %79
73: ; preds = %68
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%76 = load i32, i32* @stderr
%77 = call i32 @fflush(i32 %76)
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %68
%80 = load i32, i32* %6
%81 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %80)
br label %82
82: ; preds = %79, %125
store i32 12, i32* %14
%83 = load i32, i32* %7
%84 = bitcast i32* %8 to %struct.sockaddr*
%85 = call i32 @accept(i32 %83, %struct.sockaddr* %84, i32* %14)
store i32 %85, i32* %8
%86 = load i32, i32* %8
%87 = icmp slt i32 %86, 0
br i1 %87, label %88, label %94
88: ; preds = %82
%89 = load i32, i32* @stderr
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%91 = load i32, i32* @stderr
%92 = call i32 @fflush(i32 %91)
%93 = call i32 @exit(i32 1)
unreachable
94: ; preds = %82
br label %95
95: ; preds = %94, %124
%96 = load i32, i32* %8
%97 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%98 = call i32 @recv(i32 %96, i8* %97, i32 1024, i32 0)
store i32 %98, i32* %15
%99 = load i32, i32* %15
%100 = icmp ne i32 %99, 0
br i1 %100, label %102, label %101
101: ; preds = %95
br label %125
102: ; preds = %95
%103 = load i32, i32* %15
%104 = icmp slt i32 %103, 0
br i1 %104, label %105, label %111
105: ; preds = %102
%106 = load i32, i32* @stderr
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%108 = load i32, i32* @stderr
%109 = call i32 @fflush(i32 %108)
%110 = call i32 @exit(i32 1)
unreachable
111: ; preds = %102
%112 = load i32, i32* %8
%113 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%114 = load i32, i32* %15
%115 = call i32 @send(i32 %112, i8* %113, i32 %114, i32 0)
store i32 %115, i32* %9
%116 = load i32, i32* %9
%117 = icmp slt i32 %116, 0
br i1 %117, label %118, label %124
118: ; preds = %111
%119 = load i32, i32* @stderr
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%121 = load i32, i32* @stderr
%122 = call i32 @fflush(i32 %121)
%123 = call i32 @exit(i32 1)
unreachable
124: ; preds = %111
br label %95
125: ; preds = %101
br label %82
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"Usage: %s [port]\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [26 x i8] c"Could not create socket!\0A\00"
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [24 x i8] c"Could not bind socket!\0A\00"
@.str.3 = [29 x i8] c"Could not listen on socket!\0A\00"
@.str.4 = [27 x i8] c"Server is listening on %d\0A\00"
@.str.5 = [36 x i8] c"Could not establish new connection\0A\00"
@.str.6 = [21 x i8] c"Client read failed!\0A\00"
@.str.7 = [22 x i8] c"Client write failed!\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = icmp slt i32 %0, 2
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @stderr
%14 = tail call i32 @fflush(i32 %13)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = bitcast i32* %3 to i8*
%21 = bitcast %struct.sockaddr_in* %4 to i8*
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%23 = load i32, i32* @AF_INET
%24 = load i32, i32* @SOCK_STREAM
%25 = tail call i32 @socket(i32 %23, i32 %24, i32 0)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %16
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @stderr
%31 = tail call i32 @fflush(i32 %30)
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %16
%34 = load i32, i32* @AF_INET
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %34, i32* %35
%36 = tail call i32 @htons(i32 %19)
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %36, i32* %37
%38 = load i32, i32* @INADDR_ANY
%39 = tail call i32 @htonl(i32 %38)
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i32 %39, i32* %40
%41 = bitcast i32* %6 to i8*
store i32 1, i32* %6
%42 = load i32, i32* @SOL_SOCKET
%43 = load i32, i32* @SO_REUSEADDR
%44 = call i32 @setsockopt(i32 %25, i32 %42, i32 %43, i32* %6, i32 4)
%45 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%46 = call i32 @bind(i32 %25, %struct.sockaddr* %45, i32 12)
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %54
48: ; preds = %33
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%51 = load i32, i32* @stderr
%52 = call i32 @fflush(i32 %51)
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %33
%55 = call i32 @listen(i32 %25, i32 128)
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %63
57: ; preds = %54
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%60 = load i32, i32* @stderr
%61 = call i32 @fflush(i32 %60)
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %54
%64 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%65 = bitcast i32* %7 to i8*
%66 = bitcast i32* %3 to %struct.sockaddr*
store i32 12, i32* %7
%67 = call i32 @accept(i32 %25, %struct.sockaddr* %66, i32* %7)
store i32 %67, i32* %3
%68 = icmp slt i32 %67, 0
br i1 %68, label %73, label %69
69: ; preds = %63, %102
%70 = phi i32 [ %103, %102 ], [ %67, %63 ]
%71 = call i32 @recv(i32 %70, i8* %22, i32 1024, i32 0)
%72 = icmp eq i32 %71, 0
br i1 %72, label %102, label %79
73: ; preds = %102, %63
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%76 = load i32, i32* @stderr
%77 = call i32 @fflush(i32 %76)
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %69, %92
%80 = phi i32 [ %94, %92 ], [ %71, %69 ]
%81 = icmp slt i32 %80, 0
br i1 %81, label %82, label %88
82: ; preds = %79
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%85 = load i32, i32* @stderr
%86 = call i32 @fflush(i32 %85)
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %79
%89 = load i32, i32* %3
%90 = call i32 @send(i32 %89, i8* %22, i32 %80, i32 0)
%91 = icmp slt i32 %90, 0
br i1 %91, label %96, label %92
92: ; preds = %88
%93 = load i32, i32* %3
%94 = call i32 @recv(i32 %93, i8* %22, i32 1024, i32 0)
%95 = icmp eq i32 %94, 0
br i1 %95, label %102, label %79
96: ; preds = %88
%97 = load i32, i32* @stderr
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%99 = load i32, i32* @stderr
%100 = call i32 @fflush(i32 %99)
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %92, %69
store i32 12, i32* %7
%103 = call i32 @accept(i32 %25, %struct.sockaddr* %66, i32* %7)
store i32 %103, i32* %3
%104 = icmp slt i32 %103, 0
br i1 %104, label %73, label %69
}