// File: /workspace/github_c_makefile_star2_O2/trumabrat[P]GrandProjet/reseau.c
// Function: ecrireReseau
void ecrireReseau(Reseau *R, FILE *f){
    // sauvegarde de l'information fondamentale
    fprintf(f, "NbNoeuds: %d\n", R->nbNoeuds);
    fprintf(f, "NbLiaisons: %d\n", nbLiaisons(R));
    fprintf(f, "NbCommodites: %d\n", nbCommodites(R));
    fprintf(f, "Gamma: %d\n", R->gamma);
    fprintf(f,"\n");

    int cpt = 0;// pour securiser le processus
    CellNoeud* cnd = R->noeuds;
    Noeud* nd = NULL;

    // l'enregistrement de l'information des Noeud
    while(cnd){
        assert(cpt<R->nbNoeuds);
        nd = cnd->nd;
        fprintf(f, "v %d %.6lf %.6lf\n", nd->num, nd->x, nd->y);
        cnd = cnd->suiv;
        cpt++;
    }
    fprintf(f,"\n");

    // l'enregistrement de l'information des liasons
    CellNoeud* cndVoisin = NULL;
    //Pour chaque noeud du reseau
    for (cnd = R->noeuds, cpt = 0; cnd ; cnd = cnd->suiv, cpt++)
    {
        assert(cpt < R->nbNoeuds);// securisation
        cndVoisin = cnd->nd->voisins;

        // Pour chaque voisin
        while(cndVoisin){
            if(cndVoisin->nd->num < cnd->nd->num){ // pour une liaison n'apparaisse deux fois
                fprintf(f, "l %d %d\n", cndVoisin->nd->num, cnd->nd->num);
            }
            cndVoisin = cndVoisin->suiv;
        }
    }
    fprintf(f, "\n");

    // l'enregistrement de l'information des commodite
    CellCommodite* cell_com = R->commodites;
    while (cell_com)
    {
        fprintf(f, "k %d %d\n", cell_com->extrA->num, cell_com->extrB->num);
        cell_com = cell_com->suiv;
    }
    fprintf(f,"\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl (%rdi), %edx
leaq 0x12bc(%rip), %rsi      # 0x31ac
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
callq 0x1e9e
leaq 0x12af(%rip), %rsi      # 0x31ba
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
callq 0x1ec7
leaq 0x12a4(%rip), %rsi      # 0x31ca
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x10d0
movl 0x4(%r14), %edx
leaq 0x11e0(%rip), %rsi      # 0x311d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x10b0
leaq 0x8(%r14), %r12
leaq 0x12b3(%rip), %r15      # 0x3210
movq %r12, %r13
movq (%r13), %r13
testq %r13, %r13
je 0x1f97
cmpl (%r14), %ebp
jge 0x2047
movq (%r13), %rax
movl (%rax), %edx
movsd 0x8(%rax), %xmm0
movsd 0x10(%rax), %xmm1
movq %rbx, %rdi
movq %r15, %rsi
movb $0x2, %al
callq 0x10d0
addq $0x8, %r13
incl %ebp
jmp 0x1f60
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x10b0
leaq 0x128b(%rip), %r15      # 0x3234
xorl %ebp, %ebp
movq (%r12), %r12
testq %r12, %r12
je 0x1ff9
cmpl (%r14), %ebp
jge 0x2066
movq (%r12), %r13
addq $0x18, %r13
movq (%r13), %r13
testq %r13, %r13
je 0x1ff1
movq (%r13), %rax
movl (%rax), %edx
movq (%r12), %rax
movl (%rax), %ecx
cmpl %ecx, %edx
jge 0x1feb
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
addq $0x8, %r13
jmp 0x1fc5
addq $0x8, %r12
incl %ebp
jmp 0x1fab
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x10b0
leaq 0x1232(%rip), %r15      # 0x323d
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x202e
movq (%r14), %rax
movq 0x8(%r14), %rcx
movl (%rax), %edx
movl (%rcx), %ecx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
jmp 0x200b
pushq $0xa
popq %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0
leaq 0x118e(%rip), %rdi      # 0x31dc
leaq 0x1103(%rip), %rsi      # 0x3158
leaq 0x1190(%rip), %rcx      # 0x31ec
movl $0xb9, %edx
callq 0x10a0
leaq 0x11b5(%rip), %rdi      # 0x3222
leaq 0x10e4(%rip), %rsi      # 0x3158
leaq 0x1171(%rip), %rcx      # 0x31ec
movl $0xc6, %edx
callq 0x10a0