// File: /workspace/github_c_makefile_star2_O0/trumabrat[P]GrandProjet/chaine.c
// Function: lectureChaines
Chaines* lectureChaines(FILE *f){

    Chaines *res = (Chaines *)calloc(1,sizeof(Chaines));
    int nbChaine, gamma;
    int num, nbPoints;
    double x, y;

    // recuperer le nombre de chaines
    fscanf(f," %*s %d" , &nbChaine);

    // recuperer la valeur de gamma
    fscanf(f," %*s %d" , &gamma);

    res->nbChaines = nbChaine;
    res->gamma = gamma;
    CellChaine *liste_chaine = NULL;
    CellChaine *chaine_cur = NULL;
    CellPoint *liste_point = NULL;
    
    // pour chaque chaine
    for(int j =  0 ;  j < nbChaine ; j++){
        chaine_cur = (CellChaine *)calloc(1, sizeof(CellChaine));
        // on prend le nombre de points
        fscanf(f," %d %d", &num, &nbPoints);
        chaine_cur->numero = num;
        liste_point = NULL;

        // pour chaque point d'une chaine
        for(int i = 0 ; i < nbPoints; i++){
            CellPoint *point = (CellPoint*)malloc(sizeof(CellPoint));
            fscanf(f,"%lf %lf ", &x, &y);
            point->x = x;
            point->y = y;
            point->suiv = liste_point;
            liste_point = point;
        }

        // on passe a suivant
        chaine_cur->points = liste_point;
        chaine_cur->suiv = liste_chaine;
        liste_chaine = chaine_cur;
    }
    
    res->chaines = liste_chaine;
    return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl $0x1, %edi
movl $0x10, %esi
callq 0x10b0
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x36ee(%rip), %rsi      # 0x50f8
leaq -0x14(%rbp), %rdx
movb $0x0, %al
callq 0x1050
movq -0x8(%rbp), %rdi
leaq 0x36d8(%rip), %rsi      # 0x50f8
leaq -0x18(%rbp), %rdx
movb $0x0, %al
callq 0x1050
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1b46
movl $0x1, %edi
movl $0x18, %esi
callq 0x10b0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3679(%rip), %rsi      # 0x5100
leaq -0x1c(%rbp), %rdx
leaq -0x20(%rbp), %rcx
movb $0x0, %al
callq 0x1050
movl -0x1c(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x1b18
movl $0x18, %edi
callq 0x10d0
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3638(%rip), %rsi      # 0x5107
leaq -0x28(%rbp), %rdx
leaq -0x30(%rbp), %rcx
movb $0x0, %al
callq 0x1050
movsd -0x28(%rbp), %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x30(%rbp), %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x48(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1aae
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1a5d
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)