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

/* Variables and functions */
int EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ exit(int);
int first_eval_dicho(int, int /*<<< orphan*/ *);
int first_eval_seq(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
double temps_CPU();
int main(int argc, char *argv[]) {
  double START, END;
  START = temps_CPU();
  if (3 > argc) {
    printf("USAGE: %s <ficher d'evaluation trie.bin> <annee du film>\n",
           argv[0]);
    exit(0);
  }
  int annee, position;
  FILE *adt;
  adt = fopen(argv[1], "r");
  if (NULL == adt) {
    perror("echec ouverture fichier");
    exit(-1);
  }
  annee = atoi(argv[2]);
  puts("Evaluation Sequentielle");
  position = first_eval_seq(annee, adt);
  if (position == -1)
    printf("Aucunes evaluations n'a eu lieu en %d\n", annee);
  else
    printf("L'evaluation est en %d eme position\n", position);
  END = temps_CPU();
  printf("\nTemps CPU de la recherche sequentielle : %.4f s\n", END - START);
  START = temps_CPU();
  puts("Evaluation Dichotomique");
  position = first_eval_dicho(annee, adt);
  if (position == -1)
    printf("Aucunes evaluations n'a eu lieu en %d\n", annee);
  else
    printf("L'evaluation est en %d eme position\n", position);
  END = temps_CPU();
  printf("\nTemps CPU de la recherche dichotomique : %.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   1070 <temps_CPU@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x3,%eax
cmp    -0x8(%rbp),%eax
jle    11dc <main+0x4c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe65(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmp    -0x30(%rbp),%rax
jne    1216 <main+0x86>
lea    0xe33(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x24(%rbp)
lea    0xe25(%rip),%rdi
call   1030 <puts@plt>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1050 <first_eval_seq@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1261 <main+0xd1>
mov    -0x24(%rbp),%esi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1272 <main+0xe2>
mov    -0x28(%rbp),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <temps_CPU@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xe27(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <temps_CPU@plt>
movsd  %xmm0,-0x18(%rbp)
lea    0xe3f(%rip),%rdi
call   1030 <puts@plt>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1060 <first_eval_dicho@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    12dd <main+0x14d>
mov    -0x24(%rbp),%esi
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ee <main+0x15e>
mov    -0x28(%rbp),%esi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <temps_CPU@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xdf5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2cc7(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %edi,%ebx
xor    %eax,%eax
call   1070 <temps_CPU@plt>
movsd  %xmm0,(%rsp)
cmp    $0x2,%ebx
jle    1290 <main+0x100>
mov    0x8(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12a9 <main+0x119>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebp
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <first_eval_seq@plt>
cmp    $0xffffffff,%eax
je     11fa <main+0x6a>
lea    0xe9b(%rip),%rdi
mov    %eax,%esi
jmp    1203 <main+0x73>
lea    0xe69(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <temps_CPU@plt>
subsd  (%rsp),%xmm0
lea    0xe99(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <temps_CPU@plt>
movsd  %xmm0,(%rsp)
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <first_eval_dicho@plt>
cmp    $0xffffffff,%eax
je     1256 <main+0xc6>
lea    0xe3f(%rip),%rdi
mov    %eax,%esi
jmp    125f <main+0xcf>
lea    0xe0d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <temps_CPU@plt>
subsd  (%rsp),%xmm0
lea    0xe87(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2d59(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x0(%rbp),%rsi
lea    0xd65(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    0xd8a(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [58 x i8] c"USAGE: %s <ficher d'evaluation trie.bin> <annee du film>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [24 x i8] c"echec ouverture fichier\00"
@.str.3 = [24 x i8] c"Evaluation Sequentielle\00"
@.str.4 = [39 x i8] c"Aucunes evaluations n'a eu lieu en %d\0A\00"
@.str.5 = [37 x i8] c"L'evaluation est en %d eme position\0A\00"
@.str.6 = [50 x i8] c"\0ATemps CPU de la recherche sequentielle : %.4f s\0A\00"
@.str.7 = [24 x i8] c"Evaluation Dichotomique\00"
@.str.8 = [50 x i8] c"\0ATemps CPU de la recherche dichotomique : %.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
%9 = alloca i32
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call double (...) @temps_CPU()
store double %11, double* %6
%12 = load i32, i32* %4
%13 = icmp sgt i32 3, %12
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %10
%25 = load i32*, i32** %10
%26 = icmp eq i32* null, %25
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @exit(i32 -1)
unreachable
30: ; preds = %20
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
store i32 %34, i32* %8
%35 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%36 = load i32, i32* %8
%37 = load i32*, i32** %10
%38 = call i32 @first_eval_seq(i32 %36, i32* %37)
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %30
%42 = load i32, i32* %8
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %42)
br label %47
44: ; preds = %30
%45 = load i32, i32* %9
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %44, %41
%48 = call double (...) @temps_CPU()
store double %48, double* %7
%49 = load double, double* %7
%50 = load double, double* %6
%51 = fsub double %49, %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), double %51)
%53 = call double (...) @temps_CPU()
store double %53, double* %6
%54 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%55 = load i32, i32* %8
%56 = load i32*, i32** %10
%57 = call i32 @first_eval_dicho(i32 %55, i32* %56)
store i32 %57, i32* %9
%58 = load i32, i32* %9
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %63
60: ; preds = %47
%61 = load i32, i32* %8
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %61)
br label %66
63: ; preds = %47
%64 = load i32, i32* %9
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %63, %60
%67 = call double (...) @temps_CPU()
store double %67, double* %7
%68 = load double, double* %7
%69 = load double, double* %6
%70 = fsub double %68, %69
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0), double %70)
%72 = load i32, i32* @EXIT_SUCCESS
ret i32 %72
}

LLVM IR (-O2):
@.str = [58 x i8] c"USAGE: %s <ficher d'evaluation trie.bin> <annee du film>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [24 x i8] c"echec ouverture fichier\00"
@.str.3 = [24 x i8] c"Evaluation Sequentielle\00"
@.str.4 = [39 x i8] c"Aucunes evaluations n'a eu lieu en %d\0A\00"
@.str.5 = [37 x i8] c"L'evaluation est en %d eme position\0A\00"
@.str.6 = [50 x i8] c"\0ATemps CPU de la recherche sequentielle : %.4f s\0A\00"
@.str.7 = [24 x i8] c"Evaluation Dichotomique\00"
@.str.8 = [50 x i8] c"\0ATemps CPU de la recherche dichotomique : %.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 ([58 x i8], [58 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* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @exit(i32 -1)
unreachable
17: ; preds = %9
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%22 = tail call i32 @first_eval_seq(i32 %20, i32* %12)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %20)
br label %28
26: ; preds = %17
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %22)
br label %28
28: ; preds = %26, %24
%29 = tail call double (...) @temps_CPU()
%30 = fsub double %29, %3
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), double %30)
%32 = tail call double (...) @temps_CPU()
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%34 = tail call i32 @first_eval_dicho(i32 %20, i32* %12)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %38
36: ; preds = %28
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %20)
br label %40
38: ; preds = %28
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %34)
br label %40
40: ; preds = %38, %36
%41 = tail call double (...) @temps_CPU()
%42 = fsub double %41, %32
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0), double %42)
%44 = load i32, i32* @EXIT_SUCCESS
ret i32 %44
}