#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 */

/* Type definitions */
struct sockaddr_storage {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct addrinfo {
  int ai_flags;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  struct addrinfo *ai_next;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ from;

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int AI_ALL;
int AI_PASSIVE;
int AI_V4MAPPED;
int /*<<< orphan*/ EXIT_FAILURE;
int NI_MAXHOST;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ communication(struct sockaddr *, int, char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(int /*<<< orphan*/ *, char *, struct addrinfo *,
                struct addrinfo **);
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int sfd, s, ns, r;
  struct addrinfo hints;
  struct addrinfo *result, *rp;
  struct sockaddr_storage from;
  socklen_t fromlen;
  char host[NI_MAXHOST];
  if (argc != 2) {
    printf("Usage: %s  port_serveur\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = AF_INET6;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_PASSIVE;
  hints.ai_flags |= AI_V4MAPPED | AI_ALL;
  hints.ai_protocol = 0;
  s = getaddrinfo(NULL, argv[1], &hints, &result);
  if (s != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
    exit(EXIT_FAILURE);
  }
  for (rp = result; rp != NULL; rp = rp->ai_next) {
    sfd = socket(AF_INET6, SOCK_STREAM, 0);
    if (sfd == -1)
      continue;
    r = bind(sfd, rp->ai_addr, rp->ai_addrlen);
    if (r == 0)
      break;
    close(sfd);
  }
  if (rp == NULL) {
    perror("bind");
    exit(EXIT_FAILURE);
  }
  freeaddrinfo(result);
  listen(sfd, 5);
  for (;;) {
    fromlen = sizeof(from);
    ns = accept(sfd, (struct sockaddr *)&from, &fromlen);
    if (ns == -1) {
      perror("accept");
      exit(EXIT_FAILURE);
    }
    int pid;
    pid = fork();
    switch (pid) {
    case 0:
      communication((struct sockaddr *)&from, fromlen, host, ns);
      break;
    case -1:
      printf("erreur ni fils ni pere");
      break;
    default:
      close(ns);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x78(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1265 <main+0x75>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
mov    0x2d1f(%rip),%rcx
or     (%rcx),%eax
or     -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x48(%rbp),%rdx
lea    -0x50(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1319 <main+0x129>
mov    0x2cda(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <gai_strerror@plt>
mov    -0x8c(%rbp),%edi
mov    %rax,%rdx
lea    0xd13(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1398 <main+0x1a8>
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
mov    0x2c7c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1357 <main+0x167>
jmp    1387 <main+0x197>
mov    -0x14(%rbp),%edi
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%esi
mov    -0x58(%rbp),%rax
mov    0x4(%rax),%edx
call   10a0 <bind@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    137f <main+0x18f>
jmp    1398 <main+0x1a8>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0x58(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    1321 <main+0x131>
cmpq   $0x0,-0x58(%rbp)
jne    13bd <main+0x1cd>
lea    0xc80(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x50(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   1090 <listen@plt>
movl   $0x4,-0x64(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x60(%rbp),%rsi
lea    -0x64(%rbp),%rdx
call   10c0 <accept@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1411 <main+0x221>
lea    0xc31(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2ba6(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
xor    %eax,%eax
call   10f0 <fork@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0x90(%rbp)
sub    $0xffffffff,%eax
je     1460 <main+0x270>
jmp    1432 <main+0x242>
mov    -0x90(%rbp),%eax
test   %eax,%eax
jne    1473 <main+0x283>
jmp    1445 <main+0x255>
mov    -0x88(%rbp),%rdx
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    -0x1c(%rbp),%ecx
call   1070 <communication@plt>
jmp    147b <main+0x28b>
lea    0xbcf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    147b <main+0x28b>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
jmp    13d3 <main+0x1e3>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    0x2d9d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
cmp    $0x2,%edi
jne    12da <main+0xea>
lea    -0x68(%rbp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    0x2d93(%rip),%r15
mov    (%r15),%eax
mov    %eax,-0x44(%rbp)
mov    0x2d66(%rip),%r12
mov    0x2d87(%rip),%rax
mov    0x2d88(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    (%r12),%eax
mov    0x2d59(%rip),%rdx
or     (%rdx),%ecx
mov    %eax,-0x48(%rbp)
mov    %ecx,-0x68(%rbp)
movq   $0x0,-0x50(%rbp)
mov    0x8(%rbx),%rsi
lea    -0x38(%rbp),%rcx
xor    %edi,%edi
mov    %r14,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
jne    12ed <main+0xfd>
mov    -0x38(%rbp),%rbx
jmp    12a4 <main+0xb4>
nopl   0x0(%rax,%rax,1)
mov    0x10(%rbx),%rbx
test   %rbx,%rbx
je     1310 <main+0x120>
mov    (%r15),%edi
mov    (%r12),%esi
xor    %edx,%edx
call   1110 <socket@plt>
cmp    $0xffffffff,%eax
je     12a0 <main+0xb0>
mov    %eax,%r13d
mov    0x4(%rbx),%edx
mov    0x8(%rbx),%esi
mov    %eax,%edi
call   10a0 <bind@plt>
test   %eax,%eax
je     132a <main+0x13a>
mov    %r13d,%edi
call   1060 <close@plt>
jmp    12a0 <main+0xb0>
mov    (%rbx),%rsi
lea    0xd1c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    131c <main+0x12c>
mov    0x2ccc(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1040 <gai_strerror@plt>
lea    0xd15(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1080 <fprintf@plt>
jmp    131c <main+0x12c>
lea    0xd13(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x38(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
mov    %r13d,%edi
mov    $0x5,%esi
call   1090 <listen@plt>
movl   $0x4,-0x2c(%rbp)
lea    -0x30(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
mov    %r13d,%edi
call   10c0 <accept@plt>
cmp    $0xffffffff,%eax
jne    1365 <main+0x175>
lea    0xccc(%rip),%rdi
jmp    1317 <main+0x127>
mov    %eax,%r14d
lea    0xcc7(%rip),%r15
lea    -0x30(%rbp),%r12
lea    -0x2c(%rbp),%rbx
jmp    13a5 <main+0x1b5>
nopl   0x0(%rax)
mov    %r14d,%edi
call   1060 <close@plt>
movl   $0x4,-0x2c(%rbp)
mov    %r13d,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   10c0 <accept@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
je     135c <main+0x16c>
xor    %eax,%eax
call   10f0 <fork@plt>
cmp    $0xffffffff,%eax
je     13d0 <main+0x1e0>
test   %eax,%eax
jne    1380 <main+0x190>
mov    -0x2c(%rbp),%esi
mov    %r12,%rdi
mov    -0x40(%rbp),%rdx
mov    %r14d,%ecx
call   1070 <communication@plt>
jmp    1388 <main+0x198>
nopl   0x0(%rax)
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1388 <main+0x198>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, %struct.addrinfo*, i64, i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@NI_MAXHOST = global i32 0
@.str = [25 x i8] c"Usage: %s port_serveur\0A\00"
@EXIT_FAILURE = global i32 0
@AF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@AI_V4MAPPED = global i32 0
@AI_ALL = global i32 0
@stderr = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [5 x i8] c"bind\00"
@.str.3 = [7 x i8] c"accept\00"
@.str.4 = [23 x i8] c"erreur ni fils ni pere\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 %struct.addrinfo
%11 = alloca %struct.addrinfo*
%12 = alloca %struct.addrinfo*
%13 = alloca %struct.sockaddr_storage
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* @NI_MAXHOST
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %15
%21 = alloca i8, i64 %19
store i64 %19, i64* %16
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 2
br i1 %23, label %24, label %31
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %2
%32 = call i32 @memset(%struct.addrinfo* %10, i32 0, i32 40)
%33 = load i32, i32* @AF_INET6
%34 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 6
store i32 %33, i32* %34
%35 = load i32, i32* @SOCK_STREAM
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 5
store i32 %35, i32* %36
%37 = load i32, i32* @AI_PASSIVE
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 0
store i32 %37, i32* %38
%39 = load i32, i32* @AI_V4MAPPED
%40 = load i32, i32* @AI_ALL
%41 = or i32 %39, %40
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 0
%43 = load i32, i32* %42
%44 = or i32 %43, %41
store i32 %44, i32* %42
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 4
store i64 0, i64* %45
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
%49 = call i32 @getaddrinfo(i32* null, i8* %48, %struct.addrinfo* %10, %struct.addrinfo** %11)
store i32 %49, i32* %7
%50 = load i32, i32* %7
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %59
52: ; preds = %31
%53 = load i32, i32* @stderr
%54 = load i32, i32* %7
%55 = call i8* @gai_strerror(i32 %54)
%56 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %55)
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %31
%60 = load %struct.addrinfo*, %struct.addrinfo** %11
store %struct.addrinfo* %60, %struct.addrinfo** %12
br label %61
61: ; preds = %86, %59
%62 = load %struct.addrinfo*, %struct.addrinfo** %12
%63 = icmp ne %struct.addrinfo* %62, null
br i1 %63, label %64, label %90
64: ; preds = %61
%65 = load i32, i32* @AF_INET6
%66 = load i32, i32* @SOCK_STREAM
%67 = call i32 @socket(i32 %65, i32 %66, i32 0)
store i32 %67, i32* %6
%68 = load i32, i32* %6
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %71
70: ; preds = %64
br label %86
71: ; preds = %64
%72 = load i32, i32* %6
%73 = load %struct.addrinfo*, %struct.addrinfo** %12
%74 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %73, i32 0, i32 2
%75 = load i32, i32* %74
%76 = load %struct.addrinfo*, %struct.addrinfo** %12
%77 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %76, i32 0, i32 1
%78 = load i32, i32* %77
%79 = call i32 @bind(i32 %72, i32 %75, i32 %78)
store i32 %79, i32* %9
%80 = load i32, i32* %9
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %83
82: ; preds = %71
br label %90
83: ; preds = %71
%84 = load i32, i32* %6
%85 = call i32 @close(i32 %84)
br label %86
86: ; preds = %83, %70
%87 = load %struct.addrinfo*, %struct.addrinfo** %12
%88 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %87, i32 0, i32 3
%89 = load %struct.addrinfo*, %struct.addrinfo** %88
store %struct.addrinfo* %89, %struct.addrinfo** %12
br label %61
90: ; preds = %82, %61
%91 = load %struct.addrinfo*, %struct.addrinfo** %12
%92 = icmp eq %struct.addrinfo* %91, null
br i1 %92, label %93, label %97
93: ; preds = %90
%94 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%95 = load i32, i32* @EXIT_FAILURE
%96 = call i32 @exit(i32 %95)
unreachable
97: ; preds = %90
%98 = load %struct.addrinfo*, %struct.addrinfo** %11
%99 = call i32 @freeaddrinfo(%struct.addrinfo* %98)
%100 = load i32, i32* %6
%101 = call i32 @listen(i32 %100, i32 5)
br label %102
102: ; preds = %125, %97
store i32 4, i32* %14
%103 = load i32, i32* %6
%104 = bitcast %struct.sockaddr_storage* %13 to %struct.sockaddr*
%105 = call i32 @accept(i32 %103, %struct.sockaddr* %104, i32* %14)
store i32 %105, i32* %8
%106 = load i32, i32* %8
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %112
108: ; preds = %102
%109 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%110 = load i32, i32* @EXIT_FAILURE
%111 = call i32 @exit(i32 %110)
unreachable
112: ; preds = %102
%113 = call i32 (...) @fork()
store i32 %113, i32* %17
%114 = load i32, i32* %17
switch i32 %114, label %122 [
i32 0, label %115
i32 -1, label %120
]
115: ; preds = %112
%116 = bitcast %struct.sockaddr_storage* %13 to %struct.sockaddr*
%117 = load i32, i32* %14
%118 = load i32, i32* %8
%119 = call i32 @communication(%struct.sockaddr* %116, i32 %117, i8* %21, i32 %118)
br label %125
120: ; preds = %112
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %125
122: ; preds = %112
%123 = load i32, i32* %8
%124 = call i32 @close(i32 %123)
br label %125
125: ; preds = %122, %120, %115
br label %102
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, %struct.addrinfo*, i64, i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@NI_MAXHOST = global i32 0
@.str = [25 x i8] c"Usage: %s port_serveur\0A\00"
@EXIT_FAILURE = global i32 0
@AF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@AI_V4MAPPED = global i32 0
@AI_ALL = global i32 0
@stderr = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [5 x i8] c"bind\00"
@.str.3 = [7 x i8] c"accept\00"
@.str.4 = [23 x i8] c"erreur ni fils ni pere\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca %struct.sockaddr_storage
%6 = alloca i32
%7 = bitcast %struct.addrinfo* %3 to i8*
%8 = bitcast %struct.addrinfo** %4 to i8*
%9 = bitcast %struct.sockaddr_storage* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = load i32, i32* @NI_MAXHOST
%12 = zext i32 %11 to i64
%13 = alloca i8, i64 %12
%14 = icmp eq i32 %0, 2
br i1 %14, label %20, label %15
15: ; preds = %2
%16 = load i8*, i8** %1
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 40)
%22 = load i32, i32* @AF_INET6
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 6
store i32 %22, i32* %23
%24 = load i32, i32* @SOCK_STREAM
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 5
store i32 %24, i32* %25
%26 = load i32, i32* @AI_PASSIVE
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 0
%28 = load i32, i32* @AI_V4MAPPED
%29 = load i32, i32* @AI_ALL
%30 = or i32 %28, %26
%31 = or i32 %30, %29
store i32 %31, i32* %27
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i64 0, i64* %32
%33 = getelementptr inbounds i8*, i8** %1, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @getaddrinfo(i32* null, i8* %34, %struct.addrinfo* %3, %struct.addrinfo** %4)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %20
%38 = load %struct.addrinfo*, %struct.addrinfo** %4
%39 = icmp eq %struct.addrinfo* %38, null
br i1 %39, label %65, label %46
40: ; preds = %20
%41 = load i32, i32* @stderr
%42 = call i8* @gai_strerror(i32 %35)
%43 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %37, %61
%47 = phi %struct.addrinfo* [ %63, %61 ], [ %38, %37 ]
%48 = load i32, i32* @AF_INET6
%49 = load i32, i32* @SOCK_STREAM
%50 = call i32 @socket(i32 %48, i32 %49, i32 0)
%51 = icmp eq i32 %50, -1
br i1 %51, label %61, label %52
52: ; preds = %46
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %47, i64 0, i32 2
%54 = load i32, i32* %53
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %47, i64 0, i32 1
%56 = load i32, i32* %55
%57 = call i32 @bind(i32 %50, i32 %54, i32 %56)
%58 = icmp eq i32 %57, 0
br i1 %58, label %69, label %59
59: ; preds = %52
%60 = call i32 @close(i32 %50)
br label %61
61: ; preds = %46, %59
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %47, i64 0, i32 3
%63 = load %struct.addrinfo*, %struct.addrinfo** %62
%64 = icmp eq %struct.addrinfo* %63, null
br i1 %64, label %65, label %46
65: ; preds = %61, %37
%66 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%67 = load i32, i32* @EXIT_FAILURE
%68 = call i32 @exit(i32 %67)
unreachable
69: ; preds = %52
%70 = load %struct.addrinfo*, %struct.addrinfo** %4
%71 = call i32 @freeaddrinfo(%struct.addrinfo* %70)
%72 = call i32 @listen(i32 %50, i32 5)
%73 = bitcast %struct.sockaddr_storage* %5 to %struct.sockaddr*
store i32 4, i32* %6
%74 = call i32 @accept(i32 %50, %struct.sockaddr* %73, i32* %6)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %80
76: ; preds = %90, %69
%77 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%78 = load i32, i32* @EXIT_FAILURE
%79 = call i32 @exit(i32 %78)
unreachable
80: ; preds = %69, %90
%81 = phi i32 [ %91, %90 ], [ %74, %69 ]
%82 = call i32 (...) @fork()
switch i32 %82, label %88 [
i32 0, label %83
i32 -1, label %86
]
83: ; preds = %80
%84 = load i32, i32* %6
%85 = call i32 @communication(%struct.sockaddr* %73, i32 %84, i8* %13, i32 %81)
br label %90
86: ; preds = %80
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %90
88: ; preds = %80
%89 = call i32 @close(i32 %81)
br label %90
90: ; preds = %88, %86, %83
store i32 4, i32* %6
%91 = call i32 @accept(i32 %50, %struct.sockaddr* %73, i32* %6)
%92 = icmp eq i32 %91, -1
br i1 %92, label %76, label %80
}