// File: /workspace/github_c_makefile_star2_O1/saulvargas[P]re-C-sys/recdata_simple.c
// Function: read_data
void read_data(int** n, int*** v, double*** r, FILE* data, int N, int N_prefs, int binary) {
    char line[MAX_LEN_LINE];
    int last_x;
    int* last_p;
    int x;
    int y;
    double z;
    int* p;
    double* q;

    *n = calloc(N, sizeof(int));
    *v = calloc(N, sizeof(int*));
    p = malloc(N_prefs * sizeof(int));
    if (!binary) {
        *r = calloc(N, sizeof(double*));
        q = malloc(N_prefs * sizeof(double));
    } else {
        *r = NULL;
        q = NULL;
    }
    last_x = -1;
    last_p = p;
    while (fgets(line, MAX_LEN_LINE, data) != NULL) {
        x = atoi(strtok(line, "\t"));
        y = atoi(strtok(NULL, "\t"));
        if (!binary) {
            z = atof(strtok(NULL, "\t"));
        }
        
        if (x != last_x) {
            if (last_x != -1) {
                (*n)[last_x] = p - last_p;
            }
            (*v)[x] = p;
            if (!binary) {
                (*r)[x] = q;
            }
            last_x = x;
            last_p = p;
        }
        *p = y;
        if (!binary) {
            *q = z;
        }
        
        p++;
        if (!binary) {
            q++;
        }
    }
    (*n)[x] = p - last_p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movl %r9d, %ebp
movq %rcx, 0x10(%rsp)
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
movslq %r8d, %rbx
movl $0x4, %esi
movq %rbx, %rdi
callq 0x1090
movq %r14, 0x8(%rsp)
movq %rax, (%r14)
movl $0x8, %esi
movq %rbx, %rdi
callq 0x1090
movq %r12, 0x20(%rsp)
movq %rax, (%r12)
movslq %ebp, %r14
leaq (,%r14,4), %rdi
callq 0x10b0
movq %rax, %r12
cmpl $0x0, 0x170(%rsp)
je 0x1430
movq $0x0, (%r15)
xorl %ebp, %ebp
jmp 0x144f
movl $0x8, %esi
movq %rbx, %rdi
callq 0x1090
movq %rax, (%r15)
shlq $0x3, %r14
movq %r14, %rdi
callq 0x10b0
movq %rax, %rbp
leaq 0x30(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x10(%rsp), %rdx
callq 0x1080
testq %rax, %rax
je 0x1584
movq %r15, 0x18(%rsp)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
leaq 0x30(%rsp), %r14
movq %r12, %rbx
movq %r12, (%rsp)
movq %r12, %r13
movq %r14, %rdi
leaq 0x1b74(%rip), %r14      # 0x3004
movq %r14, %rsi
callq 0x10d0
movq %rax, %rdi
callq 0x10e0
movl %eax, %r12d
xorl %edi, %edi
movq %r14, %rsi
callq 0x10d0
movq %rax, %rdi
callq 0x10e0
movl %eax, %r14d
cmpl $0x0, 0x170(%rsp)
jne 0x14de
xorl %edi, %edi
leaq 0x1b39(%rip), %rsi      # 0x3004
callq 0x10d0
movq %rax, %rdi
callq 0x1050
movsd %xmm0, 0x28(%rsp)
cmpl %r15d, %r12d
je 0x152e
cmpl $-0x1, %r15d
je 0x1502
movq %rbx, %rax
subq (%rsp), %rax
shrq $0x2, %rax
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movslq %r15d, %rdx
movl %eax, (%rcx,%rdx,4)
movq 0x20(%rsp), %rax
movq (%rax), %rcx
movslq %r12d, %rax
movq %r13, (%rcx,%rax,8)
cmpl $0x0, 0x170(%rsp)
jne 0x1527
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
movq %rbp, (%rcx,%rax,8)
movq %r13, (%rsp)
movl %r12d, %r15d
movl %r14d, (%r13)
cmpl $0x0, 0x170(%rsp)
je 0x1540
xorl %eax, %eax
jmp 0x1550
movsd 0x28(%rsp), %xmm0
movsd %xmm0, (%rbp)
movl $0x8, %eax
leaq 0x30(%rsp), %r14
addq $0x4, %r13
addq %rax, %rbp
movq %r14, %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x10(%rsp), %rdx
callq 0x1080
addq $0x4, %rbx
testq %rax, %rax
jne 0x1486
movslq %r12d, %rax
movq (%rsp), %r12
jmp 0x1589
xorl %eax, %eax
movq %r12, %r13
subq %r12, %r13
shrq $0x2, %r13
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movl %r13d, (%rcx,%rax,4)
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq