#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 socklen_t;
typedef int /*<<< orphan*/ seraddr;
typedef int pid_t;
typedef int /*<<< orphan*/ on;
typedef int /*<<< orphan*/ cliaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SOMAXCONN;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ doServer(int, struct sockaddr_in);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
char *inet_ntoa(TYPE_1__);
scalar_t__ listen(int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(void) {
  int listensocket;
  if ((listensocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
    do {
      perror("socket");
      exit(EXIT_FAILURE);
    } while (0);
  }
  struct sockaddr_in seraddr;
  memset(&seraddr, 0, sizeof(seraddr));
  seraddr.sin_family = AF_INET;
  seraddr.sin_port = htons(3000);
  seraddr.sin_addr.s_addr = htonl(INADDR_ANY);
  int on = 1;
  if (setsockopt(listensocket, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) {
    do {
      perror("setsockopt");
      exit(EXIT_FAILURE);
    } while (0);
  }
  if (bind(listensocket, (struct sockaddr *)&seraddr, sizeof(seraddr)) < 0) {
    do {
      perror("bind");
      exit(EXIT_FAILURE);
    } while (0);
  }
  if (listen(listensocket, SOMAXCONN) < 0) {
    do {
      perror("listen");
      exit(EXIT_FAILURE);
    } while (0);
  }
  struct sockaddr_in cliaddr;
  socklen_t cliaddrlen = sizeof(cliaddr);
  int connsocket;
  pid_t pid;
  while (1) {
    if ((connsocket = accept(listensocket, (struct sockaddr *)&cliaddr,
                             &cliaddrlen)) < 0) {
      do {
        perror("accept");
        exit(EXIT_FAILURE);
      } while (0);
    }
    printf("接收到一个连接：客户端的ip=%s，port=%d\n",
           inet_ntoa(cliaddr.sin_addr), ntohs(cliaddr.sin_port));
    pid = fork();
    if (pid == -1) {
      do {
        perror("fork");
        exit(EXIT_FAILURE);
      } while (0);
    }
    if (pid == 0) {
      close(listensocket);
      doServer(connsocket, cliaddr);
      exit(EXIT_SUCCESS);
    } else {
      close(connsocket);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    0x2d99(%rip),%rax
mov    (%rax),%esi
mov    0x2da8(%rip),%rax
mov    (%rax),%edx
call   1120 <socket@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    125a <main+0x5a>
jmp    1240 <main+0x40>
lea    0xdb9(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    $0xbb8,%edi
call   1060 <htons@plt>
mov    %eax,-0x18(%rbp)
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2d43(%rip),%rax
mov    (%rax),%esi
mov    0x2cea(%rip),%rax
mov    (%rax),%edx
lea    -0x1c(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    12e8 <main+0xe8>
jmp    12ce <main+0xce>
lea    0xd32(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
jge    1322 <main+0x122>
jmp    1308 <main+0x108>
lea    0xd03(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2c94(%rip),%rax
mov    (%rax),%esi
call   10b0 <listen@plt>
cmp    $0x0,%rax
jge    135c <main+0x15c>
jmp    1342 <main+0x142>
lea    0xcce(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c53(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
movl   $0xc,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    139e <main+0x19e>
jmp    1384 <main+0x184>
lea    0xc93(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c11(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x24(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%edi
call   10c0 <ntohs@plt>
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
lea    0xc66(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   1110 <fork@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    13f7 <main+0x1f7>
jmp    13dd <main+0x1dd>
lea    0xc76(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2bb8(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
cmpl   $0x0,-0x34(%rbp)
jne    1434 <main+0x234>
mov    -0x8(%rbp),%edi
call   10a0 <close@plt>
mov    -0x30(%rbp),%edi
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%edx
call   1050 <doServer@plt>
mov    0x2b73(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x30(%rbp),%edi
call   10a0 <close@plt>
jmp    1363 <main+0x163>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
mov    0x2d9a(%rip),%rax
mov    (%rax),%esi
mov    0x2da9(%rip),%rax
mov    (%rax),%edx
call   1120 <socket@plt>
test   %eax,%eax
jns    123e <main+0x3e>
lea    0xdc7(%rip),%rdi
jmp    13c3 <main+0x1c3>
mov    %eax,%r14d
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    $0xbb8,%edi
call   1060 <htons@plt>
mov    %eax,0x18(%rsp)
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0x1c(%rsp)
movl   $0x1,0x14(%rsp)
mov    0x2d5a(%rip),%rax
mov    (%rax),%esi
mov    0x2d01(%rip),%rax
mov    (%rax),%edx
lea    0x14(%rsp),%rcx
mov    %r14d,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
jns    12bd <main+0xbd>
lea    0xd4f(%rip),%rdi
jmp    13c3 <main+0x1c3>
lea    0x18(%rsp),%rsi
mov    %r14d,%edi
mov    $0xc,%edx
call   10d0 <bind@plt>
test   %rax,%rax
jns    12e0 <main+0xe0>
lea    0xd37(%rip),%rdi
jmp    13c3 <main+0x1c3>
mov    0x2cd9(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
call   10b0 <listen@plt>
test   %rax,%rax
jns    1302 <main+0x102>
lea    0xd1a(%rip),%rdi
jmp    13c3 <main+0x1c3>
movl   $0xc,0x4(%rsp)
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %r14d,%edi
call   10f0 <accept@plt>
test   %eax,%eax
js     138d <main+0x18d>
mov    %eax,%ebp
lea    0xcfc(%rip),%r15
lea    0x8(%rsp),%r12
lea    0x4(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0xc(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%edi
call   10c0 <ntohs@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <printf@plt>
xor    %eax,%eax
call   1110 <fork@plt>
test   %eax,%eax
je     1396 <main+0x196>
cmp    $0xffffffff,%eax
je     13bc <main+0x1bc>
mov    %ebp,%edi
call   10a0 <close@plt>
mov    %r14d,%edi
mov    %r12,%rsi
mov    %r13,%rdx
call   10f0 <accept@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1340 <main+0x140>
lea    0xc8a(%rip),%rdi
jmp    13c3 <main+0x1c3>
mov    %r14d,%edi
call   10a0 <close@plt>
mov    0x8(%rsp),%rsi
mov    0x10(%rsp),%edx
mov    %ebp,%edi
call   1050 <doServer@plt>
mov    0x2beb(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    0xc97(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2bd9(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str = [7 x i8] c"socket\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.1 = [11 x i8] c"setsockopt\00"
@.str.2 = [5 x i8] c"bind\00"
@SOMAXCONN = global i32 0
@.str.3 = [7 x i8] c"listen\00"
@.str.4 = [7 x i8] c"accept\00"
@.str.5 = [53 x i8] c"\E6\8E\A5\E6\94\B6\E5\88\B0\E4\B8\80\E4\B8\AA\E8\BF\9E\E6\8E\A5\EF\BC\9A\E5\AE\A2\E6\88\B7\E7\AB\AF\E7\9A\84ip=%s\EF\BC\8Cport=%d\0A\00"
@.str.6 = [5 x i8] c"fork\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 %struct.sockaddr_in
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca { i64, i32 }
store i32 0, i32* %1
%10 = load i32, i32* @PF_INET
%11 = load i32, i32* @SOCK_STREAM
%12 = load i32, i32* @IPPROTO_TCP
%13 = call i32 @socket(i32 %10, i32 %11, i32 %12)
store i32 %13, i32* %2
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %0
br label %16
16: ; preds = %15
%17 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; No predecessors!
br label %21
21: ; preds = %20, %0
%22 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%23 = load i32, i32* @AF_INET
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 2
store i32 %23, i32* %24
%25 = call i32 @htons(i32 3000)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
store i32 %25, i32* %26
%27 = load i32, i32* @INADDR_ANY
%28 = call i32 @htonl(i32 %27)
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
%30 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %29, i32 0, i32 0
store i32 %28, i32* %30
store i32 1, i32* %4
%31 = load i32, i32* %2
%32 = load i32, i32* @SOL_SOCKET
%33 = load i32, i32* @SO_REUSEADDR
%34 = call i64 @setsockopt(i32 %31, i32 %32, i32 %33, i32* %4, i32 4)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %21
br label %37
37: ; preds = %36
%38 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; No predecessors!
br label %42
42: ; preds = %41, %21
%43 = load i32, i32* %2
%44 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%45 = call i64 @bind(i32 %43, %struct.sockaddr* %44, i32 12)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %42
br label %48
48: ; preds = %47
%49 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; No predecessors!
br label %53
53: ; preds = %52, %42
%54 = load i32, i32* %2
%55 = load i32, i32* @SOMAXCONN
%56 = call i64 @listen(i32 %54, i32 %55)
%57 = icmp slt i64 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %53
br label %59
59: ; preds = %58
%60 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; No predecessors!
br label %64
64: ; preds = %63, %53
store i32 12, i32* %6
br label %65
65: ; preds = %64, %113
%66 = load i32, i32* %2
%67 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%68 = call i32 @accept(i32 %66, %struct.sockaddr* %67, i32* %6)
store i32 %68, i32* %7
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %76
70: ; preds = %65
br label %71
71: ; preds = %70
%72 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%73 = load i32, i32* @EXIT_FAILURE
%74 = call i32 @exit(i32 %73)
unreachable
75: ; No predecessors!
br label %76
76: ; preds = %75, %65
%77 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 1
%78 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %77, i32 0, i32 0
%79 = load i32, i32* %78
%80 = call i8* @inet_ntoa(i32 %79)
%81 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 0
%82 = load i32, i32* %81
%83 = call i32 @ntohs(i32 %82)
%84 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), i8* %80, i32 %83)
%85 = call i32 (...) @fork()
store i32 %85, i32* %8
%86 = load i32, i32* %8
%87 = icmp eq i32 %86, -1
br i1 %87, label %88, label %94
88: ; preds = %76
br label %89
89: ; preds = %88
%90 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%91 = load i32, i32* @EXIT_FAILURE
%92 = call i32 @exit(i32 %91)
unreachable
93: ; No predecessors!
br label %94
94: ; preds = %93, %76
%95 = load i32, i32* %8
%96 = icmp eq i32 %95, 0
br i1 %96, label %97, label %110
97: ; preds = %94
%98 = load i32, i32* %2
%99 = call i32 @close(i32 %98)
%100 = load i32, i32* %7
%101 = bitcast { i64, i32 }* %9 to i8*
%102 = bitcast %struct.sockaddr_in* %5 to i8*
%103 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %9, i32 0, i32 0
%104 = load i64, i64* %103
%105 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %9, i32 0, i32 1
%106 = load i32, i32* %105
%107 = call i32 @doServer(i32 %100, i64 %104, i32 %106)
%108 = load i32, i32* @EXIT_SUCCESS
%109 = call i32 @exit(i32 %108)
unreachable
110: ; preds = %94
%111 = load i32, i32* %7
%112 = call i32 @close(i32 %111)
br label %113
113: ; preds = %110
br label %65
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str = [7 x i8] c"socket\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.1 = [11 x i8] c"setsockopt\00"
@.str.2 = [5 x i8] c"bind\00"
@SOMAXCONN = global i32 0
@.str.3 = [7 x i8] c"listen\00"
@.str.4 = [7 x i8] c"accept\00"
@.str.5 = [53 x i8] c"\E6\8E\A5\E6\94\B6\E5\88\B0\E4\B8\80\E4\B8\AA\E8\BF\9E\E6\8E\A5\EF\BC\9A\E5\AE\A2\E6\88\B7\E7\AB\AF\E7\9A\84ip=%s\EF\BC\8Cport=%d\0A\00"
@.str.6 = [5 x i8] c"fork\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca i32
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = load i32, i32* @PF_INET
%6 = load i32, i32* @SOCK_STREAM
%7 = load i32, i32* @IPPROTO_TCP
%8 = tail call i32 @socket(i32 %5, i32 %6, i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = bitcast %struct.sockaddr_in* %1 to i8*
%16 = call i32 @memset(%struct.sockaddr_in* %1, i32 0, i32 12)
%17 = load i32, i32* @AF_INET
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %17, i32* %18
%19 = call i32 @htons(i32 3000)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %19, i32* %20
%21 = load i32, i32* @INADDR_ANY
%22 = call i32 @htonl(i32 %21)
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %22, i32* %23
%24 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%25 = load i32, i32* @SOL_SOCKET
%26 = load i32, i32* @SO_REUSEADDR
%27 = call i64 @setsockopt(i32 %8, i32 %25, i32 %26, i32* %2, i32 4)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %14
%30 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %14
%34 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%35 = call i64 @bind(i32 %8, %struct.sockaddr* %34, i32 12)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %33
%42 = load i32, i32* @SOMAXCONN
%43 = call i64 @listen(i32 %8, i32 %42)
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %41
%50 = bitcast %struct.sockaddr_in* %3 to i8*
%51 = bitcast i32* %4 to i8*
store i32 12, i32* %4
%52 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%53 = call i32 @accept(i32 %8, %struct.sockaddr* %52, i32* %4)
%54 = icmp slt i32 %53, 0
br i1 %54, label %58, label %55
55: ; preds = %49
%56 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
br label %62
58: ; preds = %83, %49
%59 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%60 = load i32, i32* @EXIT_FAILURE
%61 = call i32 @exit(i32 %60)
unreachable
62: ; preds = %55, %83
%63 = phi i32 [ %53, %55 ], [ %85, %83 ]
%64 = load i32, i32* %56
%65 = call i8* @inet_ntoa(i32 %64)
%66 = load i32, i32* %57
%67 = call i32 @ntohs(i32 %66)
%68 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), i8* %65, i32 %67)
%69 = call i32 (...) @fork()
switch i32 %69, label %83 [
i32 -1, label %70
i32 0, label %74
]
70: ; preds = %62
%71 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %62
%75 = call i32 @close(i32 %8)
%76 = bitcast %struct.sockaddr_in* %3 to i64*
%77 = load i64, i64* %76
%78 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
%79 = load i32, i32* %78
%80 = call i32 @doServer(i32 %63, i64 %77, i32 %79)
%81 = load i32, i32* @EXIT_SUCCESS
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %62
%84 = call i32 @close(i32 %63)
%85 = call i32 @accept(i32 %8, %struct.sockaddr* %52, i32* %4)
%86 = icmp slt i32 %85, 0
br i1 %86, label %58, label %62
}