// File: /workspace/github_c_makefile_star2_O0/saulvargas[P]re-C-sys/test_ib.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 uid;
    int i;
    similarity_t* similarity;
    recommender_t* recommender;
    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);
    }

    recommender = recommender_ib_create(recdata, similarity, 10, binary);

    for (uid = 0; uid < recdata->N_users; uid++) {
        pairs = recommender_recommend(recommender, uid, 100);

        for (i = 0; i < idpairs_size(pairs); i++) {
            printf("%d\t%d\t%.4f\n", uid, idpairs_keys(pairs)[i], idpairs_values(pairs)[i]);
        }
        
        idpairs_close_deep(pairs);
    }
 
    recommender_close(recommender);
 
    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 0x32c0
cmpl $0x0, %eax
jne 0x1277
movl $0x1, -0x4(%rbp)
jmp 0x13c6
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 0x1970
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x1aa0
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 0x2130
movq %rax, -0x50(%rbp)
jmp 0x12d7
movq -0x40(%rbp), %rdi
callq 0x1da0
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x30(%rbp), %ecx
movl $0xa, %edx
callq 0x2fd0
movq %rax, -0x58(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x139b
movq -0x58(%rbp), %rdi
movl -0x44(%rbp), %esi
movl $0x64, %edx
callq 0x29d0
movq %rax, -0x60(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x60(%rbp), %rdi
callq 0x3120
movl %eax, %ecx
movl -0x64(%rbp), %eax
cmpl %ecx, %eax
jge 0x1384
movl -0x44(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x60(%rbp), %rdi
callq 0x3130
movslq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
callq 0x3150
movl -0x6c(%rbp), %esi
movl -0x68(%rbp), %edx
movslq -0x48(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0x2c92(%rip), %rdi      # 0x4004
movb $0x1, %al
callq 0x1080
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x1322
movq -0x60(%rbp), %rdi
callq 0x30c0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x12f7
movq -0x58(%rbp), %rdi
callq 0x2b10
movq -0x50(%rbp), %rdi
callq 0x1b80
movq -0x38(%rbp), %rdi
callq 0x14a0
movq -0x40(%rbp), %rdi
callq 0x14a0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)