// File: CastellanZhang[P]lambdaFM/./src/FTRL/ftrl_trainer.h
// Function: ftrl_trainer::trainPair(fm_sample&, fm_sample&, double)
void ftrl_trainer::trainPair(fm_sample& sample1, fm_sample& sample2, const double deltaNDCG)
{
    unordered_map<string, ftrl_model_unit*> theta;
    for(unordered_map<string, double>::iterator iter = sample1.x.begin(); iter != sample1.x.end(); ++iter)
    {
        const string& index = iter->first;
        if(theta.find(index) == theta.end())
        {
            theta[index] = pModel->getOrInitModelUnit(index);
        }
    }
    for(unordered_map<string, double>::iterator iter = sample2.x.begin(); iter != sample2.x.end(); ++iter)
    {
        const string& index = iter->first;
        if(theta.find(index) == theta.end())
        {
            theta[index] = pModel->getOrInitModelUnit(index);
        }
    }
    //update w via FTRL
    if(k1)
    {
        for(unordered_map<string, ftrl_model_unit*>::iterator iter = theta.begin(); iter != theta.end(); ++iter)
        {
            ftrl_model_unit& mu = *(iter->second);
            mu.mtx.lock();
            if(fabs(mu.w_zi) <= w_l1)
            {
                mu.wi = 0.0;
            }
            else
            {
                if(force_v_sparse && mu.w_ni > 0 && 0.0 == mu.wi)
                {
                    mu.reinit_vi(pModel->init_mean, pModel->init_stdev);
                }
                mu.wi = (-1) *
                    (1 / (w_l2 + (w_beta + sqrt(mu.w_ni)) / w_alpha)) *
                    (mu.w_zi - utils::sgn(mu.w_zi) * w_l1);
            }
            mu.mtx.unlock();
        }
    }
    //update v via FTRL
    for(unordered_map<string, ftrl_model_unit*>::iterator iter = theta.begin(); iter != theta.end(); ++iter)
    {
        ftrl_model_unit& mu = *(iter->second);
        for(int f = 0; f < pModel->factor_num; ++f)
        {
            mu.mtx.lock();
            double& vif = mu.vi[f];
            double& v_nif = mu.v_ni[f];
            double& v_zif = mu.v_zi[f];
            if(v_nif > 0)
            {
                if(force_v_sparse && 0.0 == mu.wi)
                {
                    vif = 0.0;
                }
                else if(fabs(v_zif) <= v_l1)
                {
                    vif = 0.0;
                }
                else
                {
                    vif = (-1) *
                        (1 / (v_l2 + (v_beta + sqrt(v_nif)) / v_alpha)) *
                        (v_zif - utils::sgn(v_zif) * v_l1);
                }
            }
            mu.mtx.unlock();
        }
    }
    vector<double> sum1(pModel->factor_num);
    double p1 = pModel->predict(sample1.x, theta, sum1);
    vector<double> sum2(pModel->factor_num);
    double p2 = pModel->predict(sample2.x, theta, sum2);
    double lambda12 = -1 / (1 + exp(p1 - p2)) * deltaNDCG;
    //update w_n, w_z
    if(k1)
    {
        for(unordered_map<string, ftrl_model_unit*>::iterator iter = theta.begin(); iter != theta.end(); ++iter)
        {
            ftrl_model_unit& mu = *(iter->second);
            const string& index = iter->first;
            unordered_map<string, double>::iterator iter_x1 = sample1.x.find(index);
            double xi1 = (iter_x1 == sample1.x.end()) ? 0 : iter_x1->second;
            unordered_map<string, double>::iterator iter_x2 = sample2.x.find(index);
            double xi2 = (iter_x2 == sample2.x.end()) ? 0 : iter_x2->second;
            double xi = xi1 - xi2;
            if(xi != 0)
            {
                mu.mtx.lock();
                double w_gi = lambda12 * xi;
                double w_si = 1 / w_alpha * (sqrt(mu.w_ni + w_gi * w_gi) - sqrt(mu.w_ni));
                mu.w_zi += w_gi - w_si * mu.wi;
                mu.w_ni += w_gi * w_gi;
                mu.mtx.unlock();
            }
        }
    }
    //update v_n, v_z
    for(unordered_map<string, ftrl_model_unit*>::iterator iter = theta.begin(); iter != theta.end(); ++iter)
    {
        ftrl_model_unit& mu = *(iter->second);
        const string& index = iter->first;
        unordered_map<string, double>::iterator iter_x1 = sample1.x.find(index);
        double xi1 = (iter_x1 == sample1.x.end()) ? 0 : iter_x1->second;
        unordered_map<string, double>::iterator iter_x2 = sample2.x.find(index);
        double xi2 = (iter_x2 == sample2.x.end()) ? 0 : iter_x2->second;
        for(int f = 0; f < pModel->factor_num; ++f)
        {
            mu.mtx.lock();
            double& vif = mu.vi[f];
            double& v_nif = mu.v_ni[f];
            double& v_zif = mu.v_zi[f];
            double v_gif = lambda12 * ((sum1[f] * xi1 - vif * xi1 * xi1) - (sum2[f] * xi2 - vif * xi2 * xi2));
            double v_sif = 1 / v_alpha * (sqrt(v_nif + v_gif * v_gif) - sqrt(v_nif));
            v_zif += v_gif - v_sif * vif;
            v_nif += v_gif * v_gif;
            //有的特征在整个训练集中只出现一次，这里还需要对vif做一次处理
            if(force_v_sparse && v_nif > 0 && 0.0 == mu.wi)
            {
                vif = 0.0;
            }
            mu.mtx.unlock();
        }
    }
}

