#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*/ serv_addr;
typedef int /*<<< orphan*/ cli_addr;

/* Variables and functions */
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ PF_INET;
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*/ htonl(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[]) {
  int serverSocket, clientSocket;
  int n, retread, childpid;
  socklen_t clilen;
  struct sockaddr_in serv_addr, cli_addr;
  char fromClient[80];
  char fromUser[80];
  if (argc != 2) {
    usage();
    exit(1);
  }
  if ((serverSocket = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
    perror("servecho : Probleme socket\n");
    exit(2);
  }
  memset((char *)&serv_addr, 0, sizeof(serv_addr));
  serv_addr.sin_family = PF_INET;
  serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  serv_addr.sin_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     1254 <main+0x34>
mov    $0x0,%al
call   10d0 <usage@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
mov    0x2d64(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    128f <main+0x6f>
lea    0xd80(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x2,%edi
call   1130 <exit@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1120 <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   10e0 <bind@plt>
cmp    $0x0,%rax
jge    1304 <main+0xe4>
lea    0xd27(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2cc2(%rip),%rax
mov    (%rax),%esi
call   10c0 <listen@plt>
cmp    $0x0,%rax
jge    1335 <main+0x115>
lea    0xd0d(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
movl   $0xc,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x48(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1110 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    136f <main+0x14f>
lea    0xcec(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0xf8(%rbp)
lea    0xce7(%rip),%rdi
call   1030 <strlen@plt>
mov    -0xf8(%rbp),%edi
mov    %eax,%edx
lea    0xcd3(%rip),%rsi
mov    $0x0,%al
call   1100 <writen@plt>
mov    %eax,-0xf4(%rbp)
mov    %eax,-0x1c(%rbp)
lea    0xcbc(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xf4(%rbp),%eax
cmp    %ecx,%eax
je     13d7 <main+0x1b7>
lea    0xca9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    13dc <main+0x1bc>
mov    -0x18(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x50,%edx
call   1080 <readline@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jle    14f8 <main+0x2d8>
lea    -0xa0(%rbp),%rsi
lea    0xc73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xc67(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1433 <main+0x213>
jmp    14f8 <main+0x2d8>
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xf0(%rbp),%rdi
mov    0x2b99(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
jne    147b <main+0x25b>
lea    0xc2c(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <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   1100 <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     14f3 <main+0x2d3>
lea    0xb8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    13dc <main+0x1bc>
cmpl   $0x0,-0x20(%rbp)
jge    150e <main+0x2ee>
lea    0xb9e(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
mov    -0x14(%rbp),%edi
call   1090 <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    143c <main+0x21c>
mov    %rsi,%rbp
mov    0x2d7c(%rip),%r15
mov    (%r15),%edi
mov    0x2d7a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
test   %eax,%eax
js     144d <main+0x22d>
mov    %eax,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    (%r15),%eax
mov    %eax,0x18(%rsp)
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,0x14(%rsp)
mov    0x8(%rbp),%rdi
call   1120 <atoi@plt>
mov    %eax,%edi
call   1040 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
test   %rax,%rax
js     1463 <main+0x243>
mov    0x2d0f(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   10c0 <listen@plt>
test   %rax,%rax
js     146c <main+0x24c>
movl   $0xc,0xc(%rsp)
lea    0x20(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   1110 <accept@plt>
test   %eax,%eax
js     1475 <main+0x255>
mov    %eax,%ebp
mov    %ebx,0x8(%rsp)
lea    0xd65(%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,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebx
jne    13d8 <main+0x1b8>
lea    0x80(%rsp),%rbx
lea    0xd4e(%rip),%r12
mov    0x2ca9(%rip),%r13
lea    0x30(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x50,%edx
call   1080 <readline@plt>
test   %eax,%eax
jle    13f0 <main+0x1d0>
lea    0xd0f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     13f2 <main+0x1d2>
lea    0xd02(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%r13),%edx
mov    %r14,%rdi
mov    $0x50,%esi
call   10a0 <fgets@plt>
test   %rax,%rax
je     1426 <main+0x206>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1100 <writen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%r15d
je     1350 <main+0x130>
lea    0xc90(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
js     1418 <main+0x1f8>
mov    0x8(%rsp),%ebx
mov    %ebx,%edi
call   1090 <close@plt>
mov    %ebx,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc88(%rip),%rdi
call   10f0 <perror@plt>
jmp    13f2 <main+0x1d2>
lea    0xc6b(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
xor    %eax,%eax
call   10d0 <usage@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xbac(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x2,%edi
call   1130 <exit@plt>
lea    0xbb2(%rip),%rdi
jmp    142d <main+0x20d>
lea    0xbc0(%rip),%rdi
jmp    142d <main+0x20d>
lea    0xbd0(%rip),%rdi
jmp    142d <main+0x20d>

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

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
@.str = [28 x i8] c"servecho : Probleme socket\0A\00"
@INADDR_ANY = global i32 0
@.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_in
%5 = alloca %struct.sockaddr_in
%6 = alloca [80 x i8]
%7 = alloca [80 x i8]
%8 = bitcast i32* %3 to i8*
%9 = bitcast %struct.sockaddr_in* %4 to i8*
%10 = bitcast %struct.sockaddr_in* %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* @PF_INET
%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* @PF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %27, i32* %28
%29 = load i32, i32* @INADDR_ANY
%30 = call i32 @htonl(i32 %29)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %30, i32* %31
%32 = getelementptr inbounds i8*, i8** %1, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
%35 = call i32 @htons(i32 %34)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %35, i32* %36
%37 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%38 = call i64 @bind(i32 %20, %struct.sockaddr* %37, i32 12)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %25
%41 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %25
%44 = load i32, i32* @SOMAXCONN
%45 = call i64 @listen(i32 %20, i32 %44)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %43
store i32 12, i32* %3
%51 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%52 = call i32 @accept(i32 %20, %struct.sockaddr* %51, i32* %3)
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %50
%58 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%59 = call i32 (i32, i8*, i32, ...) @writen(i32 %52, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %58)
%60 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%61 = icmp eq i32 %59, %60
br i1 %61, label %65, label %62
62: ; preds = %57
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %57, %80
%66 = call i32 @readline(i32 %52, i8* %11, i32 80)
%67 = icmp sgt i32 %66, 0
br i1 %67, label %68, label %88
68: ; preds = %65
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %11)
%70 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %92, label %72
72: ; preds = %68
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%74 = load i32, i32* @stdin
%75 = call i32* @fgets(i8* %12, i32 80, i32 %74)
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %80
77: ; preds = %72
%78 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %72
%81 = call i32 @strlen(i8* %12)
%82 = call i32 (i32, i8*, i32, ...) @writen(i32 %52, i8* %12, i32 %81, i32 0)
%83 = call i32 @strlen(i8* %12)
%84 = icmp eq i32 %82, %83
br i1 %84, label %65, label %85
85: ; preds = %80
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %65
%89 = icmp slt i32 %66, 0
br i1 %89, label %90, label %92
90: ; preds = %88
%91 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
br label %92
92: ; preds = %68, %90, %88
%93 = call i32 @close(i32 %20)
%94 = call i32 @close(i32 %20)
ret i32 0
}