#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*/ repartition_notes(int, int /*<<< orphan*/ *, int *, int);
double temps_CPU();
int main(int argc, char *argv[]) {
  double START, END;
  if (2 > argc) {
    printf("USAGE: %s <identifiant du film>\n", argv[0]);
    exit(0);
  }
  int film, position;
  int tab[5] = {0, 0, 0, 0, 0};
  FILE *adt;
  adt = fopen("index.bin", "r");
  if (NULL == adt) {
    perror("echec ouverture fichier");
    exit(-1);
  }
  film = atoi(argv[1]);
  START = temps_CPU();
  printf("Evaluation Sequentielle pour %d\n", film);
  position = first_eval_seq(film, adt);
  if (position == -1)
    printf("Aucunes evaluations n'a eu lieu pour %d\n", film);
  else
    printf("L'evaluation est en %d eme position\n", position);
  repartition_notes(film, adt, tab, position);
  END = temps_CPU();
  printf("\nTemps CPU de la recherche sequentielle : %.4f s\n", END - START);
  START = temps_CPU();
  printf("\nEvaluation Dichotomique pour %d\n", film);
  position = first_eval_dicho(film, adt);
  if (position == -1)
    printf("Aucunes evaluations n'a eu lieu pour %d\n", film);
  else
    printf("L'evaluation est en %d eme position\n", position);
  repartition_notes(film, adt, tab, 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    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x2,%eax
cmp    -0x8(%rbp),%eax
jle    11e0 <main+0x40>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
lea    0xe2a(%rip),%rdi
lea    0xe43(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x48(%rbp)
xor    %eax,%eax
cmp    -0x48(%rbp),%rax
jne    1229 <main+0x89>
lea    0xe11(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1080 <temps_CPU@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%esi
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
mov    -0x48(%rbp),%rsi
call   1060 <first_eval_seq@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1285 <main+0xe5>
mov    -0x24(%rbp),%esi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1296 <main+0xf6>
mov    -0x28(%rbp),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
mov    -0x48(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    -0x28(%rbp),%ecx
call   1030 <repartition_notes@plt>
mov    $0x0,%al
call   1080 <temps_CPU@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xdec(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <temps_CPU@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
mov    -0x48(%rbp),%rsi
call   1070 <first_eval_dicho@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1319 <main+0x179>
mov    -0x24(%rbp),%esi
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    132a <main+0x18a>
mov    -0x28(%rbp),%esi
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
mov    -0x48(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    -0x28(%rbp),%ecx
call   1030 <repartition_notes@plt>
mov    $0x0,%al
call   1080 <temps_CPU@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xdac(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2c78(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    12dc <main+0x14c>
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
lea    0xe64(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12f4 <main+0x164>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <temps_CPU@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe4f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <first_eval_seq@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1219 <main+0x89>
lea    0xe78(%rip),%rdi
mov    %ebx,%esi
jmp    1222 <main+0x92>
lea    0xe44(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rdx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %ebx,%ecx
call   1030 <repartition_notes@plt>
xor    %eax,%eax
call   1070 <temps_CPU@plt>
subsd  0x8(%rsp),%xmm0
lea    0xe64(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <temps_CPU@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe7b(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1060 <first_eval_dicho@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     128e <main+0xfe>
lea    0xe03(%rip),%rdi
mov    %ebx,%esi
jmp    1297 <main+0x107>
lea    0xdcf(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rdx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %ebx,%ecx
call   1030 <repartition_notes@plt>
xor    %eax,%eax
call   1070 <temps_CPU@plt>
subsd  0x8(%rsp),%xmm0
lea    0xe43(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xd1a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    0xd30(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

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

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