// File: /workspace/github_c_makefile_star2_O2/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 $0x148, %rsp            # imm = 0x148
movl %r9d, %ebp
movq %rcx, 0x38(%rsp)
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbx
movslq %r8d, %r14
pushq $0x4
popq %rsi
movq %r14, %rdi
callq 0x1090
movq %rbx, 0x10(%rsp)
movq %rax, (%rbx)
pushq $0x8
popq %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1090
movq %r15, 0x28(%rsp)
movq %rax, (%r15)
movslq %ebp, %r15
leaq (,%r15,4), %rdi
callq 0x10b0
movq %rax, %rcx
xorl %r12d, %r12d
movl $0x0, %eax
movq %rax, 0x18(%rsp)
movl $0x0, %eax
cmpl $0x0, 0x180(%rsp)
jne 0x1456
movq %r14, %rdi
movq %rbx, %rsi
movq %rcx, %r14
callq 0x1090
movq %rax, %r12
shlq $0x3, %r15
movq %r15, %rdi
callq 0x10b0
movq %r14, %rcx
movq %rbx, 0x18(%rsp)
movq %rax, 0x8(%rsp)
movq %r13, 0x20(%rsp)
movq %r12, (%r13)
pushq $-0x1
popq %rax
movl %eax, 0x4(%rsp)
leaq 0x40(%rsp), %r14
movq %rcx, %rbx
movq %rcx, %rbp
movq %rcx, %r15
movq %r14, %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x38(%rsp), %rdx
callq 0x1080
testq %rax, %rax
je 0x1593
movq %r14, %rdi
leaq 0x1b66(%rip), %r13      # 0x3004
movq %r13, %rsi
callq 0x10d0
movq %rax, %rdi
callq 0x10e0
movl %eax, %r12d
xorl %edi, %edi
movq %r13, %rsi
callq 0x10d0
movq %rax, %rdi
callq 0x10e0
movl %eax, %r14d
cmpl $0x0, 0x180(%rsp)
je 0x14de
movl 0x4(%rsp), %edx
cmpl %edx, %r12d
jne 0x1506
movl %r14d, (%r15)
jmp 0x1545
xorl %edi, %edi
movq %r13, %rsi
callq 0x10d0
movq %rax, %rdi
callq 0x1050
movsd %xmm0, 0x30(%rsp)
movl 0x4(%rsp), %edx
cmpl %edx, %r12d
jne 0x1506
movq 0x8(%rsp), %rax
jmp 0x1566
cmpl $-0x1, %edx
je 0x1523
movq %rbx, %rax
subq %rbp, %rax
shrq $0x2, %rax
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movslq %edx, %rdx
movl %eax, (%rcx,%rdx,4)
movq 0x28(%rsp), %rax
movq (%rax), %rcx
movslq %r12d, %rax
movq %r15, (%rcx,%rax,8)
cmpl $0x0, 0x180(%rsp)
je 0x154c
movl %r14d, (%r15)
movl %r12d, %edx
movq %r15, %rbp
movq 0x8(%rsp), %rax
jmp 0x1573
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
movq 0x8(%rsp), %rdx
movq %rdx, (%rcx,%rax,8)
movq %rdx, %rax
movl %r12d, %edx
movq %r15, %rbp
movl %r14d, (%r15)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
movl %edx, 0x4(%rsp)
addq $0x4, %r15
addq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
addq $0x4, %rbx
leaq 0x40(%rsp), %r14
jmp 0x1479
subq %rbp, %rbx
shrq $0x2, %rbx
movq 0x10(%rsp), %rax
movq (%rax), %rax
movslq %r12d, %rcx
movl %ebx, (%rax,%rcx,4)
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq