// File: /workspace/github_c_makefile_star2_O2/trumabrat[P]GrandProjet/Hachage.c
// Function: reconstitueReseauHachage
Reseau* reconstitueReseauHachage(Chaines *C, int M){
    int i;
    Reseau* reso = (Reseau*) calloc(1, sizeof(Reseau));
    reso->gamma = C->gamma;
    TableHachage* H = creerTableHachage(M);

    CellChaine* chaineTmp = C->chaines;
    CellPoint* pointTmp = NULL;
    CellPoint* pointPrev = NULL;
    CellPoint* pointTete = NULL;
    Noeud* noeudPrev = NULL;
    Noeud* noeudTmp = NULL;
    Noeud* noeudTete = NULL;
    CellCommodite* commoditeTmp = NULL;

    // On parcourt une a une chaque chaıne:
    for ( i = 0; i < C->nbChaines; i++, chaineTmp = chaineTmp->suiv)
    {
        // si Chaines est bien construit, les deux assert ne pose pas de probleme
        // si chaineTmp == NULL, on a mal compte le nombre de chaines
        assert(chaineTmp);

        pointTete = chaineTmp->points;// on fait hypothese que ce n'est pas NULL
        pointTmp = pointTete;

        // On s'occupe du premier neoud
        noeudTete = rechercheCreeNoeudHachage(reso, H, pointTmp->x, pointTmp->y);
        noeudPrev = noeudTete;
        pointPrev = pointTmp;
        pointTmp = pointTmp->suiv;

        // Pour chaque point p de la cha^ıne:
        while(pointTmp){
            // Si p !∈ V (on teste si le point n’a pas d´ej`a ´et´e rencontr´e auparavant)
                // On ajoute dans V un nœud correspond au point p.
            noeudTmp = rechercheCreeNoeudHachage(reso, H, pointTmp->x, pointTmp->y);
            
            // On met `a jour la liste des voisins de p et celles de ses voisins.
            noeudPrev = ajouterVoisin(noeudPrev, noeudTmp);

            // passe au point suivant
            pointPrev = pointTmp;
            pointTmp = pointTmp->suiv;
        }
        
        // On conserve la commodit´e de la cha^ıne.
        assert(noeudTete && noeudTmp);
        commoditeTmp = creerCellCommodite(noeudTete, noeudTmp, commoditeTmp);
    }

    // si chaineTmp == NULL, on a mal compte le nombre de chaines
    // securisation
    assert(!chaineTmp);
    reso->commodites = commoditeTmp;
    liberer_tableHachage(H);
    return reso;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebp
movq %rdi, %r14
pushq $0x1
popq %rdi
pushq $0x18
popq %rsi
callq 0x10c0
movq %rax, %rbx
movl (%r14), %eax
movl %eax, 0x4(%rbx)
movl %ebp, %edi
callq 0x2344
movq %rax, %r15
movq %r14, 0x8(%rsp)
leaq 0x8(%r14), %r12
xorl %ecx, %ecx
xorl %r13d, %r13d
xorl %edx, %edx
movq (%r12), %r12
movq 0x8(%rsp), %rax
cmpl 0x4(%rax), %ecx
jge 0x2627
movq %rdx, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
testq %r12, %r12
je 0x264a
movq 0x8(%r12), %r14
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
movq %rbx, %rdi
movq %r15, %rsi
callq 0x23b2
movq %rax, %rbp
movq %rax, 0x10(%rsp)
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x25f8
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
movq %rbx, %rdi
movq %r15, %rsi
callq 0x23b2
movq %rax, %r13
movq %rbp, %rdi
movq %rax, %rsi
callq 0x1cdd
movq %rax, %rbp
jmp 0x25c6
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2663
testq %r13, %r13
je 0x2663
movq %r13, %rsi
movq 0x18(%rsp), %rdx
callq 0x1d2e
movq %rax, %rdx
movq 0x20(%rsp), %rcx
incl %ecx
addq $0x10, %r12
jmp 0x257e
testq %r12, %r12
jne 0x2680
movq %rdx, 0x10(%rbx)
movq %r15, %rdi
callq 0x2699
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb51(%rip), %rdi       # 0x31a2
leaq 0xc10(%rip), %rsi       # 0x3268
leaq 0xc9d(%rip), %rcx       # 0x32fc
pushq $0x5d
jmp 0x267a
leaq 0xb21(%rip), %rdi       # 0x318b
leaq 0xbf7(%rip), %rsi       # 0x3268
leaq 0xc84(%rip), %rcx       # 0x32fc
pushq $0x77
popq %rdx
callq 0x10a0
leaq 0xb1a(%rip), %rdi       # 0x31a1
leaq 0xbda(%rip), %rsi       # 0x3268
leaq 0xc67(%rip), %rcx       # 0x32fc
pushq $0x7d
jmp 0x267a