#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*/ time_t;

/* Variables and functions */
scalar_t__ arrayCopy(int *, int);
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, double);
int *randomArray(int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ triInsertion(int *, int);
int /*<<< orphan*/ triTas(int *, int);
int main() {
  int *array = NULL;
  int *array2 = NULL;
  int arraySize;
  time_t debut, millieu, fin;
  double dureeInsert, dureeTas;
  arraySize = 1000000;
  array = randomArray(arraySize);
  array2 = (int *)arrayCopy(array, arraySize);
  debut = time(NULL);
  triInsertion(array, arraySize);
  millieu = time(NULL);
  triTas(array2, arraySize);
  fin = (time(NULL));
  dureeInsert = difftime(millieu, debut);
  dureeTas = difftime(fin, millieu);
  printf("Le temps du tri par insertion est de : %f \n", dureeInsert);
  printf("Le temps du tri par tas est de : %f \n", dureeTas);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0xf4240,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1090 <randomArray@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <arrayCopy@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <triInsertion@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1080 <triTas@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1040 <difftime@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1040 <difftime@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xde6(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xe01(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0xf4240,%edi
call   1090 <randomArray@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xf4240,%esi
call   1060 <arrayCopy@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    $0xf4240,%esi
call   1050 <triInsertion@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    $0xf4240,%esi
call   1080 <triTas@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %r15d,%esi
call   1040 <difftime@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <difftime@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe0d(%rip),%rdi
movsd  0x10(%rsp),%xmm0
call   1030 <printf@plt>
lea    0xe27(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Le temps du tri par insertion est de : %f \0A\00"
@.str.1 = [38 x i8] c"Le temps du tri par tas est de : %f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
store i32 0, i32* %1
store i32* null, i32** %2
store i32* null, i32** %3
store i32 1000000, i32* %4
%10 = load i32, i32* %4
%11 = call i32* @randomArray(i32 %10)
store i32* %11, i32** %2
%12 = load i32*, i32** %2
%13 = load i32, i32* %4
%14 = call i64 @arrayCopy(i32* %12, i32 %13)
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %3
%16 = call i32 @time(i32* null)
store i32 %16, i32* %5
%17 = load i32*, i32** %2
%18 = load i32, i32* %4
%19 = call i32 @triInsertion(i32* %17, i32 %18)
%20 = call i32 @time(i32* null)
store i32 %20, i32* %6
%21 = load i32*, i32** %3
%22 = load i32, i32* %4
%23 = call i32 @triTas(i32* %21, i32 %22)
%24 = call i32 @time(i32* null)
store i32 %24, i32* %7
%25 = load i32, i32* %6
%26 = load i32, i32* %5
%27 = call double @difftime(i32 %25, i32 %26)
store double %27, double* %8
%28 = load i32, i32* %7
%29 = load i32, i32* %6
%30 = call double @difftime(i32 %28, i32 %29)
store double %30, double* %9
%31 = load double, double* %8
%32 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), double %31)
%33 = load double, double* %9
%34 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), double %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"Le temps du tri par insertion est de : %f \0A\00"
@.str.1 = [38 x i8] c"Le temps du tri par tas est de : %f \0A\00"
define i32 @main() {
%1 = tail call i32* @randomArray(i32 1000000)
%2 = tail call i64 @arrayCopy(i32* %1, i32 1000000)
%3 = inttoptr i64 %2 to i32*
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @triInsertion(i32* %1, i32 1000000)
%6 = tail call i32 @time(i32* null)
%7 = tail call i32 @triTas(i32* %3, i32 1000000)
%8 = tail call i32 @time(i32* null)
%9 = tail call double @difftime(i32 %6, i32 %4)
%10 = tail call double @difftime(i32 %8, i32 %6)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), double %9)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), double %10)
ret i32 0
}