// File: /workspace/github_c_makefile_star2_O3/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, 0x20(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, %r15
movq %rdi, %r14
movslq %r8d, %rbx
movl $0x4, %esi
movq %rbx, %rdi
callq 0x1090
movq %r14, 0x18(%rsp)
movq %rax, (%r14)
movl $0x8, %esi
movq %rbx, %rdi
callq 0x1090
movq %r15, 0x28(%rsp)
movq %rax, (%r15)
movslq %ebp, %r14
leaq (,%r14,4), %rdi
callq 0x10b0
movq %rax, %r12
cmpl $0x0, 0x180(%rsp)
je 0x142c
xorl %ebx, %ebx
xorl %ebp, %ebp
jmp 0x144b
movl $0x8, %esi
movq %rbx, %rdi
callq 0x1090
movq %rax, %rbx
shlq $0x3, %r14
movq %r14, %rdi
callq 0x10b0
movq %rax, %rbp
movq 0x10(%rsp), %rax
movq %rbx, (%rax)
leaq 0x40(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x20(%rsp), %rdx
callq 0x1080
testq %rax, %rax
je 0x15b4
xorl %eax, %eax
cmpl $0x0, 0x180(%rsp)
sete %al
shll $0x3, %eax
movq %rax, 0x38(%rsp)
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
leaq 0x1b70(%rip), %r14      # 0x3004
leaq 0x40(%rsp), %rdi
movq %r12, %r13
movq %r12, 0x8(%rsp)
movq %r12, %rbx
movq %rdi, %r15
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
movq %r14, %rsi
movl %eax, %r14d
cmpl $0x0, 0x180(%rsp)
je 0x14ed
movl 0x4(%rsp), %edx
cmpl %edx, %r12d
jne 0x150b
movl %r14d, (%rbx)
jmp 0x1578
xorl %edi, %edi
callq 0x10d0
movq %rax, %rdi
callq 0x1050
movsd %xmm0, 0x30(%rsp)
movl 0x4(%rsp), %edx
cmpl %edx, %r12d
je 0x1566
cmpl $-0x1, %edx
je 0x152a
movq %r13, %rax
subq 0x8(%rsp), %rax
shrq $0x2, %rax
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
movslq %edx, %rdx
movl %eax, (%rcx,%rdx,4)
movq 0x28(%rsp), %rax
movq (%rax), %rcx
movslq %r12d, %rax
movq %rbx, (%rcx,%rax,8)
cmpl $0x0, 0x180(%rsp)
je 0x1552
movl %r14d, (%rbx)
movl %r12d, 0x4(%rsp)
movq %rbx, 0x8(%rsp)
jmp 0x1578
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movq %rbp, (%rcx,%rax,8)
movl %r12d, %edx
movq %rbx, 0x8(%rsp)
movl %edx, 0x4(%rsp)
movl %r14d, (%rbx)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rbp)
addq $0x4, %rbx
addq 0x38(%rsp), %rbp
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x20(%rsp), %rdx
callq 0x1080
movq %r15, %rdi
addq $0x4, %r13
testq %rax, %rax
leaq 0x1a60(%rip), %r14      # 0x3004
jne 0x14a4
movslq %r12d, %rax
movq 0x8(%rsp), %r12
jmp 0x15b9
xorl %eax, %eax
movq %r12, %rbx
subq %r12, %rbx
shrq $0x2, %rbx
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
movl %ebx, (%rcx,%rax,4)
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq