// File: /workspace/github_c_makefile_star2_O3/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, %r15
movl $0x1, %edi
movl $0x18, %esi
callq 0x10c0
movq %rax, %rbx
movl (%r15), %eax
movl %eax, 0x4(%rbx)
movl %ebp, %edi
callq 0x2580
movq %rax, %r14
movq 0x8(%r15), %r12
xorl %ecx, %ecx
movq %r15, 0x8(%rsp)
cmpl $0x0, 0x4(%r15)
jle 0x2887
xorl %ebp, %ebp
xorl %r13d, %r13d
movq %rcx, 0x20(%rsp)
testq %r12, %r12
je 0x28ac
movq 0x8(%r12), %r15
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movq %rbx, %rdi
movq %r14, %rsi
callq 0x25fc
movq 0x10(%r15), %r15
testq %r15, %r15
je 0x2850
movq %rbp, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq %rax, %rbp
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movq %rbx, %rdi
movq %r14, %rsi
callq 0x25fc
movq %rax, %r13
movq %rbp, %rdi
movq %rax, %rsi
callq 0x1e23
movq %rax, %rbp
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x2816
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x28cb
testq %r13, %r13
je 0x28cb
movq %rax, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x1e8e
movq %rax, %rbp
movq 0x20(%rsp), %rcx
incl %ecx
movq 0x10(%r12), %r12
movq 0x8(%rsp), %rax
cmpl 0x4(%rax), %ecx
jl 0x27d7
jmp 0x2889
xorl %ebp, %ebp
testq %r12, %r12
jne 0x28ea
movq %rbp, 0x10(%rbx)
movq %r14, %rdi
callq 0x2909
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18ef(%rip), %rdi      # 0x41a2
leaq 0x19ae(%rip), %rsi      # 0x4268
leaq 0x1a3b(%rip), %rcx      # 0x42fc
movl $0x5d, %edx
callq 0x10a0
leaq 0x18b9(%rip), %rdi      # 0x418b
leaq 0x198f(%rip), %rsi      # 0x4268
leaq 0x1a1c(%rip), %rcx      # 0x42fc
movl $0x77, %edx
callq 0x10a0
leaq 0x18b0(%rip), %rdi      # 0x41a1
leaq 0x1970(%rip), %rsi      # 0x4268
leaq 0x19fd(%rip), %rcx      # 0x42fc
movl $0x7d, %edx
callq 0x10a0