// File: /workspace/github_cpp_makefile_star2_O2/CastellanZhang[P]lambdaFM/./src/FTRL/ftrl_trainer.h
// Function: ftrl_trainer::trainGroupFastMode(std::vector<fm_sample, std::allocator<fm_sample>>&)
void ftrl_trainer::trainGroupFastMode(vector<fm_sample>& sampleGrp)
{
    int size = sampleGrp.size();
    variable_NDCG v_NDCG;
    if("ndcg" == rank)
    {
        v_NDCG.init(size);
        calcVariables4NDCG(sampleGrp, v_NDCG);
    }
    int factor_num = pModel->factor_num;
    vector<double> vecPred(size);
    vector<map<string, vector<double> > > vecGradPred2v(size);
    unordered_map<string, ftrl_model_unit*> theta;
    for(int i = 0; i < size; ++i)
    {
        for(unordered_map<string, double>::iterator iter = sampleGrp[i].x.begin(); iter != sampleGrp[i].x.end(); ++iter)
        {
            const string& index = iter->first;
            if(theta.find(index) == theta.end())
            {
                theta[index] = pModel->getOrInitModelUnit(index);
            }
        }
        vector<double> sum(factor_num);
        vecPred[i] = pModel->predict(sampleGrp[i].x, theta, sum);
        for(unordered_map<string, double>::iterator iter = sampleGrp[i].x.begin(); iter != sampleGrp[i].x.end(); ++iter)
        {
            const string& index = iter->first;
            const double& xi = iter->second;
            vector<double>& vi = theta[index]->vi;
            vecGradPred2v[i][index] = vector<double>(factor_num);
            for(int f = 0; f < factor_num; ++f)
            {
                vecGradPred2v[i][index][f] = sum[f] * xi - vi[f] * xi * xi;
            }
        }
    }
    for(int i = 0; i < size - 1; ++i)
    {
        for(int j = i + 1; j < size; ++j)
        {
            if(sampleGrp[i].y == sampleGrp[j].y)
            {
                continue;
            }
            double deltaNDCG = 1.0;
            if("ndcg" == rank)
            {
                deltaNDCG = calcDeltaNDCG(i, j, v_NDCG);
            }
            if(sampleGrp[i].y > sampleGrp[j].y)
            {
                trainPairFastMode(sampleGrp[i], sampleGrp[j], vecPred[i], vecPred[j], vecGradPred2v[i], vecGradPred2v[j], deltaNDCG);
            }
            else if(sampleGrp[i].y < sampleGrp[j].y)
            {
                trainPairFastMode(sampleGrp[j], sampleGrp[i], vecPred[j], vecPred[i], vecGradPred2v[j], vecGradPred2v[i], deltaNDCG);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rsi), %rax
subq (%rsi), %rax
pushq $0x60
popq %rcx
cqto
movq %rcx, 0x50(%rsp)
idivq %rcx
movq %rax, %r15
xorpd %xmm0, %xmm0
movapd %xmm0, 0x130(%rsp)
movapd %xmm0, 0x120(%rsp)
andq $0x0, 0x140(%rsp)
movapd %xmm0, 0x110(%rsp)
movapd %xmm0, 0x100(%rsp)
leaq 0x58(%rdi), %rsi
leaq 0x7258(%rip), %rdi      # 0xb072
movq %rsi, 0x78(%rsp)
callq 0x5d9f
testb %al, %al
je 0x3e4b
leaq 0x100(%rsp), %rdi
movl %r15d, %esi
callq 0x5db6
leaq 0x100(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x447a
movq %r14, 0x28(%rsp)
movq 0x8(%r14), %rax
movslq 0x38(%rax), %rax
movq %rax, 0x10(%rsp)
movq %r15, 0x38(%rsp)
movslq %r15d, %r14
leaq 0x80(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
movq %r14, %rsi
callq 0x5ef4
movq %rbx, 0x30(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
movq %r14, %rsi
callq 0x5f46
leaq 0xe0(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movupd %xmm0, -0x8(%rax)
xorl %ecx, %ecx
movq 0x10(%rsp), %rax
testl %eax, %eax
movl $0x0, %ebx
cmovgl %eax, %ebx
movq 0x38(%rsp), %rax
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
movq %rdx, 0x70(%rsp)
leaq 0xe8(%rsp), %rbp
cmpq 0x70(%rsp), %rcx
je 0x40e2
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rcx, 0x20(%rsp)
imulq $0x60, %rcx, %rcx
movq %rcx, 0x18(%rsp)
leaq (%rax,%rcx), %r12
addq $0x38, %r12
movq (%r12), %r12
testq %r12, %r12
je 0x3f85
leaq 0x8(%r12), %r14
leaq 0xb0(%rsp), %rdi
movq %r14, %rsi
callq 0x74a4
testq %rax, %rax
jne 0x3f16
movq 0x28(%rsp), %rax
movq 0x8(%rax), %r15
leaq 0x158(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x3320
movq %r15, %rdi
movq %r13, %rsi
callq 0x3706
movq %rax, %r15
leaq 0xb0(%rsp), %rdi
movq %r14, %rsi
callq 0x78c2
movq %r15, (%rax)
leaq 0x158(%rsp), %rdi
callq 0x3468
jmp 0x3f16
leaq 0x98(%rsp), %r15
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq %rbp, %rdx
callq 0x5ef4
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x30(%rsp), %r14
movq (%r14), %rax
movq 0x18(%rsp), %r12
leaq 0x28(%rax,%r12), %rsi
leaq 0xb0(%rsp), %rdx
movq %r15, %rcx
callq 0x37be
movq 0x80(%rsp), %rax
movq 0x20(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq (%r14), %rax
leaq (%rax,%r12), %r15
addq $0x38, %r15
imulq $0x30, %rcx, %r13
movq (%r15), %r15
testq %r15, %r15
je 0x40c3
leaq 0x8(%r15), %r14
leaq 0xb0(%rsp), %rdi
movq %r14, %rsi
callq 0x78c2
movq (%rax), %r12
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
leaq 0xf(%rsp), %rdx
callq 0x5ef4
movq 0x58(%rsp), %rdi
addq %r13, %rdi
movq %r14, %rsi
callq 0x5f98
movq %rax, %rdi
movq %rbp, %rsi
callq 0x80c6
movq %rbp, %rdi
callq 0x7496
xorl %ebp, %ebp
cmpq %rbp, %rbx
je 0x40b6
movq 0x98(%rsp), %rax
movsd (%rax,%rbp,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x28(%r15), %xmm0
movsd %xmm0, 0x48(%rsp)
movq 0x18(%r12), %rax
movsd (%rax,%rbp,8), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x58(%rsp), %rdi
addq %r13, %rdi
movq %r14, %rsi
callq 0x5f98
movsd 0x48(%rsp), %xmm1
movsd 0x40(%rsp), %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
movsd 0x18(%rsp), %xmm0
mulsd %xmm1, %xmm0
subsd %xmm2, %xmm0
movq (%rax), %rax
movsd %xmm0, (%rax,%rbp,8)
incq %rbp
jmp 0x4043
leaq 0xe8(%rsp), %rbp
jmp 0x3fe9
leaq 0x98(%rsp), %rdi
callq 0x7496
movq 0x20(%rsp), %rcx
incq %rcx
movq 0x38(%rsp), %rax
jmp 0x3eed
cmpl $0x2, %eax
pushq $0x1
popq %rbp
movl %ebp, %ecx
cmovgel %eax, %ecx
decl %ecx
movq %rcx, 0x20(%rsp)
pushq $0x30
popq %r14
pushq $0x8
popq %rbx
xorl %r12d, %r12d
cmpq 0x20(%rsp), %r12
je 0x422e
leaq 0x1(%r12), %rcx
movq %rcx, 0x10(%rsp)
imulq $0x60, %r12, %r13
movl %ebp, 0x18(%rsp)
movq %rbx, 0x40(%rsp)
movq 0x50(%rsp), %r15
movq %r14, 0x48(%rsp)
cmpl %eax, %ebp
jge 0x4206
movq 0x30(%rsp), %rax
movq (%rax), %rax
movl (%rax,%r13), %ecx
cmpl (%rax,%r14,2), %ecx
je 0x41ee
leaq 0x6f23(%rip), %rdi      # 0xb072
movq 0x78(%rsp), %rsi
callq 0x5d9f
movsd 0x6eaf(%rip), %xmm0     # 0xb010
testb %al, %al
je 0x417c
movq 0x28(%rsp), %rdi
movl %r12d, %esi
movl %ebp, %edx
leaq 0x100(%rsp), %rcx
callq 0x5dea
movq 0x30(%rsp), %rax
movq (%rax), %rax
leaq (%rax,%r13), %rdi
leaq (%rax,%r15), %rdx
movl (%rax,%r14,2), %ecx
cmpl %ecx, (%rax,%r13)
jle 0x41b9
movq 0x80(%rsp), %r8
leaq (%r8,%r12,8), %rcx
addq %rbx, %r8
movq 0x58(%rsp), %rax
imulq $0x30, %r12, %r9
addq %rax, %r9
addq %r14, %rax
movq %rdi, %rsi
jmp 0x41e0
jge 0x41ee
movq 0x80(%rsp), %rcx
leaq (%rcx,%r12,8), %r8
addq %rbx, %rcx
movq 0x58(%rsp), %rsi
leaq (%rsi,%r14), %r9
imulq $0x30, %r12, %rax
addq %rsi, %rax
movq %rdx, %rsi
movq %rdi, %rdx
movq %rax, (%rsp)
movq 0x28(%rsp), %rdi
callq 0x4dce
addq $0x30, %r14
addq $0x60, %r15
addq $0x8, %rbx
incl %ebp
movq 0x38(%rsp), %rax
jmp 0x412a
movq 0x48(%rsp), %r14
addq $0x30, %r14
addq $0x60, 0x50(%rsp)
movq 0x40(%rsp), %rbx
addq $0x8, %rbx
movl 0x18(%rsp), %ebp
incl %ebp
movq 0x10(%rsp), %r12
jmp 0x40fe
leaq 0xb0(%rsp), %rdi
callq 0x6d16
leaq 0x58(%rsp), %rdi
callq 0x5ffe
leaq 0x80(%rsp), %rdi
callq 0x7496
leaq 0x100(%rsp), %rdi
callq 0x5e78
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x42d9
jmp 0x4278
movq %rax, %rbx
jmp 0x42e6
jmp 0x42ad
jmp 0x42b2
jmp 0x42ad
jmp 0x42ad
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0x3468
jmp 0x42c2
jmp 0x42b2
jmp 0x42b2
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x7496
jmp 0x42b5
movq %rax, %rbx
jmp 0x42c2
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x7496
leaq 0xb0(%rsp), %rdi
callq 0x6d16
leaq 0x58(%rsp), %rdi
callq 0x5ffe
leaq 0x80(%rsp), %rdi
callq 0x7496
leaq 0x100(%rsp), %rdi
callq 0x5e78
movq %rbx, %rdi
callq 0x3410
nop