// File: /workspace/github_cpp_makefile_star2_O3/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, %r15
movq 0x8(%rsi), %rax
subq (%rsi), %rax
sarq $0x5, %rax
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r14
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 %r14d, %esi
callq 0x6a32
leaq 0x110(%rsp), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4a98
movq 0x8(%r15), %rax
movslq 0x38(%rax), %rax
movq %rax, 0x18(%rsp)
movq %r14, 0x30(%rsp)
movslq %r14d, %r14
leaq 0xd8(%rsp), %rdi
leaq 0x180(%rsp), %rdx
movq %r14, %rsi
callq 0x6af4
movq %r15, 0x28(%rsp)
movq %rbx, 0x40(%rsp)
leaq 0x98(%rsp), %rdi
leaq 0x180(%rsp), %rdx
movq %r14, %rsi
callq 0x6b82
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 0x30(%rsp), %rax
testl %eax, %eax
jle 0x46a8
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x58(%rsp)
movl 0x18(%rsp), %r15d
xorl %ecx, %ecx
leaq 0x180(%rsp), %rbp
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq %rcx, 0x38(%rsp)
leaq (%rcx,%rcx,2), %rcx
movq %rcx, 0x48(%rsp)
movq %rcx, %r12
shlq $0x5, %r12
movq 0x38(%rax,%r12), %rbx
testq %rbx, %rbx
movq %r12, 0x20(%rsp)
je 0x4288
leaq 0x8(%rbx), %r14
movq %rbp, %rdi
movq %r14, %rsi
callq 0x8608
testq %rax, %rax
jne 0x427c
movq 0x28(%rsp), %rax
movq 0x8(%rax), %r12
leaq 0x100(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
leaq 0xf0(%rsp), %r13
movq %r13, %rdi
callq 0x83c4
movq %r12, %rdi
movq %r13, %rsi
callq 0x387e
movq %rax, %r12
movq %rbp, %rdi
movq %r14, %rsi
callq 0x8a30
movq %r12, (%rax)
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
movq 0x20(%rsp), %r12
je 0x427c
callq 0x32a0
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x41f9
leaq 0x168(%rsp), %r14
movq %r14, %rdi
movq 0x18(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x6af4
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x40(%rsp), %rbx
movq (%rbx), %rax
leaq (%rax,%r12), %rsi
addq $0x28, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x395a
movq 0xd8(%rsp), %rax
movq 0x38(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq (%rbx), %rax
movq 0x38(%rax,%r12), %r12
testq %r12, %r12
je 0x440e
leaq 0x8(%r12), %r14
movq %rbp, %rdi
movq %r14, %rsi
callq 0x8a30
movq (%rax), %rbx
leaq 0x60(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0x17(%rsp), %rdx
callq 0x6af4
movq 0x48(%rsp), %rbp
shlq $0x4, %rbp
movq 0x98(%rsp), %rdi
addq %rbp, %rdi
movq %r14, %rsi
callq 0x6c1a
movq (%rax), %rdi
movapd 0x60(%rsp), %xmm0
movupd %xmm0, (%rax)
movq 0x70(%rsp), %rcx
movq %rcx, 0x10(%rax)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
testq %rdi, %rdi
je 0x436e
callq 0x32a0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x436e
callq 0x32a0
cmpl $0x0, 0x18(%rsp)
jle 0x43f9
xorl %r13d, %r13d
movq 0x168(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x28(%r12), %xmm0
movsd %xmm0, 0x80(%rsp)
movq 0x18(%rbx), %rax
movsd (%rax,%r13,8), %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x98(%rsp), %rdi
addq %rbp, %rdi
movq %r14, %rsi
callq 0x6c1a
movsd 0x80(%rsp), %xmm1
movsd 0x50(%rsp), %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
movsd 0x20(%rsp), %xmm0
mulsd %xmm1, %xmm0
subsd %xmm2, %xmm0
movq (%rax), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
cmpq %r13, %r15
jne 0x437c
movq (%r12), %r12
testq %r12, %r12
leaq 0x180(%rsp), %rbp
jne 0x42e9
movq 0x168(%rsp), %rdi
testq %rdi, %rdi
je 0x4420
callq 0x32a0
movq 0x38(%rsp), %rcx
incq %rcx
cmpq 0x58(%rsp), %rcx
jne 0x41c9
movq 0x30(%rsp), %rax
cmpl $0x1, %eax
je 0x46a8
decl %eax
movl $0x1, %r14d
movl $0x30, %r15d
movl $0x60, %r12d
movl $0x8, %r13d
xorl %ebp, %ebp
movq %rax, 0x30(%rsp)
leal 0x2(%rbp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x48(%rsp)
leaq 0x1(%rbp), %rax
movq %rax, 0xb0(%rsp)
leaq (,%rbp,2), %rbx
addq %rbp, %rbx
movq %rbx, 0x20(%rsp)
shlq $0x5, %rbx
movq %r13, 0xb8(%rsp)
movq %r12, 0xc0(%rsp)
movq %r15, 0xc8(%rsp)
movq %r14, 0x38(%rsp)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movl (%rax,%rbx), %ecx
cmpl (%rax,%r15,2), %ecx
je 0x464c
movq 0xd0(%rsp), %rdi
leaq 0x7bbe(%rip), %rsi      # 0xc092
callq 0x30c0
movsd 0x7b2f(%rip), %xmm0     # 0xc010
testl %eax, %eax
jne 0x45cb
movq 0x110(%rsp), %rax
movsd (%rax,%r14,8), %xmm0
cmpq $0x1387, %rbp           # imm = 0x1387
movapd %xmm0, 0x80(%rsp)
ja 0x451c
movq 0x28(%rsp), %rcx
movq 0x80(%rcx), %rcx
movsd (%rcx,%rbp,8), %xmm2
jmp 0x453b
movsd 0x48(%rsp), %xmm0
callq 0x3480
movsd 0x7ae1(%rip), %xmm2     # 0xc010
divsd %xmm0, %xmm2
movq 0x110(%rsp), %rax
movsd (%rax,%rbp,8), %xmm3
cmpq $0x1387, %r14           # imm = 0x1387
ja 0x455d
movq 0x28(%rsp), %rax
movq 0x80(%rax), %rax
movsd (%rax,%r14,8), %xmm1
jmp 0x4592
leal 0x2(%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm2, 0x50(%rsp)
movsd %xmm3, 0x18(%rsp)
callq 0x3480
movsd 0x18(%rsp), %xmm3
movsd 0x50(%rsp), %xmm2
movsd 0x7a82(%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,%rbp,8), %xmm0
subsd (%rax,%r14,8), %xmm0
divsd 0x160(%rsp), %xmm0
andpd 0x7a65(%rip), %xmm0     # 0xc030
movq 0x40(%rsp), %rax
movq (%rax), %rax
leaq (%rax,%rbx), %rdi
leaq (%rax,%r12), %rdx
movl (%rax,%r15,2), %ecx
cmpl %ecx, (%rax,%rbx)
jle 0x460f
movq 0xd8(%rsp), %r8
leaq (%r8,%rbp,8), %rcx
addq %r13, %r8
movq 0x98(%rsp), %rax
movq 0x20(%rsp), %r9
shlq $0x4, %r9
addq %rax, %r9
addq %r15, %rax
movq %rdi, %rsi
jmp 0x463e
jge 0x464c
movq 0xd8(%rsp), %rcx
leaq (%rcx,%rbp,8), %r8
addq %r13, %rcx
movq 0x98(%rsp), %rsi
leaq (%rsi,%r15), %r9
movq 0x20(%rsp), %rax
shlq $0x4, %rax
addq %rsi, %rax
movq %rdx, %rsi
movq %rdi, %rdx
movq %rax, (%rsp)
movq 0x28(%rsp), %rdi
callq 0x55a8
incq %r14
addq $0x30, %r15
addq $0x60, %r12
addq $0x8, %r13
cmpq %r14, 0x58(%rsp)
jne 0x44b0
movq 0x38(%rsp), %r14
incq %r14
movq 0xc8(%rsp), %r15
addq $0x30, %r15
movq 0xc0(%rsp), %r12
addq $0x60, %r12
movq 0xb8(%rsp), %r13
addq $0x8, %r13
movq 0x30(%rsp), %rax
movq 0xb0(%rsp), %rbp
cmpq %rax, %rbp
jne 0x4462
leaq 0x180(%rsp), %rdi
callq 0x7f26
leaq 0x98(%rsp), %rdi
callq 0x6cae
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x46d4
callq 0x32a0
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x46e6
callq 0x32a0
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x46f8
callq 0x32a0
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x470a
callq 0x32a0
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4723
movq %rax, %rbx
jmp 0x4799
movq %rax, %rbx
jmp 0x47ab
jmp 0x4765
jmp 0x476a
jmp 0x4765
jmp 0x4765
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
jne 0x477a
jmp 0x477f
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x476d
callq 0x32a0
jmp 0x476d
jmp 0x476a
jmp 0x476a
movq %rax, %rbx
jmp 0x477f
movq %rax, %rbx
movq 0x168(%rsp), %rdi
testq %rdi, %rdi
je 0x477f
callq 0x32a0
leaq 0x180(%rsp), %rdi
callq 0x7f26
leaq 0x98(%rsp), %rdi
callq 0x6cae
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x47ab
callq 0x32a0
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x47bd
callq 0x32a0
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x47cf
callq 0x32a0
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x47e1
callq 0x32a0
movq %rbx, %rdi
callq 0x3470
nop