// File: /workspace/github_cpp_makefile_star2_O3/CastellanZhang[P]lambdaFM/./src/FTRL/ftrl_model.h
// Function: ftrl_model::predict(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*>>>&, std::vector<double, std::allocator<double>>&)
double ftrl_model::predict(unordered_map<string, double>& x, unordered_map<string, ftrl_model_unit*>& theta, vector<double>& sum)
{
    double result = 0;
    for(unordered_map<string, double>::iterator iter = x.begin(); iter != x.end(); ++iter)
    {
        const string& index = iter->first;
        result += theta[index]->wi * iter->second;
    }
    double sum_sqr, d;
    for(int f = 0; f < factor_num; ++f)
    {
        sum[f] = sum_sqr = 0.0;
        for(unordered_map<string, double>::iterator iter = x.begin(); iter != x.end(); ++iter)
        {
            const string& index = iter->first;
            d = theta[index]->vi[f] * iter->second;
            sum[f] += d;
            sum_sqr += d * d;
        }
        result += 0.5 * (sum[f] * sum[f] - sum_sqr);
    }
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movq 0x10(%rsi), %r13
xorpd %xmm0, %xmm0
testq %r13, %r13
je 0x3950
movsd %xmm0, 0x8(%rsp)
leaq 0x8(%r13), %rsi
movq %r14, %rdi
callq 0x5eea
movsd 0x8(%rsp), %xmm0
movq (%rax), %rax
movsd (%rax), %xmm1
mulsd 0x28(%r13), %xmm1
addsd %xmm1, %xmm0
movq (%r13), %r13
jmp 0x391c
movl 0x38(%r12), %ecx
testl %ecx, %ecx
jle 0x3a10
movq (%rbx), %rax
xorl %r13d, %r13d
movq $0x0, (%rax,%r13,8)
movq 0x10(%r15), %rbp
testq %rbp, %rbp
je 0x39e5
movsd %xmm0, 0x8(%rsp)
xorpd %xmm1, %xmm1
movsd %xmm1, 0x10(%rsp)
leaq 0x8(%rbp), %rsi
movq %r14, %rdi
callq 0x5eea
movq (%rax), %rax
movq 0x18(%rax), %rax
movsd (%rax,%r13,8), %xmm1
mulsd 0x28(%rbp), %xmm1
movq (%rbx), %rax
movsd (%rax,%r13,8), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%rax,%r13,8)
mulsd %xmm1, %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x10(%rsp), %xmm1
movq (%rbp), %rbp
testq %rbp, %rbp
jne 0x397e
movl 0x38(%r12), %ecx
movsd 0x8(%rsp), %xmm0
jmp 0x39ed
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
mulsd %xmm2, %xmm2
subsd %xmm1, %xmm2
mulsd 0x560b(%rip), %xmm2     # 0x9008
addsd %xmm2, %xmm0
incq %r13
movslq %ecx, %rdx
cmpq %rdx, %r13
jl 0x3963
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop