// File: /workspace/github_c_makefile_star2_O1/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 0x264c
movq %rax, %r14
movq 0x8(%r15), %r12
xorl %ecx, %ecx
movq %r15, 0x8(%rsp)
cmpl $0x0, 0x4(%r15)
jle 0x2953
xorl %ebp, %ebp
xorl %r13d, %r13d
movq %rcx, 0x20(%rsp)
testq %r12, %r12
je 0x2978
movq 0x8(%r12), %r15
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movq %rbx, %rdi
movq %r14, %rsi
callq 0x26c8
movq 0x10(%r15), %r15
testq %r15, %r15
je 0x291c
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 0x26c8
movq %rax, %r13
movq %rbp, %rdi
movq %rax, %rsi
callq 0x1eda
movq %rax, %rbp
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x28e2
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x2997
testq %r13, %r13
je 0x2997
movq %rax, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x1f47
movq %rax, %rbp
movq 0x20(%rsp), %rcx
incl %ecx
movq 0x10(%r12), %r12
movq 0x8(%rsp), %rax
cmpl 0x4(%rax), %ecx
jl 0x28a3
jmp 0x2955
xorl %ebp, %ebp
testq %r12, %r12
jne 0x29b6
movq %rbp, 0x10(%rbx)
movq %r14, %rdi
callq 0x29d5
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1813(%rip), %rdi      # 0x4192
leaq 0x18d2(%rip), %rsi      # 0x4258
leaq 0x195f(%rip), %rcx      # 0x42ec
movl $0x5d, %edx
callq 0x10a0
leaq 0x17dd(%rip), %rdi      # 0x417b
leaq 0x18b3(%rip), %rsi      # 0x4258
leaq 0x1940(%rip), %rcx      # 0x42ec
movl $0x77, %edx
callq 0x10a0
leaq 0x17d4(%rip), %rdi      # 0x4191
leaq 0x1894(%rip), %rsi      # 0x4258
leaq 0x1921(%rip), %rcx      # 0x42ec
movl $0x7d, %edx
callq 0x10a0