// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x2dcf(%rip), %rdi      # 0x4010
leaq 0x2dd8(%rip), %rsi      # 0x4020
callq 0x10f0
movq %rax, %r14
movq %rax, %rdi
callq 0x1720
movq %rax, %rbx
movq %r14, %rdi
callq 0x1070
callq 0x1060
movq %rax, %r12
movq %rbx, %rdi
callq 0x1ebc
movq %rax, %r14
callq 0x1060
movq %rax, %r13
leaq 0x2d9d(%rip), %rdi      # 0x4022
leaq 0x2da4(%rip), %r15      # 0x4030
movq %r15, %rsi
callq 0x10f0
movq %rax, %rbp
subq %r12, %r13
cvtsi2sd %r13, %xmm0
divsd 0x2d61(%rip), %xmm0     # 0x4008
leaq 0x2d84(%rip), %rsi      # 0x4032
movq %rax, %rdi
movb $0x1, %al
callq 0x10d0
movq %rbp, %rdi
callq 0x1070
movq %r14, %rdi
callq 0x24c6
leaq 0x2d7b(%rip), %rdi      # 0x404a
movq %r15, %rsi
callq 0x10f0
movq %rax, %r14
movl $0x1, %ebp
leaq 0x2d74(%rip), %r15      # 0x405a
callq 0x1060
movq %rax, %r12
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2787
movq %rax, %r13
callq 0x1060
subq %r12, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x2cf5(%rip), %xmm0     # 0x4008
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
movb $0x1, %al
callq 0x10d0
movq %r13, %rdi
callq 0x24c6
incl %ebp
cmpl $0x14, %ebp
jne 0x12e6
movq %r14, %rdi
callq 0x1070
callq 0x1060
movq %rax, %r12
movq %rbx, %rdi
callq 0x2f03
movq %rax, %r15
callq 0x1060
movq %rax, %r13
leaq 0x2d07(%rip), %rdi      # 0x4062
leaq 0x2cce(%rip), %r14      # 0x4030
movq %r14, %rsi
callq 0x10f0
movq %rax, %rbp
subq %r12, %r13
xorps %xmm0, %xmm0
cvtsi2sd %r13, %xmm0
divsd 0x2c88(%rip), %xmm0     # 0x4008
leaq 0x2cab(%rip), %rsi      # 0x4032
movq %rax, %rdi
movb $0x1, %al
callq 0x10d0
movq %rbp, %rdi
callq 0x1070
movq %r15, %rdi
callq 0x24c6
movq %rbx, %rdi
callq 0x1ccb
leaq 0x2cc0(%rip), %rdi      # 0x4070
movq %r14, %rsi
callq 0x10f0
movq %rax, 0x20(%rsp)
leaq 0x2cc1(%rip), %rdi      # 0x4085
movq %r14, %rsi
callq 0x10f0
movq %rax, 0x18(%rsp)
leaq 0x2cbe(%rip), %rdi      # 0x4096
movq %r14, %rsi
callq 0x10f0
movq %rax, 0x10(%rsp)
leaq 0x2cbb(%rip), %rdi      # 0x40a7
movq %r14, %rsi
callq 0x10f0
movq %rax, 0x8(%rsp)
leaq 0x2cb8(%rip), %rdi      # 0x40b8
movq %r14, %rsi
callq 0x10f0
movq %rax, (%rsp)
xorl %ebp, %ebp
movl $0x1d4c, %ebx           # imm = 0x1D4C
leaq 0x2c40(%rip), %r14      # 0x405a
addl $0x1f4, %ebp            # imm = 0x1F4
movl %ebp, %edi
movl $0xf, %esi
movl $0x1388, %edx           # imm = 0x1388
movl $0x1388, %ecx           # imm = 0x1388
callq 0x1618
movq %rax, %r15
callq 0x1060
movq %rax, %r12
movq %r15, %rdi
callq 0x1ebc
movq %rax, %r13
callq 0x1060
subq %r12, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd 0x2ba4(%rip), %xmm1     # 0x4008
divsd %xmm1, %xmm0
movq 0x20(%rsp), %rdi
movq %r14, %rsi
movl %ebx, %edx
movb $0x1, %al
callq 0x10d0
movq %r13, %rdi
callq 0x24c6
callq 0x1060
movq %rax, %r12
movq %r15, %rdi
movl $0xa, %esi
callq 0x2787
movq %rax, %r13
callq 0x1060
subq %r12, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x2b57(%rip), %xmm0     # 0x4008
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movl %ebx, %edx
movb $0x1, %al
callq 0x10d0
movq %r13, %rdi
callq 0x24c6
callq 0x1060
movq %rax, %r12
movq %r15, %rdi
movl $0x64, %esi
callq 0x2787
movq %rax, %r13
callq 0x1060
subq %r12, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x2b0e(%rip), %xmm0     # 0x4008
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movl %ebx, %edx
movb $0x1, %al
callq 0x10d0
movq %r13, %rdi
callq 0x24c6
callq 0x1060
movq %rax, %r12
movq %r15, %rdi
movl $0xa, %esi
callq 0x2787
movq %rax, %r13
callq 0x1060
subq %r12, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x2ac5(%rip), %xmm0     # 0x4008
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movl %ebx, %edx
movb $0x1, %al
callq 0x10d0
movq %r13, %rdi
callq 0x24c6
callq 0x1060
movq %rax, %r12
movq %r15, %rdi
callq 0x2f03
movq %rax, %r13
callq 0x1060
subq %r12, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x2a81(%rip), %xmm0     # 0x4008
movq (%rsp), %rdi
movq %r14, %rsi
movl %ebx, %edx
movb $0x1, %al
callq 0x10d0
movq %r13, %rdi
callq 0x24c6
movq %r15, %rdi
callq 0x1ccb
addl $0x1d4c, %ebx           # imm = 0x1D4C
cmpl $0x1195, %ebp           # imm = 0x1195
jb 0x141a
movq 0x20(%rsp), %rdi
callq 0x1070
movq 0x18(%rsp), %rdi
callq 0x1070
movq 0x10(%rsp), %rdi
callq 0x1070
movq 0x8(%rsp), %rdi
callq 0x1070
movq (%rsp), %rdi
callq 0x1070
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop