#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_in6 {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  struct addrinfo *ai_next;
  int /*<<< orphan*/ ai_flags;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ hints;
typedef int /*<<< orphan*/ cli_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOMAXCONN;
int accept(int, struct sockaddr *, int *);
scalar_t__ bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errx(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ gai_strerror(int);
int getaddrinfo(int /*<<< orphan*/ *, char *, struct addrinfo *,
                struct addrinfo **);
scalar_t__ listen(int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int readline(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ usage();
int writen(int, char *, int, ...);
int main(int argc, char *argv[]) {
  int serverSocket, clientSocket, nsock;
  int n, retread, childpid, error;
  struct addrinfo hints, *res, *res0;
  socklen_t clilen;
  struct sockaddr_in6 cli_addr;
  char fromClient[80];
  char fromUser[80];
  if (argc != 2) {
    usage();
  }
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_INET6;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_PASSIVE;
  error = getaddrinfo(NULL, argv[1], &hints, &res0);
  if (error) {
    errx(1, "%s", gai_strerror(error));
  }
  nsock = 0;
  for (res = res0; res && nsock < 5; res = res->ai_next) {
    if ((serverSocket =
             socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) {
      perror("servecho : Probleme socket\n");
      exit(2);
    }
    if (bind(serverSocket, res->ai_addr, res->ai_addrlen) < 0) {
      perror("servecho: erreur bind\n");
      exit(1);
    }
    if (listen(serverSocket, SOMAXCONN) < 0) {
      perror("servecho: erreur listen\n");
      exit(1);
    }
    nsock++;
  }
  if (nsock == 0) {
    exit(1);
  }
  clilen = sizeof(cli_addr);
  clientSocket = accept(serverSocket, (struct sockaddr *)&cli_addr, &clilen);
  if (clientSocket < 0) {
    perror("servecho : erreur accept\n");
    exit(1);
  }
  if ((n = writen(clientSocket, "Bonjour\n", strlen("Bonjour\n"))) !=
      strlen("Bonjour\n")) {
    printf("erreur writen");
    exit(1);
  }
  while ((retread = readline(clientSocket, fromClient, 80)) > 0) {
    printf("corr: %s", fromClient);
    if (strcmp(fromClient, "Au revoir\n") == 0)
      break;
    printf("vous: ");
    if (fgets(fromUser, 80, stdin) == NULL) {
      perror("erreur fgets \n");
      exit(1);
    }
    if ((n = writen(clientSocket, fromUser, strlen(fromUser), 0)) !=
        strlen(fromUser)) {
      printf("erreur writen");
      exit(1);
    }
  }
  if (retread < 0) {
    perror("erreur readline \n");
    exit(1);
  }
  close(serverSocket);
  close(serverSocket);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     124a <main+0x2a>
mov    $0x0,%al
call   10d0 <usage@plt>
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2d53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x58(%rbp),%rdx
lea    -0x68(%rbp),%rcx
call   1130 <getaddrinfo@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     12bf <main+0x9f>
mov    -0x2c(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    %eax,%edx
mov    $0x1,%edi
lea    0xdc9(%rip),%rsi
call   1040 <errx@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x60(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x60(%rbp)
mov    %al,-0x111(%rbp)
je     12ee <main+0xce>
cmpl   $0x5,-0x1c(%rbp)
setl   %al
mov    %al,-0x111(%rbp)
mov    -0x111(%rbp),%al
test   $0x1,%al
jne    1301 <main+0xe1>
jmp    13bd <main+0x19d>
mov    -0x60(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x60(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x60(%rbp),%rax
mov    0x8(%rax),%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    133d <main+0x11d>
lea    0xcd2(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x2,%edi
call   1120 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x60(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x60(%rbp),%rax
mov    (%rax),%edx
call   10e0 <bind@plt>
cmp    $0x0,%rax
jge    1372 <main+0x152>
lea    0xcb9(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2c4c(%rip),%rax
mov    (%rax),%esi
call   10c0 <listen@plt>
cmp    $0x0,%rax
jge    13a3 <main+0x183>
lea    0xc9f(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x60(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x60(%rbp)
jmp    12ce <main+0xae>
cmpl   $0x0,-0x1c(%rbp)
jne    13d1 <main+0x1b1>
mov    $0x1,%edi
call   1120 <exit@plt>
movl   $0x4,-0x6c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x70(%rbp),%rsi
lea    -0x6c(%rbp),%rdx
call   1110 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    140b <main+0x1eb>
lea    0xc50(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x11c(%rbp)
lea    0xc4b(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x11c(%rbp),%edi
mov    %eax,%edx
lea    0xc37(%rip),%rsi
mov    $0x0,%al
call   1100 <writen@plt>
mov    %eax,-0x118(%rbp)
mov    %eax,-0x20(%rbp)
lea    0xc20(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x118(%rbp),%eax
cmp    %ecx,%eax
je     1473 <main+0x253>
lea    0xc0d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    1478 <main+0x258>
mov    -0x18(%rbp),%edi
lea    -0xc0(%rbp),%rsi
mov    $0x50,%edx
call   1080 <readline@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jle    1594 <main+0x374>
lea    -0xc0(%rbp),%rsi
lea    0xbd7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xc0(%rbp),%rdi
lea    0xbcb(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    14cf <main+0x2af>
jmp    1594 <main+0x374>
lea    0xbbb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    0x2af5(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
jne    1517 <main+0x2f7>
lea    0xb90(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x12c(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x110(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x12c(%rbp),%edi
mov    -0x128(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1100 <writen@plt>
mov    %eax,-0x120(%rbp)
mov    %eax,-0x20(%rbp)
lea    -0x110(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x120(%rbp),%eax
cmp    %ecx,%eax
je     158f <main+0x36f>
lea    0xaf1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    1478 <main+0x258>
cmpl   $0x0,-0x24(%rbp)
jge    15b4 <main+0x394>
lea    0xb02(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1240 <main+0x20>
xor    %eax,%eax
call   10d0 <usage@plt>
lea    0x18(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
mov    0x2d7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    0x2d58(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rsp)
mov    0x2d73(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x38(%rsp)
mov    0x8(%rbx),%rsi
lea    0x10(%rsp),%rcx
xor    %edi,%edi
mov    %rbp,%rdx
call   1130 <getaddrinfo@plt>
test   %eax,%eax
je     12ac <main+0x8c>
mov    %eax,%edi
call   1060 <gai_strerror@plt>
lea    0xde3(%rip),%rsi
mov    $0x1,%edi
mov    %eax,%edx
call   1040 <errx@plt>
mov    0x10(%rsp),%r14
test   %r14,%r14
je     14a3 <main+0x283>
xor    %ebx,%ebx
mov    0x2d05(%rip),%r15
mov    %r14,%rbp
cs nopw 0x0(%rax,%rax,1)
mov    0x10(%rbp),%edi
mov    0x8(%rbp),%edx
mov    0xc(%rbp),%esi
call   1140 <socket@plt>
test   %eax,%eax
js     146f <main+0x24f>
mov    %eax,%r12d
mov    0x0(%rbp),%edx
mov    0x4(%rbp),%esi
mov    %eax,%edi
call   10e0 <bind@plt>
test   %rax,%rax
js     1485 <main+0x265>
mov    (%r15),%esi
mov    %r12d,%edi
call   10c0 <listen@plt>
test   %rax,%rax
js     148e <main+0x26e>
mov    0x18(%rbp),%rbp
test   %rbp,%rbp
je     1326 <main+0x106>
lea    0x1(%rbx),%eax
cmp    $0x4,%ebx
mov    %eax,%ebx
jb     12d0 <main+0xb0>
test   %r14,%r14
je     14a3 <main+0x283>
movl   $0x4,0x4(%rsp)
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %r12d,%edi
call   1110 <accept@plt>
test   %eax,%eax
js     14ad <main+0x28d>
mov    %eax,%ebp
lea    0xd0c(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1100 <writen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%r15d
jne    1431 <main+0x211>
lea    0x90(%rsp),%r14
lea    0xcf3(%rip),%rbx
lea    0x40(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x50,%edx
call   1080 <readline@plt>
test   %eax,%eax
jle    1449 <main+0x229>
lea    0xcbf(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     144b <main+0x22b>
lea    0xcb2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2bf3(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    $0x50,%esi
call   10a0 <fgets@plt>
test   %rax,%rax
je     1497 <main+0x277>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1100 <writen@plt>
mov    %eax,%r13d
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    %eax,%r13d
je     13a0 <main+0x180>
lea    0xc37(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
js     14b6 <main+0x296>
mov    %r12d,%edi
call   1090 <close@plt>
mov    %r12d,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb8a(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x2,%edi
call   1120 <exit@plt>
lea    0xb90(%rip),%rdi
jmp    149e <main+0x27e>
lea    0xb9e(%rip),%rdi
jmp    149e <main+0x27e>
lea    0xbfa(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    0xb98(%rip),%rdi
jmp    149e <main+0x27e>
lea    0xbea(%rip),%rdi
jmp    149e <main+0x27e>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
%struct.sockaddr_in6 = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [28 x i8] c"servecho : Probleme socket\0A\00"
@.str.2 = [23 x i8] c"servecho: erreur bind\0A\00"
@SOMAXCONN = global i32 0
@.str.3 = [25 x i8] c"servecho: erreur listen\0A\00"
@.str.4 = [26 x i8] c"servecho : erreur accept\0A\00"
@.str.5 = [9 x i8] c"Bonjour\0A\00"
@.str.6 = [14 x i8] c"erreur writen\00"
@.str.7 = [9 x i8] c"corr: %s\00"
@.str.8 = [11 x i8] c"Au revoir\0A\00"
@.str.9 = [7 x i8] c"vous: \00"
@stdin = global i32 0
@.str.10 = [15 x i8] c"erreur fgets \0A\00"
@.str.11 = [18 x i8] c"erreur readline \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 i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.addrinfo
%14 = alloca %struct.addrinfo*
%15 = alloca %struct.addrinfo*
%16 = alloca i32
%17 = alloca %struct.sockaddr_in6
%18 = alloca [80 x i8]
%19 = alloca [80 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 2
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = call i32 (...) @usage()
br label %24
24: ; preds = %22, %2
%25 = call i32 @memset(%struct.addrinfo* %13, i32 0, i32 40)
%26 = load i32, i32* @AF_INET6
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %13, i32 0, i32 4
store i32 %26, i32* %27
%28 = load i32, i32* @SOCK_STREAM
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %13, i32 0, i32 3
store i32 %28, i32* %29
%30 = load i32, i32* @AI_PASSIVE
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %13, i32 0, i32 6
store i32 %30, i32* %31
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @getaddrinfo(i32* null, i8* %34, %struct.addrinfo* %13, %struct.addrinfo** %15)
store i32 %35, i32* %12
%36 = load i32, i32* %12
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %24
%39 = load i32, i32* %12
%40 = call i32 @gai_strerror(i32 %39)
%41 = call i32 @errx(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %38, %24
store i32 0, i32* %8
%43 = load %struct.addrinfo*, %struct.addrinfo** %15
store %struct.addrinfo* %43, %struct.addrinfo** %14
br label %44
44: ; preds = %91, %42
%45 = load %struct.addrinfo*, %struct.addrinfo** %14
%46 = icmp ne %struct.addrinfo* %45, null
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i32, i32* %8
%49 = icmp slt i32 %48, 5
br label %50
50: ; preds = %47, %44
%51 = phi i1 [ false, %44 ], [ %49, %47 ]
br i1 %51, label %52, label %95
52: ; preds = %50
%53 = load %struct.addrinfo*, %struct.addrinfo** %14
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i32 0, i32 4
%55 = load i32, i32* %54
%56 = load %struct.addrinfo*, %struct.addrinfo** %14
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 3
%58 = load i32, i32* %57
%59 = load %struct.addrinfo*, %struct.addrinfo** %14
%60 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %59, i32 0, i32 2
%61 = load i32, i32* %60
%62 = call i32 @socket(i32 %55, i32 %58, i32 %61)
store i32 %62, i32* %6
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %52
%65 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%66 = call i32 @exit(i32 2)
unreachable
67: ; preds = %52
%68 = load i32, i32* %6
%69 = load %struct.addrinfo*, %struct.addrinfo** %14
%70 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %69, i32 0, i32 1
%71 = load i32, i32* %70
%72 = load %struct.addrinfo*, %struct.addrinfo** %14
%73 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %72, i32 0, i32 0
%74 = load i32, i32* %73
%75 = call i64 @bind(i32 %68, i32 %71, i32 %74)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %67
%78 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %67
%81 = load i32, i32* %6
%82 = load i32, i32* @SOMAXCONN
%83 = call i64 @listen(i32 %81, i32 %82)
%84 = icmp slt i64 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %80
%86 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %80
%89 = load i32, i32* %8
%90 = add nsw i32 %89, 1
store i32 %90, i32* %8
br label %91
91: ; preds = %88
%92 = load %struct.addrinfo*, %struct.addrinfo** %14
%93 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %92, i32 0, i32 5
%94 = load %struct.addrinfo*, %struct.addrinfo** %93
store %struct.addrinfo* %94, %struct.addrinfo** %14
br label %44
95: ; preds = %50
%96 = load i32, i32* %8
%97 = icmp eq i32 %96, 0
br i1 %97, label %98, label %100
98: ; preds = %95
%99 = call i32 @exit(i32 1)
unreachable
100: ; preds = %95
store i32 4, i32* %16
%101 = load i32, i32* %6
%102 = bitcast %struct.sockaddr_in6* %17 to %struct.sockaddr*
%103 = call i32 @accept(i32 %101, %struct.sockaddr* %102, i32* %16)
store i32 %103, i32* %7
%104 = load i32, i32* %7
%105 = icmp slt i32 %104, 0
br i1 %105, label %106, label %109
106: ; preds = %100
%107 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%108 = call i32 @exit(i32 1)
unreachable
109: ; preds = %100
%110 = load i32, i32* %7
%111 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%112 = call i32 (i32, i8*, i32, ...) @writen(i32 %110, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %111)
store i32 %112, i32* %9
%113 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%114 = icmp ne i32 %112, %113
br i1 %114, label %115, label %118
115: ; preds = %109
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%117 = call i32 @exit(i32 1)
unreachable
118: ; preds = %109
br label %119
119: ; preds = %152, %118
%120 = load i32, i32* %7
%121 = getelementptr inbounds [80 x i8], [80 x i8]* %18, i64 0, i64 0
%122 = call i32 @readline(i32 %120, i8* %121, i32 80)
store i32 %122, i32* %10
%123 = icmp sgt i32 %122, 0
br i1 %123, label %124, label %153
124: ; preds = %119
%125 = getelementptr inbounds [80 x i8], [80 x i8]* %18, i64 0, i64 0
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %125)
%127 = getelementptr inbounds [80 x i8], [80 x i8]* %18, i64 0, i64 0
%128 = call i64 @strcmp(i8* %127, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%129 = icmp eq i64 %128, 0
br i1 %129, label %130, label %131
130: ; preds = %124
br label %153
131: ; preds = %124
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%133 = getelementptr inbounds [80 x i8], [80 x i8]* %19, i64 0, i64 0
%134 = load i32, i32* @stdin
%135 = call i32* @fgets(i8* %133, i32 80, i32 %134)
%136 = icmp eq i32* %135, null
br i1 %136, label %137, label %140
137: ; preds = %131
%138 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
%139 = call i32 @exit(i32 1)
unreachable
140: ; preds = %131
%141 = load i32, i32* %7
%142 = getelementptr inbounds [80 x i8], [80 x i8]* %19, i64 0, i64 0
%143 = getelementptr inbounds [80 x i8], [80 x i8]* %19, i64 0, i64 0
%144 = call i32 @strlen(i8* %143)
%145 = call i32 (i32, i8*, i32, ...) @writen(i32 %141, i8* %142, i32 %144, i32 0)
store i32 %145, i32* %9
%146 = getelementptr inbounds [80 x i8], [80 x i8]* %19, i64 0, i64 0
%147 = call i32 @strlen(i8* %146)
%148 = icmp ne i32 %145, %147
br i1 %148, label %149, label %152
149: ; preds = %140
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%151 = call i32 @exit(i32 1)
unreachable
152: ; preds = %140
br label %119
153: ; preds = %130, %119
%154 = load i32, i32* %10
%155 = icmp slt i32 %154, 0
br i1 %155, label %156, label %159
156: ; preds = %153
%157 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%158 = call i32 @exit(i32 1)
unreachable
159: ; preds = %153
%160 = load i32, i32* %6
%161 = call i32 @close(i32 %160)
%162 = load i32, i32* %6
%163 = call i32 @close(i32 %162)
%164 = load i32, i32* %3
ret i32 %164
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
%struct.sockaddr_in6 = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [28 x i8] c"servecho : Probleme socket\0A\00"
@.str.2 = [23 x i8] c"servecho: erreur bind\0A\00"
@SOMAXCONN = global i32 0
@.str.3 = [25 x i8] c"servecho: erreur listen\0A\00"
@.str.4 = [26 x i8] c"servecho : erreur accept\0A\00"
@.str.5 = [9 x i8] c"Bonjour\0A\00"
@.str.6 = [14 x i8] c"erreur writen\00"
@.str.7 = [9 x i8] c"corr: %s\00"
@.str.8 = [11 x i8] c"Au revoir\0A\00"
@.str.9 = [7 x i8] c"vous: \00"
@stdin = global i32 0
@.str.10 = [15 x i8] c"erreur fgets \0A\00"
@.str.11 = [18 x i8] c"erreur readline \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca i32
%6 = alloca %struct.sockaddr_in6
%7 = alloca [80 x i8]
%8 = alloca [80 x i8]
%9 = bitcast %struct.addrinfo* %3 to i8*
%10 = bitcast %struct.addrinfo** %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast %struct.sockaddr_in6* %6 to i8*
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%15 = icmp eq i32 %0, 2
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = tail call i32 (...) @usage()
br label %18
18: ; preds = %16, %2
%19 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 40)
%20 = load i32, i32* @AF_INET6
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %20, i32* %21
%22 = load i32, i32* @SOCK_STREAM
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %22, i32* %23
%24 = load i32, i32* @AI_PASSIVE
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 6
store i32 %24, i32* %25
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @getaddrinfo(i32* null, i8* %27, %struct.addrinfo* %3, %struct.addrinfo** %4)
%29 = icmp eq i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %18
%31 = call i32 @gai_strerror(i32 %28)
%32 = call i32 @errx(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %18
%34 = load %struct.addrinfo*, %struct.addrinfo** %4
%35 = icmp eq %struct.addrinfo* %34, null
br i1 %35, label %75, label %36
36: ; preds = %33, %67
%37 = phi %struct.addrinfo* [ %70, %67 ], [ %34, %33 ]
%38 = phi i32 [ %68, %67 ], [ 0, %33 ]
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 4
%40 = load i32, i32* %39
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 3
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 2
%44 = load i32, i32* %43
%45 = call i32 @socket(i32 %40, i32 %42, i32 %44)
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %36
%48 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%49 = call i32 @exit(i32 2)
unreachable
50: ; preds = %36
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 1
%52 = load i32, i32* %51
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 0
%54 = load i32, i32* %53
%55 = call i64 @bind(i32 %45, i32 %52, i32 %54)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %50
%58 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%59 = call i32 @exit(i32 1)
unreachable
60: ; preds = %50
%61 = load i32, i32* @SOMAXCONN
%62 = call i64 @listen(i32 %45, i32 %61)
%63 = icmp slt i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %60
%68 = add nuw nsw i32 %38, 1
%69 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 5
%70 = load %struct.addrinfo*, %struct.addrinfo** %69
%71 = icmp ne %struct.addrinfo* %70, null
%72 = icmp ult i32 %38, 4
%73 = select i1 %71, i1 %72, i1 false
br i1 %73, label %36, label %74
74: ; preds = %67
br i1 %35, label %75, label %77
75: ; preds = %33, %74
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %74
store i32 4, i32* %5
%78 = bitcast %struct.sockaddr_in6* %6 to %struct.sockaddr*
%79 = call i32 @accept(i32 %45, %struct.sockaddr* %78, i32* %5)
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %77
%82 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %77
%85 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%86 = call i32 (i32, i8*, i32, ...) @writen(i32 %79, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %85)
%87 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%88 = icmp eq i32 %86, %87
br i1 %88, label %92, label %89
89: ; preds = %84
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %84, %107
%93 = call i32 @readline(i32 %79, i8* %13, i32 80)
%94 = icmp sgt i32 %93, 0
br i1 %94, label %95, label %115
95: ; preds = %92
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %13)
%97 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%98 = icmp eq i64 %97, 0
br i1 %98, label %120, label %99
99: ; preds = %95
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%101 = load i32, i32* @stdin
%102 = call i32* @fgets(i8* %14, i32 80, i32 %101)
%103 = icmp eq i32* %102, null
br i1 %103, label %104, label %107
104: ; preds = %99
%105 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
%106 = call i32 @exit(i32 1)
unreachable
107: ; preds = %99
%108 = call i32 @strlen(i8* %14)
%109 = call i32 (i32, i8*, i32, ...) @writen(i32 %79, i8* %14, i32 %108, i32 0)
%110 = call i32 @strlen(i8* %14)
%111 = icmp eq i32 %109, %110
br i1 %111, label %92, label %112
112: ; preds = %107
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%114 = call i32 @exit(i32 1)
unreachable
115: ; preds = %92
%116 = icmp slt i32 %93, 0
br i1 %116, label %117, label %120
117: ; preds = %115
%118 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%119 = call i32 @exit(i32 1)
unreachable
120: ; preds = %95, %115
%121 = call i32 @close(i32 %45)
%122 = call i32 @close(i32 %45)
ret i32 0
}