#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 in6_addr {
  int dummy;
};
struct sockaddr_in6 {
  int /*<<< orphan*/ sin6_port;
  struct in6_addr sin6_addr;
  int /*<<< orphan*/ sin6_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ cli_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOMAXCONN;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
scalar_t__ listen(int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, 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[]) {
  extern const struct in6_addr in6addr_any;
  int serverSocket, clientSocket;
  int n, retread, childpid;
  socklen_t clilen;
  struct sockaddr_in6 serv_addr, cli_addr;
  char fromClient[80];
  char fromUser[80];
  if (argc != 2) {
    usage();
    exit(1);
  }
  if ((serverSocket = socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
    perror("servecho : Probleme socket\n");
    exit(2);
  }
  memset((char *)&serv_addr, 0, sizeof(serv_addr));
  serv_addr.sin6_family = AF_INET6;
  serv_addr.sin6_addr = in6addr_any;
  serv_addr.sin6_port = htons(atoi(argv[1]));
  if (bind(serverSocket, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) <
      0) {
    perror("servecho: erreur bind\n");
    exit(1);
  }
  if (listen(serverSocket, SOMAXCONN) < 0) {
    perror("servecho: erreur listen\n");
    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");
  }
  close(serverSocket);
  close(serverSocket);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1244 <main+0x34>
mov    $0x0,%al
call   10c0 <usage@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
mov    0x2d74(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    127f <main+0x6f>
lea    0xd90(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x2,%edi
call   1120 <exit@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1110 <atoi@plt>
mov    %eax,%edi
call   1040 <htons@plt>
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
jge    12ef <main+0xdf>
lea    0xd3c(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2cd7(%rip),%rax
mov    (%rax),%esi
call   10b0 <listen@plt>
cmp    $0x0,%rax
jge    1320 <main+0x110>
lea    0xd22(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
movl   $0xc,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x48(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    135a <main+0x14a>
lea    0xd01(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0xf8(%rbp)
lea    0xcfc(%rip),%rdi
call   1030 <strlen@plt>
mov    -0xf8(%rbp),%edi
mov    %eax,%edx
lea    0xce8(%rip),%rsi
mov    $0x0,%al
call   10f0 <writen@plt>
mov    %eax,-0xf4(%rbp)
mov    %eax,-0x1c(%rbp)
lea    0xcd1(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xf4(%rbp),%eax
cmp    %ecx,%eax
je     13c2 <main+0x1b2>
lea    0xcbe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    13c7 <main+0x1b7>
mov    -0x18(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x50,%edx
call   1070 <readline@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jle    14e3 <main+0x2d3>
lea    -0xa0(%rbp),%rsi
lea    0xc88(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xc7c(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    141e <main+0x20e>
jmp    14e3 <main+0x2d3>
lea    0xc6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xf0(%rbp),%rdi
mov    0x2bae(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
jne    1466 <main+0x256>
lea    0xc41(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x10c(%rbp)
lea    -0xf0(%rbp),%rax
mov    %rax,-0x108(%rbp)
lea    -0xf0(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x10c(%rbp),%edi
mov    -0x108(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   10f0 <writen@plt>
mov    %eax,-0xfc(%rbp)
mov    %eax,-0x1c(%rbp)
lea    -0xf0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xfc(%rbp),%eax
cmp    %ecx,%eax
je     14de <main+0x2ce>
lea    0xba2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    13c7 <main+0x1b7>
cmpl   $0x0,-0x20(%rbp)
jge    14f9 <main+0x2e9>
lea    0xbb3(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
cmp    $0x2,%edi
jne    141c <main+0x20c>
mov    %rsi,%rbp
mov    0x2dac(%rip),%r15
mov    (%r15),%edi
mov    0x2d8a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
test   %eax,%eax
js     142d <main+0x21d>
mov    %eax,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    (%r15),%eax
mov    %eax,0x18(%rsp)
mov    0x2d4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    0x8(%rbp),%rdi
call   1110 <atoi@plt>
mov    %eax,%edi
call   1040 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
test   %rax,%rax
js     1443 <main+0x233>
mov    0x2d24(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   10b0 <listen@plt>
test   %rax,%rax
js     144c <main+0x23c>
movl   $0xc,0xc(%rsp)
lea    0x20(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   1100 <accept@plt>
test   %eax,%eax
js     1455 <main+0x245>
mov    %eax,%ebp
mov    %ebx,0x8(%rsp)
lea    0xd7a(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10f0 <writen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebx
jne    13b8 <main+0x1a8>
lea    0x80(%rsp),%rbx
lea    0xd63(%rip),%r12
mov    0x2cbe(%rip),%r13
lea    0x30(%rsp),%r14
nop
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x50,%edx
call   1070 <readline@plt>
test   %eax,%eax
jle    13d0 <main+0x1c0>
lea    0xd2f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     13d2 <main+0x1c2>
lea    0xd22(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%r13),%edx
mov    %r14,%rdi
mov    $0x50,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     1406 <main+0x1f6>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   10f0 <writen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%r15d
je     1330 <main+0x120>
lea    0xcb0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
js     13f8 <main+0x1e8>
mov    0x8(%rsp),%ebx
mov    %ebx,%edi
call   1080 <close@plt>
mov    %ebx,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xca8(%rip),%rdi
call   10e0 <perror@plt>
jmp    13d2 <main+0x1c2>
lea    0xc8b(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
xor    %eax,%eax
call   10c0 <usage@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    0xbcc(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x2,%edi
call   1120 <exit@plt>
lea    0xbd2(%rip),%rdi
jmp    140d <main+0x1fd>
lea    0xbe0(%rip),%rdi
jmp    140d <main+0x1fd>
lea    0xbf0(%rip),%rdi
jmp    140d <main+0x1fd>

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

LLVM IR (-O2):
%struct.in6_addr = type { i32 }
%struct.sockaddr_in6 = type { i32, %struct.in6_addr, i32 }
%struct.sockaddr = type { i32 }
@AF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@.str = [28 x i8] c"servecho : Probleme socket\0A\00"
@in6addr_any = external constant %struct.in6_addr
@.str.1 = [23 x i8] c"servecho: erreur bind\0A\00"
@SOMAXCONN = global i32 0
@.str.2 = [25 x i8] c"servecho: erreur listen\0A\00"
@.str.3 = [26 x i8] c"servecho : erreur accept\0A\00"
@.str.4 = [9 x i8] c"Bonjour\0A\00"
@.str.5 = [14 x i8] c"erreur writen\00"
@.str.6 = [9 x i8] c"corr: %s\00"
@.str.7 = [11 x i8] c"Au revoir\0A\00"
@.str.8 = [7 x i8] c"vous: \00"
@stdin = global i32 0
@.str.9 = [15 x i8] c"erreur fgets \0A\00"
@.str.10 = [18 x i8] c"erreur readline \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in6
%5 = alloca %struct.sockaddr_in6
%6 = alloca [80 x i8]
%7 = alloca [80 x i8]
%8 = bitcast i32* %3 to i8*
%9 = bitcast %struct.sockaddr_in6* %4 to i8*
%10 = bitcast %struct.sockaddr_in6* %5 to i8*
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%13 = icmp eq i32 %0, 2
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = tail call i32 (...) @usage()
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i32, i32* @AF_INET6
%19 = load i32, i32* @SOCK_STREAM
%20 = tail call i32 @socket(i32 %18, i32 %19, i32 0)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%24 = tail call i32 @exit(i32 2)
unreachable
25: ; preds = %17
%26 = call i32 @memset(i8* %9, i32 0, i32 12)
%27 = load i32, i32* @AF_INET6
%28 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i64 0, i32 2
store i32 %27, i32* %28
%29 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i64 0, i32 1, i32 0
%30 = load i32, i32* getelementptr inbounds (%struct.in6_addr, %struct.in6_addr* @in6addr_any, i64 0, i32 0)
store i32 %30, i32* %29
%31 = getelementptr inbounds i8*, i8** %1, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
%34 = call i32 @htons(i32 %33)
%35 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i64 0, i32 0
store i32 %34, i32* %35
%36 = bitcast %struct.sockaddr_in6* %4 to %struct.sockaddr*
%37 = call i64 @bind(i32 %20, %struct.sockaddr* %36, i32 12)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %25
%40 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %25
%43 = load i32, i32* @SOMAXCONN
%44 = call i64 @listen(i32 %20, i32 %43)
%45 = icmp slt i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %42
store i32 12, i32* %3
%50 = bitcast %struct.sockaddr_in6* %5 to %struct.sockaddr*
%51 = call i32 @accept(i32 %20, %struct.sockaddr* %50, i32* %3)
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %49
%57 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%58 = call i32 (i32, i8*, i32, ...) @writen(i32 %51, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %57)
%59 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%60 = icmp eq i32 %58, %59
br i1 %60, label %64, label %61
61: ; preds = %56
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %56, %79
%65 = call i32 @readline(i32 %51, i8* %11, i32 80)
%66 = icmp sgt i32 %65, 0
br i1 %66, label %67, label %87
67: ; preds = %64
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %11)
%69 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %91, label %71
71: ; preds = %67
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%73 = load i32, i32* @stdin
%74 = call i32* @fgets(i8* %12, i32 80, i32 %73)
%75 = icmp eq i32* %74, null
br i1 %75, label %76, label %79
76: ; preds = %71
%77 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %71
%80 = call i32 @strlen(i8* %12)
%81 = call i32 (i32, i8*, i32, ...) @writen(i32 %51, i8* %12, i32 %80, i32 0)
%82 = call i32 @strlen(i8* %12)
%83 = icmp eq i32 %81, %82
br i1 %83, label %64, label %84
84: ; preds = %79
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %64
%88 = icmp slt i32 %65, 0
br i1 %88, label %89, label %91
89: ; preds = %87
%90 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
br label %91
91: ; preds = %67, %89, %87
%92 = call i32 @close(i32 %20)
%93 = call i32 @close(i32 %20)
ret i32 0
}