// File: /workspace/github_cpp_makefile_star2_O3/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 0x25b4
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
leaq -0x120(%rbp), %rdi
leaq -0x3c8(%rbp), %rdx
callq 0x2080
movq 0x10(%rbx), %rsi
leaq -0x90(%rbp), %rdi
leaq -0x3c8(%rbp), %rdx
callq 0x2080
leaq -0xf0(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rdx
addq %rsi, %rdx
leaq -0x100(%rbp), %rdi
callq 0x3c54
leaq -0x3c8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x298c
movq -0x100(%rbp), %rdi
cmpq %r14, %rdi
je 0x24b6
callq 0x2170
leaq -0x1c0(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x2a46
leaq -0xa8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x2a46
leaq -0x190(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x2ae2
leaq -0xa8(%rbp), %rdi
callq 0x2bd8
leaq -0x190(%rbp), %rdi
callq 0x390e
leaq -0xd0(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %rdi
callq 0x3c54
leaq -0x820(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x298c
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2553
callq 0x2170
leaq -0x600(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x3bc2
leaq -0x140(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movl $0x2, %ecx
xorl %edx, %edx
callq 0x21b0
leaq 0x1af9(%rip), %rsi      # 0x407d
leaq -0x140(%rbp), %rdi
callq 0x2290
leaq -0x60(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x25d1
movq %rdx, -0x70(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x60(%rbp)
jmp 0x25da
movq 0x3a1d(%rip), %rdi      # 0x5fd8
leaq 0x1a6e(%rip), %rsi      # 0x4030
movl $0x4c, %edx
callq 0x21d0
jmp 0x286a
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq -0x70(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x5e8(%rbp), %rdi
callq 0x2c2c
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0x260f
callq 0x2170
leaq -0x130(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2624
callq 0x2170
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
subq %rax, %rcx
je 0x26db
xorpd %xmm0, %xmm0
movl $0x8, %ebx
xorl %r14d, %r14d
movsd %xmm0, -0x30(%rbp)
movl -0x8(%rax,%rbx), %r12d
movl -0x4(%rax,%rbx), %r13d
movl (%rax,%rbx), %r15d
leaq -0x190(%rbp), %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x2ce4
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq -0x5e8(%rbp), %rdi
movl %r12d, %esi
movl %r13d, %edx
movsd %xmm0, -0x50(%rbp)
callq 0x2d8e
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd -0x50(%rbp), %xmm1
subsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
movsd -0x30(%rbp), %xmm0
addsd %xmm1, %xmm0
incq %r14
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
addq $0xc, %rbx
cmpq %r14, %rcx
ja 0x264b
jmp 0x26e7
sarq $0x2, %rcx
imulq %rdx, %rcx
xorpd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %rcx, %xmm1
divsd %xmm1, %xmm0
ucomisd 0x190d(%rip), %xmm0     # 0x4008
jb 0x2703
sqrtsd %xmm0, %xmm0
jmp 0x2708
callq 0x2120
movsd %xmm0, -0x30(%rbp)
leaq -0x1c0(%rbp), %rbx
movq 0x38bd(%rip), %rdi      # 0x5fd8
leaq 0x1970(%rip), %rsi      # 0x4092
movl $0x6, %edx
callq 0x21d0
movq 0x38a5(%rip), %rdi      # 0x5fd8
movsd -0x30(%rbp), %xmm0
callq 0x2220
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
leaq -0x3d8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x277c
callq 0x2170
movq 0x384d(%rip), %rax      # 0x5fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x5e0(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x5e8(%rbp,%rcx)
callq 0x2140
leaq -0x4f0(%rbp), %rdi
callq 0x2060
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x27c0
callq 0x2170
movq -0x600(%rbp), %rdi
testq %rdi, %rdi
je 0x27d1
callq 0x2170
leaq -0x618(%rbp), %rdi
callq 0x2bd8
leaq -0x820(%rbp), %rdi
callq 0x2040
movq -0x160(%rbp), %rdi
testq %rdi, %rdi
je 0x27fa
callq 0x2170
leaq -0x178(%rbp), %rdi
callq 0x2bd8
leaq -0x190(%rbp), %rdi
callq 0x2bd8
leaq -0xc0(%rbp), %rdi
callq 0x2bd8
movq -0x1a8(%rbp), %rdi
testq %rdi, %rdi
je 0x282f
callq 0x2170
movq %rbx, %rdi
callq 0x2bd8
leaq -0x3c8(%rbp), %rdi
callq 0x2040
leaq -0x80(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2855
callq 0x2170
leaq -0x110(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x286a
callq 0x2170
xorl %eax, %eax
addq $0x7f8, %rsp            # imm = 0x7F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0x2894
callq 0x2170
jmp 0x2894
movq %rax, %rbx
leaq -0x130(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x291e
callq 0x2170
jmp 0x291e
movq %rax, %rbx
jmp 0x291e
movq %rax, %rbx
jmp 0x292c
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2938
callq 0x2170
jmp 0x2938
jmp 0x28cd
movq %rax, %rbx
jmp 0x2938
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x2bd8
jmp 0x2944
movq %rax, %rbx
jmp 0x2944
movq %rax, %rbx
jmp 0x2950
movq %rax, %rbx
movq -0x100(%rbp), %rdi
cmpq %r14, %rdi
je 0x295c
callq 0x2170
jmp 0x295c
movq %rax, %rbx
jmp 0x295c
movq %rax, %rbx
jmp 0x296e
jmp 0x290f
movq %rax, %rbx
leaq -0x5e8(%rbp), %rdi
callq 0x2e1c
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x292c
callq 0x2170
leaq -0x820(%rbp), %rdi
callq 0x2e74
leaq -0x190(%rbp), %rdi
callq 0x2ea8
leaq -0xc0(%rbp), %rdi
callq 0x2bd8
leaq -0x3c8(%rbp), %rdi
callq 0x2e74
leaq -0x80(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x296e
callq 0x2170
leaq -0x110(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2983
callq 0x2170
movq %rbx, %rdi
callq 0x2270
nop