// File: /workspace/github_cpp_makefile_star2_O2/bowbowbow[P]CollaborativeFiltering/recommender.cpp
// Function: main
int main(int argc, const char * argv[]) {
    if(argc!=3) {
        cout << "Please follow this format. recommender.exe [base file name] [test file name]";
        return 0;
    }
    
    string baseFileName(argv[1]);
    string testFileName(argv[2]);
    
    InputReader baseInputReader(baseFileName);
    
    MAT userToItem = baseInputReader.getUserToItem();
    CF cf(userToItem);
    cf.run();
    
    InputReader testInputReader(testFileName);
    vector<inputTuple> test = testInputReader.getInput();
    
    OutputPrinter outputPrinter(testFileName.substr(0, 2)+".base_prediction.txt");
    
    double RSME = 0.0;
    
    for(int i=0;i<test.size();i++) {
        int user = test[i].user;
        int item = test[i].item;
        int rating = test[i].rating;
        
        double predict = cf.predict(user, item);
        
        RSME += (predict-rating)*(predict-rating);
        outputPrinter.addLine(user, item, predict);
    }
    
    RSME /= (double)test.size();
    RSME = sqrt(RSME);
    cout << "RSME :" << RSME << endl;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7f8, %rsp            # imm = 0x7F8
cmpl $0x3, %edi
jne 0x2573
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
leaq -0x140(%rbp), %rdi
leaq -0x3c8(%rbp), %rdx
callq 0x2060
movq 0x10(%rbx), %rsi
leaq -0xa0(%rbp), %rdi
leaq -0x3c8(%rbp), %rdx
callq 0x2060
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x21a0
leaq -0x3c8(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x2722
leaq -0x120(%rbp), %rdi
callq 0x2080
leaq -0x1c0(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x27d2
leaq -0x68(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x27d2
leaq -0x190(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x282c
leaq -0x68(%rbp), %rdi
callq 0x28f0
leaq -0x190(%rbp), %rdi
callq 0x36a0
leaq -0x100(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x21a0
leaq -0x820(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x2722
leaq -0x100(%rbp), %rdi
callq 0x2080
leaq -0x600(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x38e8
leaq -0xc0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
pushq $0x2
popq %rcx
xorl %edx, %edx
callq 0x2160
leaq 0x1bce(%rip), %rdx      # 0x407d
leaq -0xe0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x291b
leaq -0x5e8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x2944
leaq -0xe0(%rbp), %rdi
callq 0x2080
leaq -0xc0(%rbp), %rdi
callq 0x2080
xorpd %xmm0, %xmm0
pushq $0x8
popq %r13
xorl %ebx, %ebx
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
subq %rcx, %rax
cqto
pushq $0xc
popq %rsi
idivq %rsi
cmpq %rbx, %rax
jbe 0x258b
movsd %xmm0, -0x30(%rbp)
movl -0x8(%rcx,%r13), %r15d
movl -0x4(%rcx,%r13), %r12d
movl (%rcx,%r13), %r14d
leaq -0x190(%rbp), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x29f0
cvtsi2sd %eax, %xmm0
leaq -0x5e8(%rbp), %rdi
movl %r15d, %esi
movl %r12d, %edx
movsd %xmm0, -0x38(%rbp)
callq 0x2a8c
cvtsi2sd %r14d, %xmm0
movsd -0x38(%rbp), %xmm1
subsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
movsd -0x30(%rbp), %xmm0
addsd %xmm1, %xmm0
incq %rbx
addq $0xc, %r13
jmp 0x24f7
movq 0x4a5e(%rip), %rdi      # 0x6fd8
leaq 0x1aaf(%rip), %rsi      # 0x4030
callq 0x2140
jmp 0x2630
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x25a4
sqrtsd %xmm0, %xmm0
jmp 0x25a9
callq 0x20f0
movsd %xmm0, -0x30(%rbp)
movq 0x4a23(%rip), %rdi      # 0x6fd8
leaq 0x1ad6(%rip), %rsi      # 0x4092
callq 0x2140
movq %rax, %rdi
movsd -0x30(%rbp), %xmm0
callq 0x21e0
movq %rax, %rdi
callq 0x20a0
leaq -0x5e8(%rbp), %rdi
callq 0x2ae8
leaq -0x50(%rbp), %rdi
callq 0x3946
leaq -0x820(%rbp), %rdi
callq 0x2b0c
leaq -0x190(%rbp), %rdi
callq 0x2b3c
leaq -0x80(%rbp), %rdi
callq 0x28f0
leaq -0x3c8(%rbp), %rdi
callq 0x2b0c
leaq -0xa0(%rbp), %rdi
callq 0x2080
leaq -0x140(%rbp), %rdi
callq 0x2080
xorl %eax, %eax
addq $0x7f8, %rsp            # imm = 0x7F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x2080
jmp 0x2658
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x2080
jmp 0x26cc
movq %rax, %rbx
jmp 0x26cc
movq %rax, %rbx
jmp 0x26d5
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
callq 0x2080
jmp 0x26e1
jmp 0x2683
movq %rax, %rbx
jmp 0x26e1
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x28f0
jmp 0x26ed
movq %rax, %rbx
jmp 0x26ed
movq %rax, %rbx
jmp 0x26f6
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x2080
jmp 0x2702
movq %rax, %rbx
jmp 0x2702
movq %rax, %rbx
jmp 0x270e
jmp 0x26bd
movq %rax, %rbx
leaq -0x5e8(%rbp), %rdi
callq 0x2ae8
leaq -0x50(%rbp), %rdi
callq 0x3946
leaq -0x820(%rbp), %rdi
callq 0x2b0c
leaq -0x190(%rbp), %rdi
callq 0x2b3c
leaq -0x80(%rbp), %rdi
callq 0x28f0
leaq -0x3c8(%rbp), %rdi
callq 0x2b0c
leaq -0xa0(%rbp), %rdi
callq 0x2080
leaq -0x140(%rbp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x2230