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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int mkfifo(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ traiter(int, int);
int /*<<< orphan*/ unlink(char *);
int main(void) {
  int fdq, fdr;
  unlink("cli2serv");
  unlink("serv2cli");
  if (mkfifo("cli2serv", 0644) == -1 || mkfifo("serv2cli", 0644) == -1) {
    perror("Impossible de créer les tubes");
    exit(EXIT_FAILURE);
  }
  fdq = open("cli2serv", O_RDONLY);
  if (fdq == -1) {
    fprintf(stderr, "Impossible d\'ouvrir le tube %s\n", "cli2serv");
    exit(EXIT_FAILURE);
  }
  fdr = open("serv2cli", O_WRONLY);
  if (fdr == -1) {
    fprintf(stderr, "Impossible d\'ouvrir le tube %s\n", "serv2cli");
    exit(EXIT_FAILURE);
  }
  traiter(fdr, fdq);
  close(fdq);
  close(fdr);
  unlink("cli2serv");
  unlink("serv2cli");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
call   1030 <unlink@plt>
lea    0xe67(%rip),%rdi
call   1030 <unlink@plt>
lea    0xe52(%rip),%rdi
mov    $0x1a4,%esi
call   1070 <mkfifo@plt>
cmp    $0xffffffff,%eax
je     11db <main+0x5b>
lea    0xe41(%rip),%rdi
mov    $0x1a4,%esi
call   1070 <mkfifo@plt>
cmp    $0xffffffff,%eax
jne    11f5 <main+0x75>
lea    0xe30(%rip),%rdi
call   1090 <perror@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%esi
lea    0xdfb(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1241 <main+0xc1>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xe0a(%rip),%rsi
lea    0xdd2(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%esi
lea    0xdb8(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    128d <main+0x10d>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xdbe(%rip),%rsi
lea    0xd8f(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <traiter@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
lea    0xd51(%rip),%rdi
call   1030 <unlink@plt>
lea    0xd4e(%rip),%rdi
call   1030 <unlink@plt>
mov    0x2d01(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe76(%rip),%rbx
mov    %rbx,%rdi
call   1030 <unlink@plt>
lea    0xe70(%rip),%rdi
call   1030 <unlink@plt>
mov    %rbx,%rdi
mov    $0x1a4,%esi
call   1070 <mkfifo@plt>
cmp    $0xffffffff,%eax
je     11c6 <main+0x46>
lea    0xe52(%rip),%rdi
mov    $0x1a4,%esi
call   1070 <mkfifo@plt>
cmp    $0xffffffff,%eax
jne    11d4 <main+0x54>
lea    0xe45(%rip),%rdi
call   1090 <perror@plt>
jmp    123f <main+0xbf>
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
lea    0xe1c(%rip),%rdi
call   1080 <open@plt>
cmp    $0xffffffff,%eax
jne    1207 <main+0x87>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
lea    0xdfb(%rip),%rdx
jmp    123a <main+0xba>
mov    %eax,%ebx
mov    0x2da8(%rip),%rax
mov    (%rax),%esi
lea    0xdf0(%rip),%rdi
call   1080 <open@plt>
cmp    $0xffffffff,%eax
jne    124d <main+0xcd>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
lea    0xdfe(%rip),%rsi
lea    0xdcf(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %ebx,%esi
call   1050 <traiter@plt>
mov    %ebx,%edi
call   1040 <close@plt>
mov    %ebp,%edi
call   1040 <close@plt>
lea    0xd93(%rip),%rdi
call   1030 <unlink@plt>
lea    0xd90(%rip),%rdi
call   1030 <unlink@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"cli2serv\00"
@.str.1 = [9 x i8] c"serv2cli\00"
@.str.2 = [31 x i8] c"Impossible de cr\C3\A9er les tubes\00"
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.3 = [32 x i8] c"Impossible d'ouvrir le tube %s\0A\00"
@O_WRONLY = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @mkfifo(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 420)
%7 = icmp eq i32 %6, -1
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = call i32 @mkfifo(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 420)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %15
11: ; preds = %8, %0
%12 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %8
%16 = load i32, i32* @O_RDONLY
%17 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %16)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %15
%26 = load i32, i32* @O_WRONLY
%27 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %26)
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %25
%36 = load i32, i32* %3
%37 = load i32, i32* %2
%38 = call i32 @traiter(i32 %36, i32 %37)
%39 = load i32, i32* %2
%40 = call i32 @close(i32 %39)
%41 = load i32, i32* %3
%42 = call i32 @close(i32 %41)
%43 = call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%44 = call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%45 = load i32, i32* @EXIT_SUCCESS
%46 = call i32 @exit(i32 %45)
unreachable
}

LLVM IR (-O2):
@.str = [9 x i8] c"cli2serv\00"
@.str.1 = [9 x i8] c"serv2cli\00"
@.str.2 = [31 x i8] c"Impossible de cr\C3\A9er les tubes\00"
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.3 = [32 x i8] c"Impossible d'ouvrir le tube %s\0A\00"
@O_WRONLY = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @mkfifo(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 420)
%4 = icmp eq i32 %3, -1
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = tail call i32 @mkfifo(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 420)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %12
8: ; preds = %5, %0
%9 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %5
%13 = load i32, i32* @O_RDONLY
%14 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %12
%22 = load i32, i32* @O_WRONLY
%23 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = tail call i32 @exit(i32 %28)
unreachable
30: ; preds = %21
%31 = tail call i32 @traiter(i32 %23, i32 %14)
%32 = tail call i32 @close(i32 %14)
%33 = tail call i32 @close(i32 %23)
%34 = tail call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%35 = tail call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* @EXIT_SUCCESS
%37 = tail call i32 @exit(i32 %36)
unreachable
}