// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movslq -0x24(%rbp), %rdi
movl $0x4, %esi
callq 0x1090
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movslq -0x24(%rbp), %rdi
movl $0x8, %esi
callq 0x1090
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movslq -0x28(%rbp), %rdi
shlq $0x2, %rdi
callq 0x10b0
movq %rax, -0x158(%rbp)
cmpl $0x0, 0x10(%rbp)
jne 0x166e
movslq -0x24(%rbp), %rdi
movl $0x8, %esi
callq 0x1090
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movslq -0x28(%rbp), %rdi
shlq $0x3, %rdi
callq 0x10b0
movq %rax, -0x160(%rbp)
jmp 0x1684
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x160(%rbp)
movl $0xffffffff, -0x134(%rbp) # imm = 0xFFFFFFFF
movq -0x158(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0x130(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0x1080
cmpq $0x0, %rax
je 0x180c
leaq -0x130(%rbp), %rdi
leaq 0x293b(%rip), %rsi      # 0x4004
callq 0x10d0
movq %rax, %rdi
callq 0x10e0
movl %eax, -0x144(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x291d(%rip), %rsi      # 0x4004
callq 0x10d0
movq %rax, %rdi
callq 0x10e0
movl %eax, -0x148(%rbp)
cmpl $0x0, 0x10(%rbp)
jne 0x1720
xorl %eax, %eax
movl %eax, %edi
leaq 0x28f9(%rip), %rsi      # 0x4004
callq 0x10d0
movq %rax, %rdi
callq 0x1050
movsd %xmm0, -0x150(%rbp)
movl -0x144(%rbp), %eax
cmpl -0x134(%rbp), %eax
je 0x17b5
cmpl $-0x1, -0x134(%rbp)
je 0x1763
movq -0x158(%rbp), %rax
movq -0x140(%rbp), %rcx
subq %rcx, %rax
sarq $0x2, %rax
movl %eax, %edx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x134(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x158(%rbp), %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x144(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
cmpl $0x0, 0x10(%rbp)
jne 0x179b
movq -0x160(%rbp), %rdx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x144(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x144(%rbp), %eax
movl %eax, -0x134(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x140(%rbp)
movl -0x148(%rbp), %ecx
movq -0x158(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x0, 0x10(%rbp)
jne 0x17dd
movsd -0x150(%rbp), %xmm0
movq -0x160(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x158(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x158(%rbp)
cmpl $0x0, 0x10(%rbp)
jne 0x1807
movq -0x160(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x160(%rbp)
jmp 0x169c
movq -0x158(%rbp), %rax
movq -0x140(%rbp), %rcx
subq %rcx, %rax
sarq $0x2, %rax
movl %eax, %edx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x144(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopl (%rax)