// Assembly:
subq $0x3d8, %rsp            # imm = 0x3D8
movq %rdi, 0x3d0(%rsp)
movq %rsi, 0x3c8(%rsp)
movq %rdx, 0x3c0(%rsp)
movsd %xmm0, 0x3b8(%rsp)
movq 0x3d0(%rsp), %rax
movq %rax, 0x148(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x8360
movq 0x3c8(%rsp), %rdi
addq $0x28, %rdi
callq 0x8690
movq %rax, 0x378(%rsp)
movq 0x3c8(%rsp), %rdi
addq $0x28, %rdi
callq 0x86e0
movq %rax, 0x370(%rsp)
leaq 0x378(%rsp), %rdi
leaq 0x370(%rsp), %rsi
callq 0x86c0
testb $0x1, %al
jne 0x5805
jmp 0x595a
leaq 0x378(%rsp), %rdi
callq 0x8710
movq %rax, 0x368(%rsp)
movq 0x368(%rsp), %rsi
leaq 0x380(%rsp), %rdi
callq 0x8380
movq %rax, 0x140(%rsp)
jmp 0x5839
movq 0x140(%rsp), %rax
movq %rax, 0x360(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x83d0
movq %rax, 0x348(%rsp)
leaq 0x360(%rsp), %rdi
leaq 0x348(%rsp), %rsi
callq 0x83b0
testb $0x1, %al
jne 0x587c
jmp 0x5946
movq 0x148(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x138(%rsp)
movq 0x368(%rsp), %rsi
leaq 0x328(%rsp), %rdi
callq 0x3120
jmp 0x58a7
movq 0x138(%rsp), %rdi
leaq 0x328(%rsp), %rsi
callq 0x3960
movq %rax, 0x130(%rsp)
jmp 0x58c6
movq 0x368(%rsp), %rsi
leaq 0x380(%rsp), %rdi
callq 0x8730
movq %rax, 0x128(%rsp)
jmp 0x58e5
movq 0x128(%rsp), %rax
movq 0x130(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x328(%rsp), %rdi
callq 0x3518
jmp 0x5946
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x358(%rsp)
movl %eax, 0x354(%rsp)
jmp 0x69f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x358(%rsp)
movl %eax, 0x354(%rsp)
leaq 0x328(%rsp), %rdi
callq 0x3518
jmp 0x69f8
jmp 0x5948
leaq 0x378(%rsp), %rdi
callq 0x8760
jmp 0x57ce
movq 0x3c0(%rsp), %rdi
addq $0x28, %rdi
callq 0x8690
movq %rax, 0x320(%rsp)
movq 0x3c0(%rsp), %rdi
addq $0x28, %rdi
callq 0x86e0
movq %rax, 0x318(%rsp)
leaq 0x320(%rsp), %rdi
leaq 0x318(%rsp), %rsi
callq 0x86c0
testb $0x1, %al
jne 0x59aa
jmp 0x5ae6
leaq 0x320(%rsp), %rdi
callq 0x8710
movq %rax, 0x310(%rsp)
movq 0x310(%rsp), %rsi
leaq 0x380(%rsp), %rdi
callq 0x8380
movq %rax, 0x120(%rsp)
jmp 0x59de
movq 0x120(%rsp), %rax
movq %rax, 0x308(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x83d0
movq %rax, 0x300(%rsp)
leaq 0x308(%rsp), %rdi
leaq 0x300(%rsp), %rsi
callq 0x83b0
testb $0x1, %al
jne 0x5a21
jmp 0x5ad2
movq 0x148(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x118(%rsp)
movq 0x310(%rsp), %rsi
leaq 0x2e0(%rsp), %rdi
callq 0x3120
jmp 0x5a4c
movq 0x118(%rsp), %rdi
leaq 0x2e0(%rsp), %rsi
callq 0x3960
movq %rax, 0x110(%rsp)
jmp 0x5a6b
movq 0x310(%rsp), %rsi
leaq 0x380(%rsp), %rdi
callq 0x8730
movq %rax, 0x108(%rsp)
jmp 0x5a8a
movq 0x108(%rsp), %rax
movq 0x110(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x2e0(%rsp), %rdi
callq 0x3518
jmp 0x5ad2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x358(%rsp)
movl %eax, 0x354(%rsp)
leaq 0x2e0(%rsp), %rdi
callq 0x3518
jmp 0x69f8
jmp 0x5ad4
leaq 0x320(%rsp), %rdi
callq 0x8760
jmp 0x5973
movq 0x148(%rsp), %rax
testb $0x1, 0x50(%rax)
je 0x5d28
leaq 0x380(%rsp), %rdi
callq 0x87b0
movq %rax, 0x2d8(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x83d0
movq %rax, 0x2d0(%rsp)
leaq 0x2d8(%rsp), %rdi
leaq 0x2d0(%rsp), %rsi
callq 0x87e0
testb $0x1, %al
jne 0x5b40
jmp 0x5d26
leaq 0x2d8(%rsp), %rdi
callq 0x8670
movq 0x20(%rax), %rax
movq %rax, 0x2c8(%rsp)
movq 0x2c8(%rsp), %rdi
addq $0x60, %rdi
callq 0x8400
jmp 0x5b6c
movq 0x148(%rsp), %rax
movq 0x2c8(%rsp), %rcx
movsd 0x10(%rcx), %xmm1
movaps 0x154a8(%rip), %xmm0    # 0x1b030
pand %xmm0, %xmm1
movsd 0x20(%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0x5bab
movq 0x2c8(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0x5cff
movq 0x148(%rsp), %rax
testb $0x1, 0x51(%rax)
je 0x5c09
movq 0x2c8(%rsp), %rax
movsd 0x8(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x5c09
movq 0x2c8(%rsp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jne 0x5c09
jp 0x5c09
movq 0x148(%rsp), %rax
movq 0x2c8(%rsp), %rdi
movq 0x8(%rax), %rax
movsd 0x40(%rax), %xmm1
movsd 0x48(%rax), %xmm0
callq 0x91b0
jmp 0x5c07
jmp 0x5c09
movq 0x148(%rsp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0xe8(%rsp)
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0xe0(%rsp)
movq 0x2c8(%rsp), %rax
movsd 0x8(%rax), %xmm0
callq 0x3220
movq 0x148(%rsp), %rax
movsd 0xe0(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0xe8(%rsp), %xmm0
addsd %xmm2, %xmm0
movsd 0x10(%rax), %xmm2
divsd %xmm2, %xmm0
addsd %xmm0, %xmm1
movsd 0x153ab(%rip), %xmm0    # 0x1b020
divsd %xmm1, %xmm0
movsd %xmm0, 0xf0(%rsp)
movq 0x2c8(%rsp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0xf8(%rsp)
callq 0x1a130
movl %eax, 0x104(%rsp)
jmp 0x5ca6
movsd 0xf0(%rsp), %xmm0
movsd 0xf8(%rsp), %xmm2
movq 0x148(%rsp), %rax
movl 0x104(%rsp), %ecx
cvtsi2sd %ecx, %xmm1
movsd 0x20(%rax), %xmm3
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movq 0x2c8(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x2c8(%rsp), %rdi
addq $0x60, %rdi
callq 0x8660
jmp 0x5d12
jmp 0x5d14
leaq 0x2d8(%rsp), %rdi
callq 0x89d0
jmp 0x5b0d
jmp 0x5d28
leaq 0x380(%rsp), %rdi
callq 0x87b0
movq %rax, 0x2c0(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x83d0
movq %rax, 0x2b8(%rsp)
leaq 0x2c0(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
callq 0x87e0
testb $0x1, %al
jne 0x5d70
jmp 0x5fe9
leaq 0x2c0(%rsp), %rdi
callq 0x8670
movq 0x20(%rax), %rax
movq %rax, 0x2b0(%rsp)
movl $0x0, 0x2ac(%rsp)
movq 0x148(%rsp), %rcx
movl 0x2ac(%rsp), %eax
movq 0x8(%rcx), %rcx
cmpl 0x38(%rcx), %eax
jge 0x5fd5
movq 0x2b0(%rsp), %rdi
addq $0x60, %rdi
callq 0x8400
jmp 0x5dc3
movq 0x2b0(%rsp), %rdi
addq $0x18, %rdi
movslq 0x2ac(%rsp), %rsi
callq 0x8790
movq %rax, 0x2a0(%rsp)
movq 0x2b0(%rsp), %rdi
addq $0x30, %rdi
movslq 0x2ac(%rsp), %rsi
callq 0x8790
movq %rax, 0x298(%rsp)
movq 0x2b0(%rsp), %rdi
addq $0x48, %rdi
movslq 0x2ac(%rsp), %rsi
callq 0x8790
movq %rax, 0x290(%rsp)
movq 0x298(%rsp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x5faa
movq 0x148(%rsp), %rax
testb $0x1, 0x51(%rax)
je 0x5e74
movq 0x2b0(%rsp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jne 0x5e74
jp 0x5e74
movq 0x2a0(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0x5fa8
movq 0x148(%rsp), %rax
movq 0x290(%rsp), %rcx
movsd (%rcx), %xmm1
movaps 0x151a1(%rip), %xmm0    # 0x1b030
pand %xmm0, %xmm1
movsd 0x40(%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0x5eb2
movq 0x2a0(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0x5fa6
movq 0x148(%rsp), %rax
movsd 0x38(%rax), %xmm0
movsd %xmm0, 0xc0(%rsp)
movsd 0x48(%rax), %xmm0
movsd %xmm0, 0xb8(%rsp)
movq 0x298(%rsp), %rax
movsd (%rax), %xmm0
callq 0x3220
movq 0x148(%rsp), %rax
movsd 0xb8(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0xc0(%rsp), %xmm0
addsd %xmm2, %xmm0
movsd 0x30(%rax), %xmm2
divsd %xmm2, %xmm0
addsd %xmm0, %xmm1
movsd 0x15103(%rip), %xmm0    # 0x1b020
divsd %xmm1, %xmm0
movsd %xmm0, 0xc8(%rsp)
movq 0x290(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0xd0(%rsp)
callq 0x1a130
movl %eax, 0xdc(%rsp)
jmp 0x5f4d
movsd 0xc8(%rsp), %xmm0
movsd 0xd0(%rsp), %xmm2
movq 0x148(%rsp), %rax
movl 0xdc(%rsp), %ecx
cvtsi2sd %ecx, %xmm1
movsd 0x40(%rax), %xmm3
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movq 0x2a0(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x5fa8
jmp 0x5faa
movq 0x2b0(%rsp), %rdi
addq $0x60, %rdi
callq 0x8660
jmp 0x5fbd
jmp 0x5fbf
movl 0x2ac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2ac(%rsp)
jmp 0x5d94
jmp 0x5fd7
leaq 0x2c0(%rsp), %rdi
callq 0x89d0
jmp 0x5d3d
movq 0x148(%rsp), %rax
movq 0x8(%rax), %rax
movslq 0x38(%rax), %rax
movq %rax, 0xa8(%rsp)
leaq 0x277(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x9240
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
leaq 0x278(%rsp), %rdi
callq 0x9250
jmp 0x6035
leaq 0x277(%rsp), %rdi
callq 0x92d0
movq 0x148(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x3c8(%rsp), %rsi
addq $0x28, %rsi
leaq 0x380(%rsp), %rdx
leaq 0x278(%rsp), %rcx
callq 0x3ae0
movsd %xmm0, 0xa0(%rsp)
jmp 0x607a
movq 0x148(%rsp), %rax
movsd 0xa0(%rsp), %xmm0
movsd %xmm0, 0x268(%rsp)
movq 0x8(%rax), %rax
movslq 0x38(%rax), %rax
movq %rax, 0x90(%rsp)
leaq 0x24f(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0x9240
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
leaq 0x250(%rsp), %rdi
callq 0x9250
jmp 0x60d8
leaq 0x24f(%rsp), %rdi
callq 0x92d0
movq 0x148(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x3c0(%rsp), %rsi
addq $0x28, %rsi
leaq 0x380(%rsp), %rdx
leaq 0x250(%rsp), %rcx
callq 0x3ae0
movsd %xmm0, 0x88(%rsp)
jmp 0x611d
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x240(%rsp)
movsd 0x268(%rsp), %xmm0
subsd 0x240(%rsp), %xmm0
callq 0x34c0
movq 0x148(%rsp), %rax
movsd 0x14ec2(%rip), %xmm1    # 0x1b018
addsd %xmm0, %xmm1
movsd 0x14ebe(%rip), %xmm0    # 0x1b020
divsd %xmm1, %xmm0
mulsd 0x3b8(%rsp), %xmm0
movsd %xmm0, 0x238(%rsp)
testb $0x1, 0x50(%rax)
je 0x6516
leaq 0x380(%rsp), %rdi
callq 0x87b0
movq %rax, 0x230(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x83d0
movq %rax, 0x228(%rsp)
leaq 0x230(%rsp), %rdi
leaq 0x228(%rsp), %rsi
callq 0x87e0
testb $0x1, %al
jne 0x61ca
jmp 0x6514
leaq 0x230(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x8670
movq 0x78(%rsp), %rdi
movq 0x20(%rax), %rax
movq %rax, 0x220(%rsp)
callq 0x8670
movq %rax, 0x218(%rsp)
movq 0x3c8(%rsp), %rdi
addq $0x28, %rdi
movq 0x218(%rsp), %rsi
callq 0x92e0
movq %rax, 0x80(%rsp)
jmp 0x621d
movq 0x80(%rsp), %rax
movq %rax, 0x210(%rsp)
movq 0x3c8(%rsp), %rdi
addq $0x28, %rdi
callq 0x86e0
movq %rax, 0x200(%rsp)
leaq 0x210(%rsp), %rdi
leaq 0x200(%rsp), %rsi
callq 0x9310
testb $0x1, %al
jne 0x6261
jmp 0x626c
xorps %xmm0, %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0x6284
leaq 0x210(%rsp), %rdi
callq 0x8710
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x208(%rsp)
movq 0x3c0(%rsp), %rdi
addq $0x28, %rdi
movq 0x218(%rsp), %rsi
callq 0x92e0
movq %rax, 0x68(%rsp)
jmp 0x62b3
movq 0x68(%rsp), %rax
movq %rax, 0x1f8(%rsp)
movq 0x3c0(%rsp), %rdi
addq $0x28, %rdi
callq 0x86e0
movq %rax, 0x1e8(%rsp)
leaq 0x1f8(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x9310
testb $0x1, %al
jne 0x62f4
jmp 0x62ff
xorps %xmm0, %xmm0
movsd %xmm0, 0x60(%rsp)
jmp 0x6317
leaq 0x1f8(%rsp), %rdi
callq 0x8710
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x1f0(%rsp)
movsd 0x208(%rsp), %xmm0
subsd 0x1f0(%rsp), %xmm0
movsd %xmm0, 0x1e0(%rsp)
movsd 0x1e0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x635a
jp 0x635a
jmp 0x6500
movq 0x220(%rsp), %rdi
addq $0x60, %rdi
callq 0x8400
jmp 0x636d
movq 0x148(%rsp), %rax
movsd 0x238(%rsp), %xmm0
movsd 0x1e0(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x1d8(%rsp)
movsd 0x10(%rax), %xmm1
movsd 0x14c77(%rip), %xmm0    # 0x1b018
divsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x220(%rsp), %rax
movsd 0x8(%rax), %xmm1
movsd 0x1d8(%rsp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
callq 0x3220
movsd %xmm0, 0x50(%rsp)
movq 0x220(%rsp), %rax
movsd 0x8(%rax), %xmm0
callq 0x3220
movsd 0x50(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x58(%rsp), %xmm0
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x1d0(%rsp)
movsd 0x1d8(%rsp), %xmm1
movsd 0x1d0(%rsp), %xmm2
movq 0x220(%rsp), %rax
movsd (%rax), %xmm3
movsd 0x10(%rax), %xmm0
mulsd %xmm3, %xmm2
subsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rax)
movsd 0x1d8(%rsp), %xmm0
movq 0x220(%rsp), %rax
movsd 0x8(%rax), %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rax)
movq 0x220(%rsp), %rdi
addq $0x60, %rdi
callq 0x8660
jmp 0x6470
jmp 0x6500
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x358(%rsp)
movl %eax, 0x354(%rsp)
leaq 0x277(%rsp), %rdi
callq 0x92d0
jmp 0x69f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x358(%rsp)
movl %eax, 0x354(%rsp)
jmp 0x69eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x358(%rsp)
movl %eax, 0x354(%rsp)
leaq 0x24f(%rsp), %rdi
callq 0x92d0
jmp 0x69eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x358(%rsp)
movl %eax, 0x354(%rsp)
leaq 0x250(%rsp), %rdi
callq 0x8ec0
jmp 0x69eb
jmp 0x6502
leaq 0x230(%rsp), %rdi
callq 0x89d0
jmp 0x6197
jmp 0x6516
leaq 0x380(%rsp), %rdi
callq 0x87b0
movq %rax, 0x1c8(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x83d0
movq %rax, 0x1c0(%rsp)
leaq 0x1c8(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x87e0
testb $0x1, %al
jne 0x655e
jmp 0x69bc
leaq 0x1c8(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x8670
movq 0x40(%rsp), %rdi
movq 0x20(%rax), %rax
movq %rax, 0x1b8(%rsp)
callq 0x8670
movq %rax, 0x1b0(%rsp)
movq 0x3c8(%rsp), %rdi
addq $0x28, %rdi
movq 0x1b0(%rsp), %rsi
callq 0x92e0
movq %rax, 0x48(%rsp)
jmp 0x65ae
movq 0x48(%rsp), %rax
movq %rax, 0x1a8(%rsp)
movq 0x3c8(%rsp), %rdi
addq $0x28, %rdi
callq 0x86e0
movq %rax, 0x198(%rsp)
leaq 0x1a8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x9310
testb $0x1, %al
jne 0x65ef
jmp 0x65fa
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0x6612
leaq 0x1a8(%rsp), %rdi
callq 0x8710
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x1a0(%rsp)
movq 0x3c0(%rsp), %rdi
addq $0x28, %rdi
movq 0x1b0(%rsp), %rsi
callq 0x92e0
movq %rax, 0x30(%rsp)
jmp 0x6641
movq 0x30(%rsp), %rax
movq %rax, 0x190(%rsp)
movq 0x3c0(%rsp), %rdi
addq $0x28, %rdi
callq 0x86e0
movq %rax, 0x180(%rsp)
leaq 0x190(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x9310
testb $0x1, %al
jne 0x6682
jmp 0x668d
xorps %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
jmp 0x66a5
leaq 0x190(%rsp), %rdi
callq 0x8710
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x188(%rsp)
movl $0x0, 0x17c(%rsp)
movq 0x148(%rsp), %rcx
movl 0x17c(%rsp), %eax
movq 0x8(%rcx), %rcx
cmpl 0x38(%rcx), %eax
jge 0x69a8
movq 0x1b8(%rsp), %rdi
addq $0x60, %rdi
callq 0x8400
jmp 0x66ee
movq 0x1b8(%rsp), %rdi
addq $0x18, %rdi
movslq 0x17c(%rsp), %rsi
callq 0x8790
movq %rax, 0x170(%rsp)
movq 0x1b8(%rsp), %rdi
addq $0x30, %rdi
movslq 0x17c(%rsp), %rsi
callq 0x8790
movq %rax, 0x168(%rsp)
movq 0x1b8(%rsp), %rdi
addq $0x48, %rdi
movslq 0x17c(%rsp), %rsi
callq 0x8790
movq %rax, 0x160(%rsp)
movsd 0x238(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movslq 0x17c(%rsp), %rsi
leaq 0x278(%rsp), %rdi
callq 0x8790
movsd (%rax), %xmm0
movsd 0x1a0(%rsp), %xmm2
movq 0x170(%rsp), %rax
movsd (%rax), %xmm1
mulsd 0x1a0(%rsp), %xmm1
mulsd 0x1a0(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movslq 0x17c(%rsp), %rsi
leaq 0x250(%rsp), %rdi
callq 0x8790
movsd 0x8(%rsp), %xmm1
movsd 0x10(%rsp), %xmm0
movq %rax, %rcx
movq 0x148(%rsp), %rax
movsd (%rcx), %xmm2
movsd 0x188(%rsp), %xmm4
movq 0x170(%rsp), %rcx
movsd (%rcx), %xmm3
mulsd 0x188(%rsp), %xmm3
mulsd 0x188(%rsp), %xmm3
movq %xmm3, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm3
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x158(%rsp)
movsd 0x147c4(%rip), %xmm0    # 0x1b018
divsd 0x30(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x168(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x158(%rsp), %xmm0
movsd 0x158(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x3220
movsd %xmm0, 0x18(%rsp)
movq 0x168(%rsp), %rax
movsd (%rax), %xmm0
callq 0x3220
movsd 0x18(%rsp), %xmm1
movq 0x148(%rsp), %rax
movaps %xmm0, %xmm2
movsd 0x20(%rsp), %xmm0
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x150(%rsp)
movsd 0x158(%rsp), %xmm1
movsd 0x150(%rsp), %xmm0
movq 0x170(%rsp), %rcx
movsd (%rcx), %xmm2
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x160(%rsp), %rcx
addsd (%rcx), %xmm0
movsd %xmm0, (%rcx)
movsd 0x158(%rsp), %xmm0
movsd 0x158(%rsp), %xmm2
movq 0x168(%rsp), %rcx
movsd (%rcx), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx)
testb $0x1, 0x51(%rax)
je 0x697d
movq 0x168(%rsp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x697d
movq 0x1b8(%rsp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jne 0x697d
jp 0x697d
movq 0x170(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq 0x1b8(%rsp), %rdi
addq $0x60, %rdi
callq 0x8660
jmp 0x6990
jmp 0x6992
movl 0x17c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x17c(%rsp)
jmp 0x66bf
jmp 0x69aa
leaq 0x1c8(%rsp), %rdi
callq 0x89d0
jmp 0x652b
leaq 0x250(%rsp), %rdi
callq 0x8ec0
leaq 0x278(%rsp), %rdi
callq 0x8ec0
leaq 0x380(%rsp), %rdi
callq 0x9330
addq $0x3d8, %rsp            # imm = 0x3D8
retq
leaq 0x278(%rsp), %rdi
callq 0x8ec0
leaq 0x380(%rsp), %rdi
callq 0x9330
movq 0x358(%rsp), %rdi
callq 0x3490
nopw %cs:(%rax,%rax)