#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 (2 > argc) {
    printf("USAGE: %s <fichier a trier.bin>\n", argv[0]);
    exit(0);
  }
  tri_externe(argv[1]);
  boolean = rename("f1", "index.bin");
  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    $0x2,%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>
lea    0xe51(%rip),%rdi
lea    0xe4d(%rip),%rsi
call   1080 <rename@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
je     11f6 <main+0x86>
lea    0xe3d(%rip),%rdi
call   1070 <perror@plt>
lea    0xe46(%rip),%rdi
call   1040 <remove@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
je     121c <main+0xac>
lea    0xe2f(%rip),%rdi
call   1070 <perror@plt>
lea    0xe3b(%rip),%rdi
call   1040 <remove@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
je     1242 <main+0xd2>
lea    0xe09(%rip),%rdi
call   1070 <perror@plt>
lea    0xe18(%rip),%rdi
call   1040 <remove@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
je     1268 <main+0xf8>
lea    0xde3(%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    0xddf(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x2d4d(%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    $0x1,%ebp
jle    123f <main+0xcf>
mov    0x8(%rbx),%rdi
call   1030 <tri_externe@plt>
lea    0xe84(%rip),%rdi
lea    0xe80(%rip),%rsi
call   1080 <rename@plt>
test   %eax,%eax
jne    1207 <main+0x97>
lea    0xe8f(%rip),%rdi
call   1040 <remove@plt>
test   %eax,%eax
jne    1215 <main+0xa5>
lea    0xe9a(%rip),%rdi
call   1040 <remove@plt>
test   %eax,%eax
jne    1223 <main+0xb3>
lea    0xe8d(%rip),%rdi
call   1040 <remove@plt>
test   %eax,%eax
jne    1231 <main+0xc1>
xor    %eax,%eax
call   1060 <temps_CPU@plt>
subsd  (%rsp),%xmm0
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe20(%rip),%rdi
call   1070 <perror@plt>
jmp    11ad <main+0x3d>
lea    0xe2a(%rip),%rdi
call   1070 <perror@plt>
jmp    11bd <main+0x4d>
lea    0xe1c(%rip),%rdi
call   1070 <perror@plt>
jmp    11cd <main+0x5d>
lea    0xe0e(%rip),%rdi
call   1070 <perror@plt>
jmp    11dd <main+0x6d>
mov    (%rbx),%rsi
lea    0xdb7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"USAGE: %s <fichier a trier.bin>\0A\00"
@.str.1 = [3 x i8] c"f1\00"
@.str.2 = [10 x i8] c"index.bin\00"
@.str.3 = [21 x i8] c"le renomage a echoue\00"
@.str.4 = [3 x i8] c"f2\00"
@.str.5 = [24 x i8] c"la suppression a echoue\00"
@.str.6 = [3 x i8] c"f3\00"
@.str.7 = [3 x i8] c"f4\00"
@.str.8 = [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 2, %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 ([33 x i8], [33 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 = call i32 @rename(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = icmp ne i32 0, %24
br i1 %25, label %26, label %28
26: ; preds = %18
%27 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %18
%29 = call i32 @remove(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = icmp ne i32 0, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %34
34: ; preds = %32, %28
%35 = call i32 @remove(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32 %35, i32* %8
%36 = load i32, i32* %8
%37 = icmp ne i32 0, %36
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
%41 = call i32 @remove(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
store i32 %41, i32* %8
%42 = load i32, i32* %8
%43 = icmp ne i32 0, %42
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %44, %40
%47 = call double (...) @temps_CPU()
store double %47, double* %7
%48 = load double, double* %7
%49 = load double, double* %6
%50 = fsub double %48, %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), double %50)
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}

LLVM IR (-O2):
@.str = [33 x i8] c"USAGE: %s <fichier a trier.bin>\0A\00"
@.str.1 = [3 x i8] c"f1\00"
@.str.2 = [10 x i8] c"index.bin\00"
@.str.3 = [21 x i8] c"le renomage a echoue\00"
@.str.4 = [3 x i8] c"f2\00"
@.str.5 = [24 x i8] c"la suppression a echoue\00"
@.str.6 = [3 x i8] c"f3\00"
@.str.7 = [3 x i8] c"f4\00"
@.str.8 = [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, 2
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 ([33 x i8], [33 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 = tail call i32 @rename(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %9
%16 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %15, %9
%18 = tail call i32 @remove(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = tail call i32 @remove(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = tail call i32 @remove(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = tail call double (...) @temps_CPU()
%34 = fsub double %33, %3
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), double %34)
%36 = load i32, i32* @EXIT_SUCCESS
ret i32 %36
}