// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
leaq 0x1dcf(%rip), %rdi      # 0x3010
leaq 0x1dd8(%rip), %rsi      # 0x3020
callq 0x10f0
movq %rax, %r14
movq %rax, %rdi
callq 0x16f0
movq %rax, %rbx
movq %r14, %rdi
callq 0x1070
callq 0x1060
movq %rax, %r12
movq %rbx, %rdi
callq 0x1d58
movq %rax, %r14
callq 0x1060
movq %rax, %r13
leaq 0x1d9d(%rip), %rdi      # 0x3022
leaq 0x1da4(%rip), %r15      # 0x3030
movq %r15, %rsi
callq 0x10f0
movq %rax, %rbp
subq %r12, %r13
cvtsi2sd %r13, %xmm0
divsd 0x1d61(%rip), %xmm0     # 0x3008
leaq 0x1d84(%rip), %rsi      # 0x3032
movq %rax, %rdi
movb $0x1, %al
callq 0x10d0
movq %rbp, %rdi
callq 0x1070
movq %r14, %rdi
callq 0x228d
leaq 0x1d7b(%rip), %rdi      # 0x304a
movq %r15, %rsi
callq 0x10f0
movq %rax, %r14
pushq $0x1
popq %rbp
leaq 0x1d76(%rip), %r15      # 0x305a
cmpl $0x14, %ebp
je 0x132e
callq 0x1060
movq %rax, %r12
movq %rbx, %rdi
movl %ebp, %esi
callq 0x253d
movq %rax, %r13
callq 0x1060
subq %r12, %rax
cvtsi2sd %rax, %xmm0
divsd 0x1cf5(%rip), %xmm0     # 0x3008
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
movb $0x1, %al
callq 0x10d0
movq %r13, %rdi
callq 0x228d
incl %ebp
jmp 0x12e4
movq %r14, %rdi
callq 0x1070
callq 0x1060
movq %rax, %r12
movq %rbx, %rdi
callq 0x2bc0
movq %rax, %r15
callq 0x1060
movq %rax, %r13
leaq 0x1d0a(%rip), %rdi      # 0x3062
leaq 0x1cd1(%rip), %r14      # 0x3030
movq %r14, %rsi
callq 0x10f0
movq %rax, %rbp
subq %r12, %r13
cvtsi2sd %r13, %xmm0
divsd 0x1c8e(%rip), %xmm0     # 0x3008
leaq 0x1cb1(%rip), %rsi      # 0x3032
movq %rax, %rdi
movb $0x1, %al
callq 0x10d0
movq %rbp, %rdi
callq 0x1070
movq %r15, %rdi
callq 0x228d
movq %rbx, %rdi
callq 0x1bd8
leaq 0x1cc6(%rip), %rdi      # 0x3070
movq %r14, %rsi
callq 0x10f0
movq %rax, 0x30(%rsp)
leaq 0x1cc7(%rip), %rdi      # 0x3085
movq %r14, %rsi
callq 0x10f0
movq %rax, 0x28(%rsp)
leaq 0x1cc4(%rip), %rdi      # 0x3096
movq %r14, %rsi
callq 0x10f0
movq %rax, 0x20(%rsp)
leaq 0x1cc1(%rip), %rdi      # 0x30a7
movq %r14, %rsi
callq 0x10f0
movq %rax, 0x18(%rsp)
leaq 0x1cbe(%rip), %rdi      # 0x30b8
movq %r14, %rsi
callq 0x10f0
movq %rax, 0x10(%rsp)
movl $0x1f4, %eax            # imm = 0x1F4
movl $0x1d4c, %ebx           # imm = 0x1D4C
pushq $0xa
popq %r14
cmpl $0x1389, %eax           # imm = 0x1389
jae 0x15b2
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %edi
pushq $0xf
popq %rsi
movl $0x1388, %edx           # imm = 0x1388
movl $0x1388, %ecx           # imm = 0x1388
callq 0x1614
movq %rax, %r12
callq 0x1060
movq %rax, %r13
movq %r12, %rdi
callq 0x1d58
movq %rax, %r15
callq 0x1060
subq %r13, %rax
cvtsi2sd %rax, %xmm0
movsd 0x1ba3(%rip), %xmm1     # 0x3008
divsd %xmm1, %xmm0
movq 0x30(%rsp), %rdi
leaq 0x1be5(%rip), %rbp      # 0x305a
movq %rbp, %rsi
movl %ebx, %edx
movb $0x1, %al
callq 0x10d0
movq %r15, %rdi
callq 0x228d
callq 0x1060
movq %rax, %r15
movq %r12, %rdi
movl %r14d, %esi
callq 0x253d
movq %rax, %r13
callq 0x1060
subq %r15, %rax
cvtsi2sd %rax, %xmm0
divsd 0x1b54(%rip), %xmm0     # 0x3008
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
movl %ebx, %edx
movb $0x1, %al
callq 0x10d0
movq %r13, %rdi
callq 0x228d
callq 0x1060
movq %rax, %r15
movq %r12, %rdi
pushq $0x64
popq %rsi
callq 0x253d
movq %rax, %r13
callq 0x1060
subq %r15, %rax
cvtsi2sd %rax, %xmm0
divsd 0x1b10(%rip), %xmm0     # 0x3008
movq 0x20(%rsp), %rdi
movq %rbp, %rsi
movl %ebx, %edx
movb $0x1, %al
callq 0x10d0
movq %r13, %rdi
callq 0x228d
callq 0x1060
movq %rax, %r15
movq %r12, %rdi
movl %r14d, %esi
callq 0x253d
movq %rax, %r13
callq 0x1060
subq %r15, %rax
cvtsi2sd %rax, %xmm0
divsd 0x1acc(%rip), %xmm0     # 0x3008
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movl %ebx, %edx
movb $0x1, %al
callq 0x10d0
movq %r13, %rdi
callq 0x228d
callq 0x1060
movq %rax, %r15
movq %r12, %rdi
callq 0x2bc0
movq %rax, %r13
callq 0x1060
subq %r15, %rax
cvtsi2sd %rax, %xmm0
divsd 0x1a8b(%rip), %xmm0     # 0x3008
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
movl %ebx, %edx
movb $0x1, %al
callq 0x10d0
movq %r13, %rdi
callq 0x228d
movq %r12, %rdi
callq 0x1bd8
movl 0xc(%rsp), %eax
addl $0x1f4, %eax            # imm = 0x1F4
addl $0x1d4c, %ebx           # imm = 0x1D4C
jmp 0x1415
movq 0x30(%rsp), %rdi
callq 0x1070
movq 0x28(%rsp), %rdi
callq 0x1070
movq 0x20(%rsp), %rdi
callq 0x1070
movq 0x18(%rsp), %rdi
callq 0x1070
movq 0x10(%rsp), %rdi
callq 0x1070
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)