// File: /workspace/github_c_makefile_star2_O0/trumabrat[P]GrandProjet/comparaisonsMain.c
// Function: main
int main()
{
    // lecture et creation d'une instance de Chaines et de Reseau
    FILE* f = NULL;
    f = fopen("00014_burma.cha", "r");
    Chaines *c = lectureChaines(f);
    fclose(f);

    // construction du reseau, hachage et arbre
    // avec calcul du temps, et son ecriture dans un fichier
    clock_t start, end;
    double t_diff;
    FILE* f2 = NULL;

    start = clock();
    Reseau *L = reconstitueReseauListe(c);
    end = clock();
    f2 = fopen("timeListe.txt", "w");
    t_diff = (double)(end - start)/(CLOCKS_PER_SEC);
    fprintf(f2, "temps de calcusls: %lf\n", t_diff);
    fclose(f2);
    liberation_reseau(L);
    
    // Reconstruction par table hachage
    Reseau *H = NULL;
    f2 = fopen("timeHachage.txt", "w");
    for(int i = 1; i < 20; i++){
        start = clock();
        H = reconstitueReseauHachage(c, i);
        end = clock();
        t_diff = (double)(end - start)/(CLOCKS_PER_SEC);
        fprintf(f2, "%d %lf\n", i, t_diff);
        liberation_reseau(H);
    }
    fclose(f2);
    
    // Reconstruiction par Arbre
    start = clock();
    Reseau* A = reconstitueReseauArbre(c);
    end = clock();
    f2 = fopen("timeArbre.txt", "w");
    t_diff = (double)(end - start)/(CLOCKS_PER_SEC);
    fprintf(f2, "temps de calcusls: %lf\n", t_diff);
    fclose(f2);
    liberation_reseau(A);


    // liberation de memoire
    liberer_chaines(c);

    FILE *f3 = NULL, *f4 = NULL, *f5 = NULL, *f6 = NULL, *f7 = NULL;
    int nbPointsChaine = 15, xmax = 5000, ymax = 5000;
    int taille_tab_hachage[3] = {10, 100, 1000};
    clock_t debut, fin;
    double temps_calcul = 0;
    Reseau* tmp = NULL;
    f3 = fopen("compListeChainee.txt", "w");
    f4 = fopen("compHachage1.txt", "w");
    f5 = fopen("compHachage2.txt", "w");
    f6 = fopen("compHachage3.txt", "w");
    f7 = fopen("compArbreQuat.txt", "w");
    

    for (int nbChaines = 500; nbChaines <= 5000; nbChaines += 500)
    {
        // generation de Chaines
        c = generationAleatoire(nbChaines, nbPointsChaine, xmax, ymax);

        // reconstruction de reseau par liste chainee
        // ensuite le calcul et l'ecriture de temps utilise
        // enfin liberation de memoire
        debut = clock();
        tmp = reconstitueReseauListe(c);
        fin = clock();
        temps_calcul = (double) ((fin-debut)*1.0/CLOCKS_PER_SEC);
        fprintf(f3, "%d %lf\n", nbChaines*nbPointsChaine, temps_calcul);
        liberation_reseau(tmp);

        // reconstruction de reseau par table de hachage de taille petite
        // ensuite le calcul et l'ecriture de temps utilise
        // enfin liberation de memoire
        debut = clock();
        tmp = reconstitueReseauHachage(c, taille_tab_hachage[0]);
        fin = clock();
        temps_calcul = (double) ((fin-debut)*1.0/CLOCKS_PER_SEC);
        fprintf(f4, "%d %lf\n", nbChaines*nbPointsChaine, temps_calcul);
        liberation_reseau(tmp);

        // reconstruction de reseau par table de hachage de taille moyenne
        // ensuite le calcul et l'ecriture de temps utilise
        // enfin liberation de memoire
        debut = clock();
        tmp = reconstitueReseauHachage(c, taille_tab_hachage[1]);
        fin = clock();
        temps_calcul = (double) ((fin-debut)*1.0/CLOCKS_PER_SEC);
        fprintf(f5, "%d %lf\n", nbChaines*nbPointsChaine, temps_calcul);
        liberation_reseau(tmp);

        // reconstruction de reseau par table de hachage de taille grande
        // ensuite le calcul et l'ecriture de temps utilise
        // enfin liberation de memoire
        debut = clock();
        tmp = reconstitueReseauHachage(c, taille_tab_hachage[0]);
        fin = clock();
        temps_calcul = (double) ((fin-debut)*1.0/CLOCKS_PER_SEC);
        fprintf(f6, "%d %lf\n", nbChaines*nbPointsChaine, temps_calcul);
        liberation_reseau(tmp);

        // reconstruction de reseau par arbre quaternaire
        // ensuite le calcul et l'ecriture de temps utilise
        // enfin liberation de memoire
        debut = clock();
        tmp = reconstitueReseauArbre(c);
        fin = clock();
        temps_calcul = (double) ((fin-debut)*1.0/CLOCKS_PER_SEC);
        fprintf(f7, "%d %lf\n", nbChaines*nbPointsChaine, temps_calcul);
        liberation_reseau(tmp);

        liberer_chaines(c);
    }
    fclose(f3);fclose(f4);fclose(f5);fclose(f6);fclose(f7);
    

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl $0x0, -0x4(%rbp)
movq $0x0, -0x10(%rbp)
leaq 0x3dc7(%rip), %rdi      # 0x5018
leaq 0x3dd0(%rip), %rsi      # 0x5028
callq 0x10e0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x19e0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1080
movq $0x0, -0x38(%rbp)
callq 0x1070
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2560
movq %rax, -0x40(%rbp)
callq 0x1070
movq %rax, -0x28(%rbp)
leaq 0x3d85(%rip), %rdi      # 0x502a
leaq 0x3d8c(%rip), %rsi      # 0x5038
callq 0x10e0
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
subq -0x20(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x3d3e(%rip), %xmm1     # 0x5008
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x38(%rbp), %rdi
movsd -0x30(%rbp), %xmm0
leaq 0x3d57(%rip), %rsi      # 0x503a
movb $0x1, %al
callq 0x10c0
movq -0x38(%rbp), %rdi
callq 0x1080
movq -0x40(%rbp), %rdi
callq 0x2e20
movq $0x0, -0x48(%rbp)
leaq 0x3d47(%rip), %rdi      # 0x5052
leaq 0x3d26(%rip), %rsi      # 0x5038
callq 0x10e0
movq %rax, -0x38(%rbp)
movl $0x1, -0x4c(%rbp)
cmpl $0x14, -0x4c(%rbp)
jge 0x1396
callq 0x1070
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x3210
movq %rax, -0x48(%rbp)
callq 0x1070
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
subq -0x20(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x3ca9(%rip), %xmm1     # 0x5008
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x38(%rbp), %rdi
movl -0x4c(%rbp), %edx
movsd -0x30(%rbp), %xmm0
leaq 0x3ce7(%rip), %rsi      # 0x5062
movb $0x1, %al
callq 0x10c0
movq -0x48(%rbp), %rdi
callq 0x2e20
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1322
movq -0x38(%rbp), %rdi
callq 0x1080
callq 0x1070
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3fb0
movq %rax, -0x58(%rbp)
callq 0x1070
movq %rax, -0x28(%rbp)
leaq 0x3ca5(%rip), %rdi      # 0x506a
leaq 0x3c6c(%rip), %rsi      # 0x5038
callq 0x10e0
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
subq -0x20(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x3c1e(%rip), %xmm1     # 0x5008
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x38(%rbp), %rdi
movsd -0x30(%rbp), %xmm0
leaq 0x3c37(%rip), %rsi      # 0x503a
movb $0x1, %al
callq 0x10c0
movq -0x38(%rbp), %rdi
callq 0x1080
movq -0x58(%rbp), %rdi
callq 0x2e20
movq -0x18(%rbp), %rdi
callq 0x2230
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movl $0xf, -0x84(%rbp)
movl $0x1388, -0x88(%rbp)    # imm = 0x1388
movl $0x1388, -0x8c(%rbp)    # imm = 0x1388
movq 0x3c62(%rip), %rax      # 0x50d4
movq %rax, -0x98(%rbp)
movl 0x3c5d(%rip), %eax      # 0x50dc
movl %eax, -0x90(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xb0(%rbp)
movq $0x0, -0xb8(%rbp)
leaq 0x3bd6(%rip), %rdi      # 0x5078
leaq 0x3b8f(%rip), %rsi      # 0x5038
callq 0x10e0
movq %rax, -0x60(%rbp)
leaq 0x3bd4(%rip), %rdi      # 0x508d
leaq 0x3b78(%rip), %rsi      # 0x5038
callq 0x10e0
movq %rax, -0x68(%rbp)
leaq 0x3bce(%rip), %rdi      # 0x509e
leaq 0x3b61(%rip), %rsi      # 0x5038
callq 0x10e0
movq %rax, -0x70(%rbp)
leaq 0x3bc8(%rip), %rdi      # 0x50af
leaq 0x3b4a(%rip), %rsi      # 0x5038
callq 0x10e0
movq %rax, -0x78(%rbp)
leaq 0x3bc2(%rip), %rdi      # 0x50c0
leaq 0x3b33(%rip), %rsi      # 0x5038
callq 0x10e0
movq %rax, -0x80(%rbp)
movl $0x1f4, -0xbc(%rbp)     # imm = 0x1F4
cmpl $0x1388, -0xbc(%rbp)    # imm = 0x1388
jg 0x1840
movl -0xbc(%rbp), %edi
movl -0x84(%rbp), %esi
movl -0x88(%rbp), %edx
movl -0x8c(%rbp), %ecx
callq 0x18c0
movq %rax, -0x18(%rbp)
callq 0x1070
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2560
movq %rax, -0xb8(%rbp)
callq 0x1070
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
subq -0xa0(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x3a84(%rip), %xmm1     # 0x5010
mulsd %xmm1, %xmm0
movsd 0x3a70(%rip), %xmm1     # 0x5008
divsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x60(%rbp), %rdi
movl -0xbc(%rbp), %edx
imull -0x84(%rbp), %edx
movsd -0xb0(%rbp), %xmm0
leaq 0x3a9e(%rip), %rsi      # 0x5062
movb $0x1, %al
callq 0x10c0
movq -0xb8(%rbp), %rdi
callq 0x2e20
callq 0x1070
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
movl -0x98(%rbp), %esi
callq 0x3210
movq %rax, -0xb8(%rbp)
callq 0x1070
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
subq -0xa0(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x39f0(%rip), %xmm1     # 0x5010
mulsd %xmm1, %xmm0
movsd 0x39dc(%rip), %xmm1     # 0x5008
divsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x68(%rbp), %rdi
movl -0xbc(%rbp), %edx
imull -0x84(%rbp), %edx
movsd -0xb0(%rbp), %xmm0
leaq 0x3a0a(%rip), %rsi      # 0x5062
movb $0x1, %al
callq 0x10c0
movq -0xb8(%rbp), %rdi
callq 0x2e20
callq 0x1070
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
movl -0x94(%rbp), %esi
callq 0x3210
movq %rax, -0xb8(%rbp)
callq 0x1070
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
subq -0xa0(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x395c(%rip), %xmm1     # 0x5010
mulsd %xmm1, %xmm0
movsd 0x3948(%rip), %xmm1     # 0x5008
divsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x70(%rbp), %rdi
movl -0xbc(%rbp), %edx
imull -0x84(%rbp), %edx
movsd -0xb0(%rbp), %xmm0
leaq 0x3976(%rip), %rsi      # 0x5062
movb $0x1, %al
callq 0x10c0
movq -0xb8(%rbp), %rdi
callq 0x2e20
callq 0x1070
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
movl -0x98(%rbp), %esi
callq 0x3210
movq %rax, -0xb8(%rbp)
callq 0x1070
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
subq -0xa0(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x38c8(%rip), %xmm1     # 0x5010
mulsd %xmm1, %xmm0
movsd 0x38b4(%rip), %xmm1     # 0x5008
divsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x78(%rbp), %rdi
movl -0xbc(%rbp), %edx
imull -0x84(%rbp), %edx
movsd -0xb0(%rbp), %xmm0
leaq 0x38e2(%rip), %rsi      # 0x5062
movb $0x1, %al
callq 0x10c0
movq -0xb8(%rbp), %rdi
callq 0x2e20
callq 0x1070
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3fb0
movq %rax, -0xb8(%rbp)
callq 0x1070
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
subq -0xa0(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x383a(%rip), %xmm1     # 0x5010
mulsd %xmm1, %xmm0
movsd 0x3826(%rip), %xmm1     # 0x5008
divsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x80(%rbp), %rdi
movl -0xbc(%rbp), %edx
imull -0x84(%rbp), %edx
movsd -0xb0(%rbp), %xmm0
leaq 0x3854(%rip), %rsi      # 0x5062
movb $0x1, %al
callq 0x10c0
movq -0xb8(%rbp), %rdi
callq 0x2e20
movq -0x18(%rbp), %rdi
callq 0x2230
movl -0xbc(%rbp), %eax
addl $0x1f4, %eax            # imm = 0x1F4
movl %eax, -0xbc(%rbp)
jmp 0x1518
movq -0x60(%rbp), %rdi
callq 0x1080
movq -0x68(%rbp), %rdi
callq 0x1080
movq -0x70(%rbp), %rdi
callq 0x1080
movq -0x78(%rbp), %rdi
callq 0x1080
movq -0x80(%rbp), %rdi
callq 0x1080
xorl %eax, %eax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)