#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 s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ optval;
typedef int /*<<< orphan*/ me;
typedef int /*<<< orphan*/ it;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ PF_INET;
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*/ htons(int);
int inet_addr(char *);
int listen(int, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char **argv) {
  if (argc == 3) {
    int addr = inet_addr(argv[1]);
    int port = atoi(argv[2]);
    int s1 = socket(PF_INET, SOCK_STREAM, 0);
    struct sockaddr_in me, it;
    int melen = sizeof(me), itlen = sizeof(it);
    memset((char *)&me, 0, sizeof(me));
    me.sin_family = AF_INET;
    me.sin_addr.s_addr = addr;
    me.sin_port = htons(port);
    int optval = 1;
    int opt = setsockopt(s1, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval));
    int bound = bind(s1, (struct sockaddr *)&me, melen);
    if (bound < 0) {
      perror("bind fails: ");
      return -1;
    }
    int listening = listen(s1, 1);
    if (listening < 0) {
      perror("listen fails: ");
      return -1;
    }
    printf("listening on //%08x:%d/\n", addr, port);
    char buf[128];
    while (1) {
      int s2 = accept(s1, (struct sockaddr *)&it, &itlen);
      if (s2 < 0) {
        perror("accept fails: ");
        break;
      }
      printf("accepted connection from //%08x/\n", it.sin_addr.s_addr);
      while (1) {
        memset((char *)&it, 0, sizeof(it));
        memset(buf, 0, sizeof(buf));
        int received = recv(s2, buf, sizeof(buf) - 1, 0);
        if (received > 0) {
          buf[received] = 0;
          printf("received '%s'\n", buf);
        } else if (received == 0) {
          printf("peer closed\n");
          break;
        } else {
          perror("receive fails: ");
          break;
        }
        int sent = send(s2, buf, received, 0);
        if (sent < 0) {
          perror("send fails: ");
          break;
        }
      }
    }
  } else
    printf("ses <local ip> <local port>\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    144d <main+0x27d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <inet_addr@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
mov    0x2dad(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x1c(%rbp)
movl   $0xc,-0x3c(%rbp)
movl   $0xc,-0x40(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2d6d(%rip),%rax
mov    (%rax),%esi
mov    0x2d3c(%rip),%rax
mov    (%rax),%edx
lea    -0x44(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    %eax,-0x48(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    -0x3c(%rbp),%edx
call   10b0 <bind@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jge    12cc <main+0xfc>
lea    0xd45(%rip),%rdi
call   10c0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1462 <main+0x292>
mov    -0x1c(%rbp),%edi
mov    $0x1,%esi
call   10a0 <listen@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
jge    12fe <main+0x12e>
lea    0xd20(%rip),%rdi
call   10c0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1462 <main+0x292>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xd11(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x1c(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   10d0 <accept@plt>
mov    %eax,-0xd4(%rbp)
cmpl   $0x0,-0xd4(%rbp)
jge    1346 <main+0x176>
lea    0xcf9(%rip),%rdi
call   10c0 <perror@plt>
jmp    1448 <main+0x278>
mov    -0x38(%rbp),%esi
lea    0xcf4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1080 <memset@plt>
mov    -0xd4(%rbp),%edi
lea    -0xd0(%rbp),%rsi
mov    $0x7f,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0xd8(%rbp)
cmpl   $0x0,-0xd8(%rbp)
jle    13cf <main+0x1ff>
movslq -0xd8(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
lea    -0xd0(%rbp),%rsi
lea    0xca3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1400 <main+0x230>
cmpl   $0x0,-0xd8(%rbp)
jne    13ef <main+0x21f>
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1443 <main+0x273>
lea    0xc8c(%rip),%rdi
call   10c0 <perror@plt>
jmp    1443 <main+0x273>
mov    -0xd4(%rbp),%edi
lea    -0xd0(%rbp),%rsi
mov    -0xd8(%rbp),%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %eax,-0xdc(%rbp)
cmpl   $0x0,-0xdc(%rbp)
jge    143e <main+0x26e>
lea    0xc5e(%rip),%rdi
call   10c0 <perror@plt>
jmp    1443 <main+0x273>
jmp    1357 <main+0x187>
jmp    1312 <main+0x142>
jmp    145b <main+0x28b>
lea    0xc4b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
cmp    $0x3,%edi
je     1216 <main+0x36>
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   10a0 <inet_addr@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   10f0 <atoi@plt>
mov    %eax,%ebp
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
mov    0x2d90(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,%r12d
movl   $0xc,0x8(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2d71(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    %r14d,0x10(%rsp)
mov    %ebp,%edi
call   1060 <htons@plt>
mov    %eax,0x14(%rsp)
movl   $0x1,0xc(%rsp)
mov    0x2d54(%rip),%rax
mov    (%rax),%esi
mov    0x2d23(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %r12d,%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
test   %eax,%eax
jns    12cf <main+0xef>
lea    0xd33(%rip),%rdi
jmp    12e7 <main+0x107>
mov    %r12d,%edi
mov    $0x1,%esi
call   10b0 <listen@plt>
test   %eax,%eax
jns    12f6 <main+0x116>
lea    0xd26(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%eax
jmp    1204 <main+0x24>
lea    0xd1f(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x20(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %r12d,%edi
call   10e0 <accept@plt>
test   %eax,%eax
jns    1330 <main+0x150>
lea    0xd0f(%rip),%rdi
call   10d0 <perror@plt>
jmp    1202 <main+0x22>
mov    %eax,%r15d
lea    0x20(%rsp),%rbp
lea    0x30(%rsp),%rbx
lea    0xd22(%rip),%r13
jmp    1379 <main+0x199>
cs nopw 0x0(%rax,%rax,1)
jne    13f8 <main+0x218>
lea    0xd51(%rip),%rdi
call   1040 <puts@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
lea    0x8(%rsp),%rdx
call   10e0 <accept@plt>
mov    %eax,%r15d
test   %eax,%eax
js     131f <main+0x13f>
mov    0x20(%rsp),%esi
lea    0xcc0(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1090 <memset@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x7f,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    1350 <main+0x170>
mov    %eax,%r14d
mov    %eax,%eax
movb   $0x0,0x30(%rsp,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
test   %eax,%eax
jns    1390 <main+0x1b0>
lea    0xc8f(%rip),%rdi
jmp    13ff <main+0x21f>
lea    0xc76(%rip),%rdi
call   10d0 <perror@plt>
jmp    1362 <main+0x182>

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

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
@AF_INET = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str = [13 x i8] c"bind fails: \00"
@.str.1 = [15 x i8] c"listen fails: \00"
@.str.2 = [25 x i8] c"listening on //%08x:%d/\0A\00"
@.str.3 = [15 x i8] c"accept fails: \00"
@.str.4 = [34 x i8] c"accepted connection from //%08x/\0A\00"
@.str.5 = [15 x i8] c"received '%s'\0A\00"
@.str.7 = [16 x i8] c"receive fails: \00"
@.str.8 = [13 x i8] c"send fails: \00"
@str = [28 x i8] c"ses <local ip> <local port>\00"
@str.10 = [12 x i8] c"peer closed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = icmp eq i32 %0, 3
br i1 %8, label %9, label %77
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @inet_addr(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = load i32, i32* @PF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = tail call i32 @socket(i32 %16, i32 %17, i32 0)
%19 = bitcast %struct.sockaddr_in* %3 to i8*
%20 = bitcast %struct.sockaddr_in* %4 to i8*
%21 = bitcast i32* %5 to i8*
store i32 12, i32* %5
%22 = call i32 @memset(i8* %19, i32 0, i32 12)
%23 = load i32, i32* @AF_INET
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %23, i32* %24
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %12, i32* %25
%26 = call i32 @htons(i32 %15)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %26, i32* %27
%28 = bitcast i32* %6 to i8*
store i32 1, i32* %6
%29 = load i32, i32* @SOL_SOCKET
%30 = load i32, i32* @SO_REUSEADDR
%31 = call i32 @setsockopt(i32 %18, i32 %29, i32 %30, i32* %6, i32 4)
%32 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%33 = call i32 @bind(i32 %18, %struct.sockaddr* %32, i32 12)
%34 = icmp slt i32 %33, 0
br i1 %34, label %72, label %35
35: ; preds = %9
%36 = call i32 @listen(i32 %18, i32 1)
%37 = icmp slt i32 %36, 0
br i1 %37, label %72, label %38
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %15)
%40 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%41 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%42 = call i32 @accept(i32 %18, %struct.sockaddr* %41, i32* %5)
%43 = icmp slt i32 %42, 0
br i1 %43, label %75, label %44
44: ; preds = %38
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
br label %46
46: ; preds = %44, %69
%47 = phi i32 [ %42, %44 ], [ %70, %69 ]
%48 = load i32, i32* %45
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %55, %46
%51 = call i32 @memset(i8* %20, i32 0, i32 12)
%52 = call i32 @memset(i8* %40, i32 0, i32 128)
%53 = call i32 @recv(i32 %47, i8* %40, i32 127, i32 0)
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %61
55: ; preds = %50
%56 = zext i32 %53 to i64
%57 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 %56
store i8 0, i8* %57
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %40)
%59 = call i32 @send(i32 %47, i8* %40, i32 %53, i32 0)
%60 = icmp slt i32 %59, 0
br i1 %60, label %67, label %50
61: ; preds = %50
%62 = icmp eq i32 %53, 0
br i1 %62, label %63, label %65
63: ; preds = %61
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.10, i64 0, i64 0))
br label %69
65: ; preds = %61
%66 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %69
67: ; preds = %55
%68 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %69
69: ; preds = %63, %65, %67
%70 = call i32 @accept(i32 %18, %struct.sockaddr* %41, i32* %5)
%71 = icmp slt i32 %70, 0
br i1 %71, label %75, label %46
72: ; preds = %35, %9
%73 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %9 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), %35 ]
%74 = call i32 @perror(i8* %73)
br label %79
75: ; preds = %69, %38
%76 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %79
77: ; preds = %2
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %79
79: ; preds = %77, %75, %72
%80 = phi i32 [ -1, %72 ], [ 0, %75 ], [ 0, %77 ]
ret i32 %80
}