#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 int /*<<< orphan*/ reuse;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int /*<<< orphan*/ STDOUT_FILENO;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
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 recv(int, char *, int, int /*<<< orphan*/);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main(int argc, char *argv[]) {
  int i;
  int j;
  int port;
  int rc;
  int listen_sd;
  int accept_sd;
  char buffer[188 * 7];
  char ts_packet[188];
  struct sockaddr_in addr;
  if (argc >= 2) {
    port = atoi(argv[1]);
  } else {
    fprintf(stderr, "Usage: %s port\n", argv[0]);
    return 0;
  }
  listen_sd = socket(AF_INET, SOCK_STREAM, 0);
  if (listen_sd < 0) {
    fprintf(stderr, "socket() error\n");
    return 0;
  }
  int reuse = 1;
  if (setsockopt(listen_sd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)) <
      0) {
    perror("setsockopt() SO_REUSEADDR: error ");
  }
  fprintf(stderr, "Binding the socket...\n");
  memset(&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_addr.s_addr = htonl(INADDR_ANY);
  addr.sin_port = htons(port);
  rc = bind(listen_sd, (struct sockaddr *)&addr, sizeof(addr));
  if (rc < 0) {
    fprintf(stderr, "bind() error\n");
    close(listen_sd);
    return 0;
  }
  rc = listen(listen_sd, 1);
  if (rc < 0) {
    fprintf(stderr, "listen() error\n");
    close(listen_sd);
    return 0;
  }
  accept_sd = accept(listen_sd, NULL, NULL);
  if (accept_sd < 0) {
    fprintf(stderr, "accept() error\n");
    close(listen_sd);
    return 0;
  }
  rc = 1;
  j = 0;
  i = 0;
  while (rc > 0) {
    rc = recv(accept_sd, buffer, 188 * 7, 0);
    for (i = 0; i < rc; i++) {
      ts_packet[j] = buffer[i];
      j++;
      if (j == 188) {
        write(STDOUT_FILENO, ts_packet, 188);
        j = 0;
      }
    }
  }
  close(accept_sd);
  close(listen_sd);
  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)
jl     1218 <main+0x38>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    1242 <main+0x62>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14cc <main+0x2ec>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
mov    0x2d66(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    128b <main+0xab>
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
lea    0xd98(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14cc <main+0x2ec>
movl   $0x1,-0x624(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2d41(%rip),%rax
mov    (%rax),%esi
mov    0x2d08(%rip),%rax
mov    (%rax),%edx
lea    -0x624(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    12d2 <main+0xf2>
lea    0xd53(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
lea    0xd60(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
lea    -0x620(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2cd5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x618(%rbp)
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x61c(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x620(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x620(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1379 <main+0x199>
mov    0x2c6b(%rip),%rax
mov    (%rax),%edi
lea    0xcfb(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x24(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    14cc <main+0x2ec>
mov    -0x24(%rbp),%edi
mov    $0x1,%esi
call   10b0 <listen@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    13be <main+0x1de>
mov    0x2c26(%rip),%rax
mov    (%rax),%edi
lea    0xcc4(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x24(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    14cc <main+0x2ec>
mov    -0x24(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10e0 <accept@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1405 <main+0x225>
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
lea    0xc8d(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x24(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    14cc <main+0x2ec>
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    14b5 <main+0x2d5>
mov    -0x28(%rbp),%edi
lea    -0x550(%rbp),%rsi
mov    $0x524,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    14b0 <main+0x2d0>
movslq -0x14(%rbp),%rax
mov    -0x550(%rbp,%rax,1),%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x610(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xbc,-0x18(%rbp)
jne    149d <main+0x2bd>
mov    0x2b6d(%rip),%rax
mov    (%rax),%edi
lea    -0x610(%rbp),%rsi
mov    $0xbc,%edx
call   1050 <write@plt>
movl   $0x0,-0x18(%rbp)
jmp    14a2 <main+0x2c2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1444 <main+0x264>
jmp    141a <main+0x23a>
mov    -0x28(%rbp),%edi
call   1090 <close@plt>
mov    -0x24(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x630,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x608,%rsp
cmp    $0x2,%edi
jl     1388 <main+0x1a8>
mov    0x8(%rsi),%rdi
call   10f0 <atoi@plt>
mov    %eax,%r15d
mov    0x2dcb(%rip),%r12
mov    (%r12),%edi
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
test   %eax,%eax
js     13a4 <main+0x1c4>
mov    %eax,%ebp
movl   $0x1,0xc(%rsp)
mov    0x2da6(%rip),%rax
mov    (%rax),%esi
mov    0x2d6d(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
js     1410 <main+0x230>
mov    0x2d59(%rip),%r14
mov    (%r14),%edi
lea    0xdd1(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    (%r12),%eax
mov    %eax,0x18(%rsp)
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,0x14(%rsp)
mov    %r15d,%edi
call   1060 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
test   %eax,%eax
js     13bd <main+0x1dd>
mov    %ebp,%edi
mov    $0x1,%esi
call   10b0 <listen@plt>
test   %eax,%eax
js     13d8 <main+0x1f8>
xor    %ebx,%ebx
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10e0 <accept@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
js     13e4 <main+0x204>
mov    %ebp,0x8(%rsp)
mov    0x2cef(%rip),%r14
lea    0x20(%rsp),%r13
jmp    1318 <main+0x138>
nopl   0x0(%rax,%rax,1)
test   %ebp,%ebp
jle    13c9 <main+0x1e9>
mov    0x4(%rsp),%edi
lea    0xe0(%rsp),%rsi
mov    $0x524,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    13c9 <main+0x1e9>
mov    %eax,%ebp
mov    %eax,%r15d
xor    %r12d,%r12d
jmp    1359 <main+0x179>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r12
cmp    %r12,%r15
je     1310 <main+0x130>
movzbl 0xe0(%rsp,%r12,1),%eax
movslq %ebx,%rbx
mov    %al,0x20(%rsp,%rbx,1)
add    $0x1,%ebx
cmp    $0xbc,%ebx
jne    1350 <main+0x170>
mov    (%r14),%edi
mov    %r13,%rsi
mov    $0xbc,%edx
call   1050 <write@plt>
xor    %ebx,%ebx
jmp    1350 <main+0x170>
mov    0x2c31(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xc65(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    13fc <main+0x21c>
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
lea    0xc5c(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    13fc <main+0x21c>
mov    (%r14),%edi
lea    0xc92(%rip),%rsi
jmp    13ee <main+0x20e>
mov    0x4(%rsp),%edi
call   1090 <close@plt>
mov    0x8(%rsp),%ebp
jmp    13f5 <main+0x215>
mov    (%r14),%edi
lea    0xc85(%rip),%rsi
jmp    13ee <main+0x20e>
mov    (%r14),%edi
lea    0xc89(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %ebp,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x608,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc09(%rip),%rdi
call   10d0 <perror@plt>
jmp    1260 <main+0x80>

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

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