#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ repartition_notes(int, int /*<<< orphan*/ *, int *);
double temps_CPU();
int main(int argc, char *argv[]) {
  double START, END;
  START = temps_CPU();
  if (3 > argc) {
    printf("USAGE: %s <ficher d'evaluation.bin> <identification du film>\n",
           argv[0]);
    exit(0);
  }
  int tab[5] = {0, 0, 0, 0, 0};
  FILE *adt;
  int id_film;
  id_film = atoi(argv[2]);
  adt = fopen(argv[1], "r");
  if (NULL == adt) {
    perror("echec ouverture fichier");
    exit(-1);
  }
  repartition_notes(id_film, adt, tab);
  fclose(adt);
  END = temps_CPU();
  printf("\nCPU time : %.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    $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   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe49(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x48(%rbp)
xor    %eax,%eax
cmp    -0x48(%rbp),%rax
jne    1236 <main+0xa6>
lea    0xe17(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1030 <repartition_notes@plt>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x0,%al
call   1070 <temps_CPU@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xdea(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x2d66(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1060 <temps_CPU@plt>
movsd  %xmm0,0x8(%rsp)
cmp    $0x2,%ebp
jle    1214 <main+0x94>
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     122c <main+0xac>
mov    %rax,%rbx
lea    0x10(%rsp),%rdx
mov    %ebp,%edi
mov    %rax,%rsi
call   1030 <repartition_notes@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
call   1060 <temps_CPU@plt>
subsd  0x8(%rsp),%xmm0
lea    0xe59(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xde2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
lea    0xe0b(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [62 x i8] c"USAGE: %s <ficher d'evaluation.bin> <identification du film>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [24 x i8] c"echec ouverture fichier\00"
@.str.3 = [20 x i8] c"\0ACPU 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 [5 x 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 ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %2
%21 = bitcast [5 x i32]* %8 to i8*
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %10
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %9
%30 = load i32*, i32** %9
%31 = icmp eq i32* null, %30
br i1 %31, label %32, label %35
32: ; preds = %20
%33 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %20
%36 = load i32, i32* %10
%37 = load i32*, i32** %9
%38 = getelementptr inbounds [5 x i32], [5 x i32]* %8, i64 0, i64 0
%39 = call i32 @repartition_notes(i32 %36, i32* %37, i32* %38)
%40 = load i32*, i32** %9
%41 = call i32 @fclose(i32* %40)
%42 = call double (...) @temps_CPU()
store double %42, double* %7
%43 = load double, double* %7
%44 = load double, double* %6
%45 = fsub double %43, %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), double %45)
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}

LLVM IR (-O2):
@.str = [62 x i8] c"USAGE: %s <ficher d'evaluation.bin> <identification du film>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [24 x i8] c"echec ouverture fichier\00"
@.str.3 = [20 x i8] c"\0ACPU time : %.4f s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [5 x i32]
%4 = tail call double (...) @temps_CPU()
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 0)
unreachable
10: ; preds = %2
%11 = bitcast [5 x i32]* %3 to i8*
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %10
%20 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @exit(i32 -1)
unreachable
22: ; preds = %10
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%24 = call i32 @repartition_notes(i32 %14, i32* %17, i32* %23)
%25 = call i32 @fclose(i32* %17)
%26 = call double (...) @temps_CPU()
%27 = fsub double %26, %4
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), double %27)
%29 = load i32, i32* @EXIT_SUCCESS
ret i32 %29
}