// File: /workspace/github_c_makefile_star2_O0/saulvargas[P]re-C-sys/test_itemsim.c
// Function: main
int main(int argc, char** argv) {
    FILE* user_data;
    FILE* item_data;
    int N_users;
    int N_items;
    int N_prefs;
    int binary;
    recdata_t* recdata;
    recdata_t* cerdata;
    int iid;
    int i;
    similarity_t* similarity;
    idpairs_t* pairs;

    if (!read_args(argc, argv, &user_data, &item_data, &N_users, &N_items, &N_prefs, &binary)) {
        return EXIT_FAILURE;
    }

    recdata = recdata_simple_create(user_data, item_data, N_users, N_items, N_prefs, binary);
    cerdata = recdata_transposed_create(recdata);
    
    fclose(user_data);
    fclose(item_data);

    if (!binary) {
        similarity = similarity_veccosine_create(cerdata);
    } else {
        similarity = similarity_setcosine_create(cerdata);
    }

    for (iid = 0; iid < recdata->N_items; iid++) {
        pairs = similarity_calculate(similarity, iid, 10);

        for (i = 0; i < idpairs_size(pairs); i++) {
            printf("%d\t%d\t%.4f\n", iid, idpairs_keys(pairs)[i], idpairs_values(pairs)[i]);
        }
        
        idpairs_close_deep(pairs);
    }
 
    similarity_close(similarity);
    
    recdata_close(recdata);
    recdata_close(cerdata);
   
    return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq -0x18(%rbp), %rdx
leaq -0x20(%rbp), %rcx
leaq -0x24(%rbp), %r8
leaq -0x28(%rbp), %r9
leaq -0x2c(%rbp), %r10
leaq -0x30(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x32a0
cmpl $0x0, %eax
jne 0x1277
movl $0x1, -0x4(%rbp)
jmp 0x13a5
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
movl -0x2c(%rbp), %r8d
movl -0x30(%rbp), %r9d
callq 0x1950
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x1a80
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1060
movq -0x20(%rbp), %rdi
callq 0x1060
cmpl $0x0, -0x30(%rbp)
jne 0x12ca
movq -0x40(%rbp), %rdi
callq 0x2110
movq %rax, -0x50(%rbp)
jmp 0x12d7
movq -0x40(%rbp), %rdi
callq 0x1d80
movq %rax, -0x50(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x1383
movq -0x50(%rbp), %rdi
movl -0x44(%rbp), %esi
movl $0xa, %edx
callq 0x1b30
movq %rax, -0x58(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rdi
callq 0x3100
movl %eax, %ecx
movl -0x5c(%rbp), %eax
cmpl %ecx, %eax
jge 0x136c
movl -0x44(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x58(%rbp), %rdi
callq 0x3110
movslq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
callq 0x3130
movl -0x64(%rbp), %esi
movl -0x60(%rbp), %edx
movslq -0x48(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0x2caa(%rip), %rdi      # 0x4004
movb $0x1, %al
callq 0x1080
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x130a
movq -0x58(%rbp), %rdi
callq 0x30a0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x12de
movq -0x50(%rbp), %rdi
callq 0x1b60
movq -0x38(%rbp), %rdi
callq 0x1480
movq -0x40(%rbp), %rdi
callq 0x1480
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)