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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int INET_ADDRSTRLEN;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, TYPE_1__ *, char *, int);
int listen(int, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
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 /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
int main(void) {
  struct sockaddr_in sin;
  struct sockaddr_in cin;
  int l_fd;
  int c_fd;
  socklen_t len;
  char buf[100];
  char addr_p[INET_ADDRSTRLEN];
  int port = 8000;
  int n;
  bzero(&sin, sizeof(sin));
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = INADDR_ANY;
  sin.sin_port = htons(port);
  if ((l_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
    perror("fail to creat socket");
    exit(1);
  }
  if (bind(l_fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
    perror("fail to bind");
    exit(1);
  }
  if (listen(l_fd, 10) == -1) {
    perror("fail to listen");
    exit(1);
  }
  printf("waiting ...\n");
  while (1) {
    if ((c_fd = accept(l_fd, (struct sockaddr *)&cin, &len)) == -1) {
      perror("fail to accept");
      exit(1);
    }
    n = recv(c_fd, buf, 100, 0);
    if (n == -1) {
      perror("fail to receive");
      exit(1);
    } else if (n == 0) {
      printf("the connect has been closed\n");
      close(c_fd);
      continue;
    }
    inet_ntop(AF_INET, &cin.sin_addr, addr_p, sizeof(addr_p));
    printf("client IP is %s, port is %d\n", addr_p, ntohs(cin.sin_port));
    printf("content is : %s\n", buf);
    n = strlen(buf);
    sprintf(buf, "%d", n);
    n = send(c_fd, buf, strlen(buf) + 1, 0);
    if (n == -1) {
      perror("fail to send");
      exit(1);
    }
    if (close(c_fd) == -1) {
      perror("fail to close");
      exit(1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xb8(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xb0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xa0(%rbp)
movl   $0x1f40,-0xa4(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0xc,%esi
call   10e0 <bzero@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2d67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0xa4(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x10(%rbp)
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
mov    0x2d34(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    12c7 <main+0xc7>
lea    0xd48(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x24(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12f7 <main+0xf7>
lea    0xd2d(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x24(%rbp),%edi
mov    $0xa,%esi
call   10a0 <listen@plt>
cmp    $0xffffffff,%eax
jne    1323 <main+0x123>
lea    0xd0e(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1336 <main+0x136>
mov    -0x24(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
jne    1368 <main+0x168>
lea    0xce5(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x28(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    %eax,-0xa8(%rbp)
cmpl   $0xffffffff,-0xa8(%rbp)
jne    13a7 <main+0x1a7>
lea    0xcb5(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
cmpl   $0x0,-0xa8(%rbp)
jne    13cf <main+0x1cf>
lea    0xca2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x28(%rbp),%edi
call   1090 <close@plt>
jmp    1331 <main+0x131>
jmp    13d4 <main+0x1d4>
mov    -0xb0(%rbp),%rdx
mov    -0xb8(%rbp),%rax
mov    0x2bff(%rip),%rcx
mov    (%rcx),%edi
lea    -0x20(%rbp),%rsi
add    $0x4,%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x20(%rbp),%edi
call   10b0 <ntohs@plt>
mov    -0xb0(%rbp),%rsi
mov    %eax,%edx
lea    0xc68(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xc70(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xa8(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0xa8(%rbp),%edx
lea    0xc54(%rip),%rsi
call   1100 <sprintf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0xc4(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0xc0(%rbp)
lea    -0x90(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xc4(%rbp),%edi
mov    -0xc0(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    %eax,-0xa8(%rbp)
cmpl   $0xffffffff,-0xa8(%rbp)
jne    14be <main+0x2be>
lea    0xbfc(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x28(%rbp),%edi
call   1090 <close@plt>
cmp    $0xffffffff,%eax
jne    14e5 <main+0x2e5>
lea    0xbe2(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    1331 <main+0x131>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    0x2d9d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
mov    %rax,-0x50(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    -0x38(%rbp),%rdi
mov    $0xc,%esi
call   10f0 <bzero@plt>
mov    0x2d91(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    $0x1f40,%edi
call   1070 <htons@plt>
mov    %eax,-0x38(%rbp)
mov    (%rbx),%edi
mov    0x2d52(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
cmp    $0xffffffff,%eax
jne    1295 <main+0x85>
lea    0xd6d(%rip),%rdi
jmp    12f9 <main+0xe9>
mov    %eax,%r13d
lea    -0x38(%rbp),%rsi
mov    %eax,%edi
mov    $0xc,%edx
call   10d0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12b6 <main+0xa6>
lea    0xd61(%rip),%rdi
jmp    12f9 <main+0xe9>
mov    %r13d,%edi
mov    $0xa,%esi
call   10b0 <listen@plt>
cmp    $0xffffffff,%eax
jne    12d1 <main+0xc1>
lea    0xd53(%rip),%rdi
jmp    12f9 <main+0xe9>
lea    0xdc4(%rip),%rdi
call   1050 <puts@plt>
lea    -0x48(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
mov    %r13d,%edi
call   1100 <accept@plt>
cmp    $0xffffffff,%eax
jne    1308 <main+0xf8>
lea    0xd38(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    %eax,%r12d
lea    -0xc0(%rbp),%rbx
lea    -0x2c(%rbp),%r14
jmp    134b <main+0x13b>
nopl   0x0(%rax,%rax,1)
lea    0xd81(%rip),%rdi
call   1050 <puts@plt>
mov    %r12d,%edi
call   10a0 <close@plt>
mov    %r13d,%edi
lea    -0x48(%rbp),%rsi
mov    %r14,%rdx
call   1100 <accept@plt>
mov    %eax,%r12d
cmp    $0xffffffff,%eax
je     12f2 <main+0xe2>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
test   %eax,%eax
je     1320 <main+0x110>
cmp    $0xffffffff,%eax
je     1402 <main+0x1f2>
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
lea    -0x44(%rbp),%rsi
mov    %r15,%rdx
mov    -0x50(%rbp),%rcx
call   1030 <inet_ntop@plt>
mov    -0x48(%rbp),%edi
call   10c0 <ntohs@plt>
lea    0xcbe(%rip),%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xcc8(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
lea    0xcbd(%rip),%rsi
mov    %eax,%edx
call   1110 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edx
mov    %r12d,%edi
mov    %rbx,%rsi
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0xffffffff,%eax
je     140e <main+0x1fe>
mov    %r12d,%edi
call   10a0 <close@plt>
cmp    $0xffffffff,%eax
jne    1334 <main+0x124>
lea    0xc91(%rip),%rdi
jmp    12f9 <main+0xe9>
lea    0xc37(%rip),%rdi
jmp    12f9 <main+0xe9>
lea    0xc6c(%rip),%rdi
jmp    12f9 <main+0xe9>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@INET_ADDRSTRLEN = global i32 0
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
@.str = [21 x i8] c"fail to creat socket\00"
@.str.1 = [13 x i8] c"fail to bind\00"
@.str.2 = [15 x i8] c"fail to listen\00"
@.str.3 = [13 x i8] c"waiting ...\0A\00"
@.str.4 = [15 x i8] c"fail to accept\00"
@.str.5 = [16 x i8] c"fail to receive\00"
@.str.6 = [29 x i8] c"the connect has been closed\0A\00"
@.str.7 = [29 x i8] c"client IP is %s, port is %d\0A\00"
@.str.8 = [17 x i8] c"content is : %s\0A\00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [13 x i8] c"fail to send\00"
@.str.11 = [14 x i8] c"fail to close\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sockaddr_in
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = load i32, i32* @INET_ADDRSTRLEN
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %8
%15 = alloca i8, i64 %13
store i64 %13, i64* %9
store i32 8000, i32* %10
%16 = call i32 @bzero(%struct.sockaddr_in* %2, i32 12)
%17 = load i32, i32* @AF_INET
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 2
store i32 %17, i32* %18
%19 = load i32, i32* @INADDR_ANY
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 1
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i32 0, i32 0
store i32 %19, i32* %21
%22 = load i32, i32* %10
%23 = call i32 @htons(i32 %22)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 0
store i32 %23, i32* %24
%25 = load i32, i32* @AF_INET
%26 = load i32, i32* @SOCK_STREAM
%27 = call i32 @socket(i32 %25, i32 %26, i32 0)
store i32 %27, i32* %4
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %32
29: ; preds = %0
%30 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %0
%33 = load i32, i32* %4
%34 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%35 = call i32 @bind(i32 %33, %struct.sockaddr* %34, i32 12)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %32
%41 = load i32, i32* %4
%42 = call i32 @listen(i32 %41, i32 10)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %40
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %109, %70, %47
br label %50
50: ; preds = %49
%51 = load i32, i32* %4
%52 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%53 = call i32 @accept(i32 %51, %struct.sockaddr* %52, i32* %6)
store i32 %53, i32* %5
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %50
%59 = load i32, i32* %5
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%61 = call i32 @recv(i32 %59, i8* %60, i32 100, i32 0)
store i32 %61, i32* %11
%62 = load i32, i32* %11
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %67
64: ; preds = %58
%65 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %58
%68 = load i32, i32* %11
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %67
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%72 = load i32, i32* %5
%73 = call i32 @close(i32 %72)
br label %49
74: ; preds = %67
br label %75
75: ; preds = %74
%76 = load i32, i32* @AF_INET
%77 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
%78 = trunc i64 %13 to i32
%79 = call i32 @inet_ntop(i32 %76, %struct.TYPE_2__* %77, i8* %15, i32 %78)
%80 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%81 = load i32, i32* %80
%82 = call i32 @ntohs(i32 %81)
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %15, i32 %82)
%84 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8* %84)
%86 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%87 = call i32 @strlen(i8* %86)
store i32 %87, i32* %11
%88 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%89 = load i32, i32* %11
%90 = call i32 @sprintf(i8* %88, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %89)
%91 = load i32, i32* %5
%92 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%93 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%94 = call i32 @strlen(i8* %93)
%95 = add nsw i32 %94, 1
%96 = call i32 @send(i32 %91, i8* %92, i32 %95, i32 0)
store i32 %96, i32* %11
%97 = load i32, i32* %11
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %102
99: ; preds = %75
%100 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %75
%103 = load i32, i32* %5
%104 = call i32 @close(i32 %103)
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %109
106: ; preds = %102
%107 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
%108 = call i32 @exit(i32 1)
unreachable
109: ; preds = %102
br label %49
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@INET_ADDRSTRLEN = global i32 0
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
@.str = [21 x i8] c"fail to creat socket\00"
@.str.1 = [13 x i8] c"fail to bind\00"
@.str.2 = [15 x i8] c"fail to listen\00"
@.str.4 = [15 x i8] c"fail to accept\00"
@.str.5 = [16 x i8] c"fail to receive\00"
@.str.7 = [29 x i8] c"client IP is %s, port is %d\0A\00"
@.str.8 = [17 x i8] c"content is : %s\0A\00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [13 x i8] c"fail to send\00"
@.str.11 = [14 x i8] c"fail to close\00"
@str = [12 x i8] c"waiting ...\00"
@str.12 = [28 x i8] c"the connect has been closed\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = bitcast %struct.sockaddr_in* %1 to i8*
%6 = bitcast %struct.sockaddr_in* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* @INET_ADDRSTRLEN
%10 = zext i32 %9 to i64
%11 = alloca i8, i64 %10
%12 = call i32 @bzero(%struct.sockaddr_in* %1, i32 12)
%13 = load i32, i32* @AF_INET
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %13, i32* %14
%15 = load i32, i32* @INADDR_ANY
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %15, i32* %16
%17 = tail call i32 @htons(i32 8000)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %17, i32* %18
%19 = load i32, i32* @AF_INET
%20 = load i32, i32* @SOCK_STREAM
%21 = tail call i32 @socket(i32 %19, i32 %20, i32 0)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %26
23: ; preds = %0
%24 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %0
%27 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%28 = call i32 @bind(i32 %21, %struct.sockaddr* %27, i32 12)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %26
%34 = call i32 @listen(i32 %21, i32 10)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %33
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%41 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%42 = call i32 @accept(i32 %21, %struct.sockaddr* %41, i32* %3)
%43 = icmp eq i32 %42, -1
br i1 %43, label %47, label %44
44: ; preds = %39
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
br label %50
47: ; preds = %59, %39
%48 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %44, %59
%51 = phi i32 [ %42, %44 ], [ %60, %59 ]
%52 = call i32 @recv(i32 %51, i8* %8, i32 100, i32 0)
switch i32 %52, label %62 [
i32 -1, label %53
i32 0, label %56
]
53: ; preds = %50
%54 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %50
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.12, i64 0, i64 0))
%58 = call i32 @close(i32 %51)
br label %59
59: ; preds = %56, %78
%60 = call i32 @accept(i32 %21, %struct.sockaddr* %41, i32* %3)
%61 = icmp eq i32 %60, -1
br i1 %61, label %47, label %50
62: ; preds = %50
%63 = load i32, i32* @AF_INET
%64 = call i32 @inet_ntop(i32 %63, %struct.TYPE_2__* %45, i8* %11, i32 %9)
%65 = load i32, i32* %46
%66 = call i32 @ntohs(i32 %65)
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %11, i32 %66)
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8* %8)
%69 = call i32 @strlen(i8* %8)
%70 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %69)
%71 = call i32 @strlen(i8* %8)
%72 = add nsw i32 %71, 1
%73 = call i32 @send(i32 %51, i8* %8, i32 %72, i32 0)
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %78
75: ; preds = %62
%76 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %62
%79 = call i32 @close(i32 %51)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %59
81: ; preds = %78
%82 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
%83 = call i32 @exit(i32 1)
unreachable
}