// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1b8, %rsp            # imm = 0x1B8
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rsi), %rax
subq (%rsi), %rax
sarq $0x5, %rax
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r15
xorpd %xmm0, %xmm0
movapd %xmm0, 0x140(%rsp)
movapd %xmm0, 0x130(%rsp)
movapd %xmm0, 0x120(%rsp)
movapd %xmm0, 0x110(%rsp)
movq $0x0, 0x150(%rsp)
addq $0x58, %rdi
leaq 0x7f9b(%rip), %rsi      # 0xc092
movq %rdi, 0xd0(%rsp)
callq 0x30c0
testl %eax, %eax
jne 0x412b
leaq 0x110(%rsp), %rdi
movl %r15d, %esi
callq 0x6a1e
leaq 0x110(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4aa0
movq 0x8(%r14), %rax
movslq 0x38(%rax), %r13
movslq %r15d, %r12
leaq 0xd8(%rsp), %rdi
leaq 0x180(%rsp), %rdx
movq %r12, %rsi
callq 0x6ae0
movq %rbx, 0x38(%rsp)
leaq 0x98(%rsp), %rdi
leaq 0x180(%rsp), %rdx
movq %r12, %rsi
callq 0x6b6a
leaq 0x1b0(%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)
movq %r15, 0x28(%rsp)
testl %r15d, %r15d
movq %r14, 0x20(%rsp)
jle 0x4437
movq 0x28(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x40(%rsp)
movl %r13d, %r15d
xorl %ecx, %ecx
movq %r13, 0x48(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rcx, 0x30(%rsp)
leaq (%rcx,%rcx,2), %rcx
movq %rcx, 0x50(%rsp)
shlq $0x5, %rcx
movq %rcx, 0x18(%rsp)
movq 0x38(%rax,%rcx), %rbx
testq %rbx, %rbx
je 0x427d
leaq 0x8(%rbx), %rbp
leaq 0x180(%rsp), %rdi
movq %rbp, %rsi
callq 0x853c
testq %rax, %rax
jne 0x4275
movq 0x8(%r14), %r14
leaq 0x100(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
leaq 0xf0(%rsp), %r12
movq %r12, %rdi
callq 0x8304
movq %r14, %rdi
movq %r12, %rsi
callq 0x387e
movq %rax, %r14
leaq 0x180(%rsp), %rdi
movq %rbp, %rsi
callq 0x8968
movq %r14, (%rax)
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
movq 0x20(%rsp), %r14
je 0x4275
callq 0x32a0
movq (%rbx), %rbx
jmp 0x41e4
leaq 0x168(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
leaq 0x60(%rsp), %rdx
callq 0x6ae0
movq 0x8(%r14), %rdi
movq 0x38(%rsp), %rbx
movq (%rbx), %rax
movq 0x18(%rsp), %r14
leaq (%rax,%r14), %rsi
addq $0x28, %rsi
leaq 0x180(%rsp), %rdx
movq %r12, %rcx
callq 0x395a
movq 0xd8(%rsp), %rax
movq 0x30(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq (%rbx), %rax
movq 0x38(%rax,%r14), %r14
testq %r14, %r14
je 0x440d
leaq 0x8(%r14), %rbp
leaq 0x180(%rsp), %rdi
movq %rbp, %rsi
callq 0x8968
movq (%rax), %rbx
leaq 0x60(%rsp), %rdi
movq %r13, %rsi
leaq 0x17(%rsp), %rdx
callq 0x6ae0
movq 0x50(%rsp), %r12
shlq $0x4, %r12
movq 0x98(%rsp), %rdi
addq %r12, %rdi
movq %rbp, %rsi
callq 0x6c06
movq (%rax), %rdi
movapd 0x60(%rsp), %xmm0
movupd 0x8(%rax), %xmm1
movupd %xmm0, (%rax)
movq 0x70(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %rdi, 0x60(%rsp)
movupd %xmm1, 0x68(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
testq %rdi, %rdi
je 0x4369
callq 0x32a0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x4378
callq 0x32a0
testl %r13d, %r13d
jle 0x43fc
xorl %r13d, %r13d
movq 0x168(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x28(%r14), %xmm0
movsd %xmm0, 0x80(%rsp)
movq 0x18(%rbx), %rax
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x98(%rsp), %rdi
addq %r12, %rdi
movq %rbp, %rsi
callq 0x6c06
movsd 0x80(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
movsd 0x18(%rsp), %xmm0
mulsd %xmm1, %xmm0
subsd %xmm2, %xmm0
movq (%rax), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
cmpq %r13, %r15
jne 0x4380
movq (%r14), %r14
testq %r14, %r14
movq 0x48(%rsp), %r13
jne 0x42e1
movq 0x168(%rsp), %rdi
testq %rdi, %rdi
je 0x441f
callq 0x32a0
movq 0x30(%rsp), %rcx
incq %rcx
cmpq 0x40(%rsp), %rcx
movq 0x20(%rsp), %r14
jne 0x41c0
cmpl $0x2, 0x28(%rsp)
jl 0x46b0
movq 0x28(%rsp), %rax
leal -0x1(%rax), %ecx
movq %rcx, 0xb0(%rsp)
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x28(%rsp)
movl $0x1, %r15d
movl $0x30, %r12d
movl $0x60, %r13d
movl $0x8, %ebp
xorl %ebx, %ebx
leal 0x2(%rbx), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x48(%rsp)
leaq 0x1(%rbx), %rax
movq %rax, 0xb8(%rsp)
leaq (%rbx,%rbx,2), %r14
movq %r14, 0x18(%rsp)
shlq $0x5, %r14
movq %rbp, 0xc0(%rsp)
movq %r13, 0xc8(%rsp)
movq %r12, 0x40(%rsp)
movq %r15, 0x30(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rax
movl (%rax,%r14), %ecx
cmpl (%rax,%r12,2), %ecx
je 0x4657
movq 0xd0(%rsp), %rdi
leaq 0x7bb4(%rip), %rsi      # 0xc092
callq 0x30c0
movsd 0x7b25(%rip), %xmm0     # 0xc010
testl %eax, %eax
jne 0x45d5
movq 0x110(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
cmpq $0x1387, %rbx           # imm = 0x1387
movapd %xmm0, 0x80(%rsp)
ja 0x4526
movq 0x20(%rsp), %rax
movq 0x80(%rax), %rax
movsd (%rax,%rbx,8), %xmm2
jmp 0x453d
movsd 0x48(%rsp), %xmm0
callq 0x3480
movsd 0x7ad7(%rip), %xmm2     # 0xc010
divsd %xmm0, %xmm2
movq 0x110(%rsp), %rax
movsd (%rax,%rbx,8), %xmm3
cmpq $0x1387, %r15           # imm = 0x1387
ja 0x4567
movq 0x20(%rsp), %rax
movq 0x80(%rax), %rax
movsd (%rax,%r15,8), %xmm1
jmp 0x459c
leal 0x2(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm2, 0x58(%rsp)
movsd %xmm3, 0x50(%rsp)
callq 0x3480
movsd 0x50(%rsp), %xmm3
movsd 0x58(%rsp), %xmm2
movsd 0x7a78(%rip), %xmm1     # 0xc010
divsd %xmm0, %xmm1
movapd 0x80(%rsp), %xmm0
mulsd %xmm1, %xmm3
mulsd %xmm2, %xmm0
addsd %xmm3, %xmm0
movq 0x128(%rsp), %rax
subsd (%rax,%rbx,8), %xmm0
subsd (%rax,%r15,8), %xmm0
divsd 0x160(%rsp), %xmm0
andpd 0x7a5b(%rip), %xmm0     # 0xc030
movq 0x38(%rsp), %rax
movq (%rax), %rax
leaq (%rax,%r14), %rdi
leaq (%rax,%r13), %rdx
movl (%rax,%r12,2), %ecx
cmpl %ecx, (%rax,%r14)
jle 0x461a
movq 0xd8(%rsp), %r8
leaq (%r8,%rbx,8), %rcx
addq %rbp, %r8
movq 0x98(%rsp), %rax
movq 0x18(%rsp), %r9
shlq $0x4, %r9
addq %rax, %r9
addq %r12, %rax
movq %rdi, %rsi
jmp 0x4649
jge 0x4657
movq 0xd8(%rsp), %rcx
leaq (%rcx,%rbx,8), %r8
addq %rbp, %rcx
movq 0x98(%rsp), %rsi
leaq (%rsi,%r12), %r9
movq 0x18(%rsp), %rax
shlq $0x4, %rax
addq %rsi, %rax
movq %rdx, %rsi
movq %rdi, %rdx
movq %rax, (%rsp)
movq 0x20(%rsp), %rdi
callq 0x55a4
incq %r15
addq $0x30, %r12
addq $0x60, %r13
addq $0x8, %rbp
cmpq %r15, 0x28(%rsp)
jne 0x44b9
movq 0x30(%rsp), %r15
incq %r15
movq 0x40(%rsp), %r12
addq $0x30, %r12
movq 0xc8(%rsp), %r13
addq $0x60, %r13
movq 0xc0(%rsp), %rbp
addq $0x8, %rbp
movq 0xb8(%rsp), %rbx
cmpq 0xb0(%rsp), %rbx
jne 0x4475
leaq 0x180(%rsp), %rdi
callq 0x7e72
leaq 0x98(%rsp), %rdi
callq 0x6c98
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x46dc
callq 0x32a0
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x46ee
callq 0x32a0
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x4700
callq 0x32a0
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x4712
callq 0x32a0
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x472b
movq %rax, %rbx
jmp 0x47a1
movq %rax, %rbx
jmp 0x47b3
jmp 0x476d
jmp 0x4772
jmp 0x476d
jmp 0x476d
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
jne 0x4782
jmp 0x4787
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x4775
callq 0x32a0
jmp 0x4775
jmp 0x4772
jmp 0x4772
movq %rax, %rbx
jmp 0x4787
movq %rax, %rbx
movq 0x168(%rsp), %rdi
testq %rdi, %rdi
je 0x4787
callq 0x32a0
leaq 0x180(%rsp), %rdi
callq 0x7e72
leaq 0x98(%rsp), %rdi
callq 0x6c98
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x47b3
callq 0x32a0
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x47c5
callq 0x32a0
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x47d7
callq 0x32a0
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x47e9
callq 0x32a0
movq %rbx, %rdi
callq 0x3470
nop