// File: CastellanZhang[P]lambdaFM/./src/FTRL/ftrl_model.h
// Function: ftrl_model::getScore(std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, double>>>&, std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, ftrl_model_unit*, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, ftrl_model_unit*>>>&)
double ftrl_model::getScore(unordered_map<string, double>& x, unordered_map<string, ftrl_model_unit*>& theta)
{
    double result = 0;
    for(unordered_map<string, double>::iterator iter = x.begin(); iter != x.end(); ++iter)
    {
        const string& index = iter->first;
        result += get_wi(theta, index) * iter->second;
    }
    double sum, sum_sqr, d;
    for(int f = 0; f < factor_num; ++f)
    {
        sum = sum_sqr = 0.0;
        for(unordered_map<string, double>::iterator iter = x.begin(); iter != x.end(); ++iter)
        {
            const string& index = iter->first;
            d = get_vif(theta, index, f) * iter->second;
            sum += d;
            sum_sqr += d * d;
        }
        result += 0.5 * (sum * sum - sum_sqr);
    }
    //return 1.0/(1.0 + exp(-result));
    return result;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
movq %rdx, 0x70(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x68(%rsp)
movq 0x78(%rsp), %rdi
callq 0x5680
movq %rax, 0x60(%rsp)
movq 0x78(%rsp), %rdi
callq 0x56d0
movq %rax, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x56b0
testb $0x1, %al
jne 0x3e52
jmp 0x3eb3
leaq 0x60(%rsp), %rdi
callq 0x5700
movq 0x10(%rsp), %rdi
movq %rax, 0x50(%rsp)
movq 0x70(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0x4010
movsd %xmm0, 0x8(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x5700
movsd 0x8(%rsp), %xmm0
movsd 0x20(%rax), %xmm2
movsd 0x68(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x5750
jmp 0x3e2e
movl $0x0, 0x34(%rsp)
movq 0x10(%rsp), %rcx
movl 0x34(%rsp), %eax
cmpl 0x38(%rcx), %eax
jge 0x3ff9
xorps %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x48(%rsp)
movq 0x78(%rsp), %rdi
callq 0x5680
movq %rax, 0x28(%rsp)
movq 0x78(%rsp), %rdi
callq 0x56d0
movq %rax, 0x20(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x56b0
testb $0x1, %al
jne 0x3f15
jmp 0x3f9c
leaq 0x28(%rsp), %rdi
callq 0x5700
movq 0x10(%rsp), %rdi
movq %rax, 0x18(%rsp)
movq 0x70(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0x34(%rsp), %ecx
callq 0x4090
movsd %xmm0, (%rsp)
leaq 0x28(%rsp), %rdi
callq 0x5700
movsd (%rsp), %xmm0
mulsd 0x20(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x38(%rsp), %xmm0
addsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x38(%rsp), %xmm0
movsd 0x38(%rsp), %xmm2
movsd 0x40(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x5750
jmp 0x3eee
movsd 0x48(%rsp), %xmm0
movsd 0x48(%rsp), %xmm2
movsd 0x40(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x68(%rsp), %xmm1
movsd 0xe02d(%rip), %xmm2     # 0x12008
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x3ebb
movsd 0x68(%rsp), %xmm0
addq $0x88, %rsp
retq
nopw (%rax,%rax)