// File: /workspace/github_c_makefile_star2_O0/saulvargas[P]re-C-sys/test_ub.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;
    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);
    
    fclose(user_data);
    fclose(item_data);

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

    recommender = recommender_ub_create(recdata, similarity, 100, 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);
    
    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 0x13b0
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 -0x18(%rbp), %rdi
callq 0x1060
movq -0x20(%rbp), %rdi
callq 0x1060
cmpl $0x0, -0x30(%rbp)
jne 0x12bd
movq -0x38(%rbp), %rdi
callq 0x2110
movq %rax, -0x48(%rbp)
jmp 0x12ca
movq -0x38(%rbp), %rdi
callq 0x1d80
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x30(%rbp), %ecx
movl $0x64, %edx
callq 0x2cd0
movq %rax, -0x50(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x138e
movq -0x50(%rbp), %rdi
movl -0x3c(%rbp), %esi
movl $0x64, %edx
callq 0x29b0
movq %rax, -0x58(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rdi
callq 0x3100
movl %eax, %ecx
movl -0x5c(%rbp), %eax
cmpl %ecx, %eax
jge 0x1377
movl -0x3c(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x58(%rbp), %rdi
callq 0x3110
movslq -0x40(%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 -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0x2c9f(%rip), %rdi      # 0x4004
movb $0x1, %al
callq 0x1080
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1315
movq -0x58(%rbp), %rdi
callq 0x30a0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x12ea
movq -0x50(%rbp), %rdi
callq 0x2af0
movq -0x48(%rbp), %rdi
callq 0x1b60
movq -0x38(%rbp), %rdi
callq 0x1480
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)