// File: /workspace/github_c_makefile_star2_O3/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 0x2120(%rip), %rsi      # 0x41ac
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x20c9
xorl %ecx, %ecx
movq (%rax), %rdx
movq 0x18(%rdx), %rdx
testq %rdx, %rdx
je 0x20b7
incl %ecx
movq 0x8(%rdx), %rdx
jmp 0x20aa
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x20a3
movl %ecx, %ebp
shrl $0x1f, %ebp
addl %ecx, %ebp
sarl %ebp
leaq 0x20ea(%rip), %rsi      # 0x41ba
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 0x20e4
leaq 0x20d4(%rip), %rsi      # 0x41ca
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
movl 0x4(%r14), %edx
leaq 0x200a(%rip), %rsi      # 0x4115
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10b0
movq 0x8(%r14), %r12
testq %r12, %r12
je 0x2169
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
leaq 0x20d9(%rip), %r15      # 0x4210
incl %ebp
cmpl (%r14), %ebp
jge 0x2226
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 0x2137
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10b0
movq 0x8(%r14), %r12
testq %r12, %r12
je 0x21cd
leaq 0x20ae(%rip), %r15      # 0x4234
xorl %ebp, %ebp
cmpl (%r14), %ebp
jge 0x2245
movq (%r12), %rax
movq 0x18(%rax), %r13
testq %r13, %r13
je 0x21c1
movq (%r13), %rax
movl (%rax), %edx
movq (%r12), %rax
movl (%rax), %ecx
cmpl %ecx, %edx
jge 0x21bb
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
movq 0x8(%r13), %r13
jmp 0x2199
incl %ebp
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x2188
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10b0
movq 0x10(%r14), %r15
testq %r15, %r15
je 0x220b
leaq 0x2053(%rip), %r14      # 0x423d
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 0x21ea
movl $0xa, %edi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0
leaq 0x1faf(%rip), %rdi      # 0x41dc
leaq 0x1f24(%rip), %rsi      # 0x4158
leaq 0x1fb1(%rip), %rcx      # 0x41ec
movl $0xb9, %edx
callq 0x10a0
leaq 0x1fd6(%rip), %rdi      # 0x4222
leaq 0x1f05(%rip), %rsi      # 0x4158
leaq 0x1f92(%rip), %rcx      # 0x41ec
movl $0xc6, %edx
callq 0x10a0