// File: /workspace/github_c_makefile_star2_O1/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 0x2053(%rip), %rsi      # 0x419c
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x2186
xorl %ecx, %ecx
movq (%rax), %rdx
movq 0x18(%rdx), %rdx
testq %rdx, %rdx
je 0x2174
incl %ecx
movq 0x8(%rdx), %rdx
jmp 0x2167
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x2160
movl %ecx, %ebp
shrl $0x1f, %ebp
addl %ecx, %ebp
sarl %ebp
leaq 0x201d(%rip), %rsi      # 0x41aa
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x10d0
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r14, %rax
movq 0x10(%rax), %rax
incl %edx
testq %rax, %rax
jne 0x21a1
leaq 0x2007(%rip), %rsi      # 0x41ba
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
movl 0x4(%r14), %edx
leaq 0x1f3d(%rip), %rsi      # 0x4105
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10b0
movq 0x8(%r14), %r12
testq %r12, %r12
je 0x2226
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
leaq 0x200c(%rip), %r15      # 0x4200
incl %ebp
cmpl (%r14), %ebp
jge 0x22e3
movq (%r12), %rax
movl (%rax), %edx
movsd 0x8(%rax), %xmm0
movsd 0x10(%rax), %xmm1
movq %rbx, %rdi
movq %r15, %rsi
movb $0x2, %al
callq 0x10d0
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x21f4
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10b0
movq 0x8(%r14), %r12
testq %r12, %r12
je 0x228a
leaq 0x1fe1(%rip), %r15      # 0x4224
xorl %ebp, %ebp
cmpl (%r14), %ebp
jge 0x2302
movq (%r12), %rax
movq 0x18(%rax), %r13
testq %r13, %r13
je 0x227e
movq (%r13), %rax
movl (%rax), %edx
movq (%r12), %rax
movl (%rax), %ecx
cmpl %ecx, %edx
jge 0x2278
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
movq 0x8(%r13), %r13
jmp 0x2256
incl %ebp
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x2245
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10b0
movq 0x10(%r14), %r15
testq %r15, %r15
je 0x22c8
leaq 0x1f86(%rip), %r14      # 0x422d
movq (%r15), %rax
movq 0x8(%r15), %rcx
movl (%rax), %edx
movl (%rcx), %ecx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x10d0
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x22a7
movl $0xa, %edi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0
leaq 0x1ee2(%rip), %rdi      # 0x41cc
leaq 0x1e57(%rip), %rsi      # 0x4148
leaq 0x1ee4(%rip), %rcx      # 0x41dc
movl $0xb9, %edx
callq 0x10a0
leaq 0x1f09(%rip), %rdi      # 0x4212
leaq 0x1e38(%rip), %rsi      # 0x4148
leaq 0x1ec5(%rip), %rcx      # 0x41dc
movl $0xc6, %edx
callq 0x10a0