#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*/ sin;
typedef int pid_t;
typedef int /*<<< orphan*/ from;
typedef int /*<<< orphan*/ cwd;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
int bind(int, struct sockaddr *, int);
scalar_t__ chroot(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ communication(int, struct sockaddr_in);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ *getcwd(char *, int);
int /*<<< orphan*/ htons(int);
scalar_t__ listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int s, ns, r, port;
  pid_t pid;
  struct sockaddr_in sin, from;
  socklen_t fromlen;
  char cwd[512];
  if (getcwd(cwd, sizeof(cwd)) == NULL) {
    perror("getcwd() error");
    exit(1);
  }
  if (chroot(cwd) != 0) {
    fprintf(stderr, "chroot(%s) failed\n", cwd);
    exit(1);
  }
  signal(SIGCHLD, SIG_IGN);
  if (argc != 2) {
    printf("Usage : %s  port_serveur\n", argv[0]);
    exit(1);
  }
  port = atoi(argv[1]);
  if (port < 5000) {
    printf("donnez un numero de port superieur a 5000\n");
    exit(1);
  }
  memset(&sin, 0, sizeof(sin));
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = INADDR_ANY;
  sin.sin_port = htons(port);
  s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (s == -1) {
    perror("socket");
    exit(2);
  }
  r = bind(s, (struct sockaddr *)&sin, sizeof(sin));
  if (r == -1) {
    perror("bind");
    exit(3);
  }
  if (listen(s, 5) < 0) {
    perror("listen");
    exit(4);
  }
  fromlen = sizeof(from);
  for (;;) {
    ns = accept(s, (struct sockaddr *)&from, &fromlen);
    if (ns == -1) {
      perror("accept");
      exit(1);
    }
    pid = fork();
    if (pid == -1) {
      perror("Error forking!");
      exit(5);
    }
    if (pid == 0) {
      communication(ns, from);
      return 0;
    } else {
      close(ns);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x260,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x250(%rbp),%rdi
mov    $0x200,%esi
call   1070 <getcwd@plt>
cmp    $0x0,%rax
jne    125a <main+0x4a>
lea    0xdb5(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x250(%rbp),%rdi
call   1030 <chroot@plt>
cmp    $0x0,%rax
je     1296 <main+0x86>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    -0x250(%rbp),%rdx
lea    0xd88(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2d33(%rip),%rax
mov    (%rax),%edi
mov    0x2d22(%rip),%rax
mov    (%rax),%esi
call   10a0 <signal@plt>
cmpl   $0x2,-0x8(%rbp)
je     12d6 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x1388,-0x20(%rbp)
jge    130b <main+0xfb>
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2cc6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2cb2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%edi
call   1040 <htons@plt>
mov    %eax,-0x30(%rbp)
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
mov    0x2c62(%rip),%rax
mov    (%rax),%esi
mov    0x2c81(%rip),%rax
mov    (%rax),%edx
call   1130 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1381 <main+0x171>
lea    0xcf5(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x2,%edi
call   1110 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    13b5 <main+0x1a5>
lea    0xcc8(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x3,%edi
call   1110 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
cmp    $0x0,%rax
jge    13e2 <main+0x1d2>
lea    0xca0(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x4,%edi
call   1110 <exit@plt>
movl   $0xc,-0x44(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x44(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    141c <main+0x20c>
lea    0xc6d(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1446 <main+0x236>
lea    0xc4a(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x5,%edi
call   1110 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
jne    1484 <main+0x274>
mov    -0x18(%rbp),%edi
mov    -0x40(%rbp),%rax
mov    %rax,-0x260(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x258(%rbp)
mov    -0x260(%rbp),%rsi
mov    -0x258(%rbp),%edx
call   1090 <communication@plt>
xor    %eax,%eax
add    $0x260,%rsp
pop    %rbp
ret
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
jmp    13e9 <main+0x1d9>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x238,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x30(%rsp),%rdi
mov    $0x200,%esi
call   1080 <getcwd@plt>
test   %rax,%rax
je     13c7 <main+0x1a7>
lea    0x30(%rsp),%rdi
call   1030 <chroot@plt>
test   %rax,%rax
jne    13d0 <main+0x1b0>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
mov    0x2d5b(%rip),%rax
mov    (%rax),%esi
call   10b0 <signal@plt>
cmp    $0x2,%ebp
jne    13f4 <main+0x1d4>
mov    0x8(%rbx),%rdi
call   1110 <atoi@plt>
cmp    $0x1387,%eax
jle    140f <main+0x1ef>
mov    %eax,%ebx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d3d(%rip),%rbp
mov    0x0(%rbp),%eax
mov    %eax,0x18(%rsp)
mov    0x2d27(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    %ebx,%edi
call   1050 <htons@plt>
mov    %eax,0x10(%rsp)
mov    0x0(%rbp),%edi
mov    0x2cdc(%rip),%rax
mov    (%rax),%esi
mov    0x2cfb(%rip),%rax
mov    (%rax),%edx
call   1140 <socket@plt>
cmp    $0xffffffff,%eax
je     1425 <main+0x205>
mov    %eax,%ebx
lea    0x10(%rsp),%rsi
mov    %eax,%edi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
je     143b <main+0x21b>
mov    %ebx,%edi
mov    $0x5,%esi
call   10d0 <listen@plt>
test   %rax,%rax
js     1451 <main+0x231>
movl   $0xc,0xc(%rsp)
lea    0x20(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   1100 <accept@plt>
cmp    $0xffffffff,%eax
je     137b <main+0x15b>
mov    %eax,%ebp
lea    0x20(%rsp),%r14
lea    0xc(%rsp),%r15
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1391 <main+0x171>
cmp    $0xffffffff,%eax
je     13b1 <main+0x191>
mov    %ebp,%edi
call   1090 <close@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1100 <accept@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1350 <main+0x130>
lea    0xccd(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x20(%rsp),%rsi
mov    0x28(%rsp),%edx
mov    %ebp,%edi
call   10a0 <communication@plt>
xor    %eax,%eax
add    $0x238,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc9e(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x5,%edi
call   1120 <exit@plt>
lea    0xc32(%rip),%rdi
jmp    1382 <main+0x162>
mov    0x2be1(%rip),%rax
mov    (%rax),%edi
lea    0xc2f(%rip),%rsi
lea    0x30(%rsp),%rdx
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    (%rbx),%rsi
lea    0xc24(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    0xc4f(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    0xc10(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x2,%edi
call   1120 <exit@plt>
lea    0xc01(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%edi
call   1120 <exit@plt>
lea    0xbf0(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x4,%edi
call   1120 <exit@plt>

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

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [15 x i8] c"getcwd() error\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"chroot(%s) failed\0A\00"
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
@.str.2 = [26 x i8] c"Usage : %s port_serveur\0A\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.4 = [7 x i8] c"socket\00"
@.str.5 = [5 x i8] c"bind\00"
@.str.6 = [7 x i8] c"listen\00"
@.str.7 = [7 x i8] c"accept\00"
@.str.8 = [15 x i8] c"Error forking!\00"
@str = [42 x i8] c"donnez un numero de port superieur a 5000\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca [512 x i8]
%7 = bitcast %struct.sockaddr_in* %3 to i8*
%8 = bitcast %struct.sockaddr_in* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%11 = call i32* @getcwd(i8* %10, i32 512)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = call i64 @chroot(i8* %10)
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %16
%24 = load i32, i32* @SIGCHLD
%25 = load i32, i32* @SIG_IGN
%26 = call i32 @signal(i32 %24, i32 %25)
%27 = icmp eq i32 %0, 2
br i1 %27, label %32, label %28
28: ; preds = %23
%29 = load i8*, i8** %1
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %23
%33 = getelementptr inbounds i8*, i8** %1, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
%36 = icmp slt i32 %35, 5000
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %32
%41 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%42 = load i32, i32* @AF_INET
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %42, i32* %43
%44 = load i32, i32* @INADDR_ANY
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %44, i32* %45
%46 = call i32 @htons(i32 %35)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %46, i32* %47
%48 = load i32, i32* @AF_INET
%49 = load i32, i32* @SOCK_STREAM
%50 = load i32, i32* @IPPROTO_TCP
%51 = call i32 @socket(i32 %48, i32 %49, i32 %50)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %56
53: ; preds = %40
%54 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%55 = call i32 @exit(i32 2)
unreachable
56: ; preds = %40
%57 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%58 = call i32 @bind(i32 %51, %struct.sockaddr* %57, i32 12)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%62 = call i32 @exit(i32 3)
unreachable
63: ; preds = %56
%64 = call i64 @listen(i32 %51, i32 5)
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%68 = call i32 @exit(i32 4)
unreachable
69: ; preds = %63
store i32 12, i32* %5
%70 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%71 = call i32 @accept(i32 %51, %struct.sockaddr* %70, i32* %5)
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %76
73: ; preds = %88, %69
%74 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %69, %88
%77 = phi i32 [ %90, %88 ], [ %71, %69 ]
%78 = call i32 (...) @fork()
switch i32 %78, label %88 [
i32 -1, label %79
i32 0, label %82
]
79: ; preds = %76
%80 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%81 = call i32 @exit(i32 5)
unreachable
82: ; preds = %76
%83 = bitcast %struct.sockaddr_in* %4 to i64*
%84 = load i64, i64* %83
%85 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
%86 = load i32, i32* %85
%87 = call i32 @communication(i32 %77, i64 %84, i32 %86)
ret i32 0
88: ; preds = %76
%89 = call i32 @close(i32 %77)
%90 = call i32 @accept(i32 %51, %struct.sockaddr* %70, i32* %5)
%91 = icmp eq i32 %90, -1
br i1 %91, label %73, label %76
}