#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 EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int remove(char *);
int rename(char *, char *);
double temps_CPU();
int /*<<< orphan*/ tri_externe(char *);
int main(int argc, char *argv[]) {
  double START, END;
  START = temps_CPU();
  int boolean;
  if (3 > argc) {
    printf("USAGE: %s <fichier a trier.bin> <nom du fichier trie.bin>\n",
           argv[0]);
    exit(0);
  }
  tri_externe(argv[1]);
  boolean = rename("f1", argv[2]);
  if (0 != boolean)
    perror("le renomage a echoue");
  boolean = remove("f2");
  if (0 != boolean)
    perror("la suppression a echoue");
  boolean = remove("f3");
  if (0 != boolean)
    perror("la suppression a echoue");
  boolean = remove("f4");
  if (0 != boolean)
    perror("la suppression a echoue");
  END = temps_CPU();
  printf("Tri execute avec succes. CPU time : %.4f s\n", END - START);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <temps_CPU@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x3,%eax
cmp    -0x8(%rbp),%eax
jle    11bc <main+0x4c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <tri_externe@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe63(%rip),%rdi
call   1080 <rename@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
je     11f7 <main+0x87>
lea    0xe4c(%rip),%rdi
call   1070 <perror@plt>
lea    0xe55(%rip),%rdi
call   1040 <remove@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
je     121d <main+0xad>
lea    0xe3e(%rip),%rdi
call   1070 <perror@plt>
lea    0xe4a(%rip),%rdi
call   1040 <remove@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
je     1243 <main+0xd3>
lea    0xe18(%rip),%rdi
call   1070 <perror@plt>
lea    0xe27(%rip),%rdi
call   1040 <remove@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
je     1269 <main+0xf9>
lea    0xdf2(%rip),%rdi
call   1070 <perror@plt>
mov    $0x0,%al
call   1060 <temps_CPU@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xdee(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1060 <temps_CPU@plt>
movsd  %xmm0,(%rsp)
cmp    $0x2,%ebp
jle    123c <main+0xcc>
mov    0x8(%rbx),%rdi
call   1030 <tri_externe@plt>
mov    0x10(%rbx),%rsi
lea    0xe9a(%rip),%rdi
call   1080 <rename@plt>
test   %eax,%eax
jne    1204 <main+0x94>
lea    0xea2(%rip),%rdi
call   1040 <remove@plt>
test   %eax,%eax
jne    1212 <main+0xa2>
lea    0xead(%rip),%rdi
call   1040 <remove@plt>
test   %eax,%eax
jne    1220 <main+0xb0>
lea    0xea0(%rip),%rdi
call   1040 <remove@plt>
test   %eax,%eax
jne    122e <main+0xbe>
xor    %eax,%eax
call   1060 <temps_CPU@plt>
subsd  (%rsp),%xmm0
lea    0xe87(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe33(%rip),%rdi
call   1070 <perror@plt>
jmp    11aa <main+0x3a>
lea    0xe3d(%rip),%rdi
call   1070 <perror@plt>
jmp    11ba <main+0x4a>
lea    0xe2f(%rip),%rdi
call   1070 <perror@plt>
jmp    11ca <main+0x5a>
lea    0xe21(%rip),%rdi
call   1070 <perror@plt>
jmp    11da <main+0x6a>
mov    (%rbx),%rsi
lea    0xdba(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [59 x i8] c"USAGE: %s <fichier a trier.bin> <nom du fichier trie.bin>\0A\00"
@.str.1 = [3 x i8] c"f1\00"
@.str.2 = [21 x i8] c"le renomage a echoue\00"
@.str.3 = [3 x i8] c"f2\00"
@.str.4 = [24 x i8] c"la suppression a echoue\00"
@.str.5 = [3 x i8] c"f3\00"
@.str.6 = [3 x i8] c"f4\00"
@.str.7 = [44 x i8] c"Tri execute avec succes. CPU time : %.4f s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call double (...) @temps_CPU()
store double %9, double* %6
%10 = load i32, i32* %4
%11 = icmp sgt i32 3, %10
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @tri_externe(i8* %21)
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @rename(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %25)
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = icmp ne i32 0, %27
br i1 %28, label %29, label %31
29: ; preds = %18
%30 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %18
%32 = call i32 @remove(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = icmp ne i32 0, %33
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
%38 = call i32 @remove(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32 %38, i32* %8
%39 = load i32, i32* %8
%40 = icmp ne i32 0, %39
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %43
43: ; preds = %41, %37
%44 = call i32 @remove(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32 %44, i32* %8
%45 = load i32, i32* %8
%46 = icmp ne i32 0, %45
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
%50 = call double (...) @temps_CPU()
store double %50, double* %7
%51 = load double, double* %7
%52 = load double, double* %6
%53 = fsub double %51, %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), double %53)
%55 = load i32, i32* @EXIT_SUCCESS
ret i32 %55
}

LLVM IR (-O2):
@.str = [59 x i8] c"USAGE: %s <fichier a trier.bin> <nom du fichier trie.bin>\0A\00"
@.str.1 = [3 x i8] c"f1\00"
@.str.2 = [21 x i8] c"le renomage a echoue\00"
@.str.3 = [3 x i8] c"f2\00"
@.str.4 = [24 x i8] c"la suppression a echoue\00"
@.str.5 = [3 x i8] c"f3\00"
@.str.6 = [3 x i8] c"f4\00"
@.str.7 = [44 x i8] c"Tri execute avec succes. CPU time : %.4f s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call double (...) @temps_CPU()
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @tri_externe(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @rename(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %9
%18 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %9
%20 = tail call i32 @remove(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
%25 = tail call i32 @remove(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
%30 = tail call i32 @remove(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp eq i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
%35 = tail call double (...) @temps_CPU()
%36 = fsub double %35, %3
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), double %36)
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}