// File: /workspace/github_cpp_makefile_star2_O3/myudelson[P]hmm-scalable/HMMProblem.cpp
// Function: HMMProblem::doConjugateLinearStep(FitBit*)
NUMBER HMMProblem::doConjugateLinearStep(FitBit *fb) {
	NPAR i=0, j=0, m=0;
    NPAR nS = this->p->nS, nO = this->p->nO;
	// first scale down gradients
    fb->doLog10ScaleGentleByRow(FBS_GRAD);
    
    // compute beta_gradient_direction
    NUMBER beta_grad = 0, beta_grad_num = 0, beta_grad_den = 0;
    
    switch (this->p->solver_setting) {
        case 1: // Fletcher-Reeves
            for(i=0; i<nS; i++)
            {
                if(fb->pi != NULL) {
                    beta_grad_num += fb->gradPI  [i]*fb->gradPI  [i];
                    beta_grad_den += fb->gradPIm1[i]*fb->gradPIm1[i];
                }
                if(fb->A  != NULL)
                    for(j=0; j<nS; j++) {
                        beta_grad_num += fb->gradA  [i][j]*fb->gradA  [i][j];
                        beta_grad_den += fb->gradAm1[i][j]*fb->gradAm1[i][j];
                    }
                if(fb->B  != NULL)
                    for(m=0; m<nO; m++) {
                        beta_grad_num += fb->gradB  [i][m]*fb->gradB  [i][m];
                        beta_grad_den += fb->gradBm1[i][m]*fb->gradBm1[i][m];
                    }
            }
            break;
        case 2: // Polak–Ribiere
            for(i=0; i<nS; i++)
            {
                if(fb->pi != NULL) {
                    beta_grad_num += -fb->gradPI[i]*(-fb->gradPI[i] + fb->gradPIm1[i]);
                    beta_grad_den +=  fb->gradPIm1[i]*fb->gradPIm1[i];
                }
                if(fb->A != NULL)
                    for(j=0; j<nS; j++) {
                        beta_grad_num += -fb->gradA[i][j]*(-fb->gradA[i][j] + fb->gradAm1[i][j]);
                        beta_grad_den +=  fb->gradAm1[i][j]*fb->gradAm1[i][j];
                    }
                if(fb->B  != NULL)
                    for(m=0; m<nO; m++) {
                        beta_grad_num += -fb->gradB[i][m]*(-fb->gradB[i][m] + fb->gradBm1[i][m]);
                        beta_grad_den +=  fb->gradBm1[i][m]*fb->gradBm1[i][m];
                    }
            }
            break;
        case 3: // Hestenes-Stiefel
            for(i=0; i<nS; i++)
            {
                if(fb->pi != NULL) {
                    beta_grad_num +=  fb->gradPI[i]* (-fb->gradPI[i] + fb->gradPIm1[i]); // no -, since neg gradient and - is +
                    beta_grad_den +=  fb->dirPIm1[i]*(-fb->gradPI[i] + fb->gradPIm1[i]);
                }
                if(fb->A  != NULL)
                    for(j=0; j<nS; j++) {
                        beta_grad_num +=  fb->gradA[i][j]* (-fb->gradA[i][j] + fb->gradAm1[i][j]);
                        beta_grad_den +=  fb->dirAm1[i][j]*(-fb->gradA[i][j] + fb->gradAm1[i][j]);
                    }
                if(fb->B  != NULL)
                    for(m=0; m<nO; m++) {
                        beta_grad_num +=  fb->gradB[i][m]* (-fb->gradB[i][m] + fb->gradBm1[i][m]);
                        beta_grad_den +=  fb->dirBm1[i][m]*(-fb->gradB[i][m] + fb->gradBm1[i][m]);
                    }
            }
            break;
        case 4: // Dai-Yuan
            for(i=0; i<nS; i++)
            {
                if(fb->pi != NULL) {
                    beta_grad_num += -fb->gradPI [i]*fb->gradPI  [i];
                    beta_grad_den +=  fb->dirPIm1[i]*(-fb->gradPI[i] + fb->gradPIm1[i]);
                }
                if(fb->A  != NULL)
                    for(j=0; j<nS; j++) {
                        beta_grad_num += -fb->gradA [i][j]*fb->gradA  [i][j];
                        beta_grad_den +=  fb->dirAm1[i][j]*(-fb->gradA[i][j] + fb->gradAm1[i][j]);
                    }
                if(fb->B  != NULL)
                    for(m=0; m<nO; m++) {
                        beta_grad_num += -fb->gradB [i][m]*fb->gradB  [i][m];
                        beta_grad_den +=  fb->dirBm1[i][m]*(-fb->gradB[i][m] + fb->gradBm1[i][m]);
                    }
            }
            break;
        default:
            fprintf(stderr,"Wrong stepping algorithm (%d) specified for Conjugate Gradient Descent\n",this->p->solver_setting);
            break;
    }
    beta_grad = beta_grad_num / safe0num(beta_grad_den);
    beta_grad = (beta_grad>=0)?beta_grad:0;
    // compute new direction
    fb->toZero(FBS_DIR);
	for(i=0; i<nS; i++)
	{
		if(fb->pi != NULL) fb->dirPI[i] = -fb->gradPI[i] + beta_grad * fb->dirPIm1[i];
		if(fb->A  != NULL) for(j=0; j<nS; j++) fb->dirA[i][j] = -fb->gradA[i][j] + beta_grad * fb->dirAm1[i][j];
		if(fb->B  != NULL) for(m=0; m<nO; m++) fb->dirB[i][m] = -fb->gradB[i][m] + beta_grad * fb->dirBm1[i][m];
	}
	// scale direction
    fb->doLog10ScaleGentleByRow(FBS_DIR);
    
	NUMBER e = this->p->ArmijoSeed; // step seed
	bool compliesArmijo = false;
    bool compliesWolfe2 = false; // second wolfe condition is turned on, if satisfied - honored, if not, just the 1st is used
    NUMBER e_Armijo = -1; // e (step size) at which Armijo (Wolfe 1) criterion is satisfied, 'cos both criterions are sometimes not met.
    NUMBER f_xkplus1_Armijo = 0; // f_xkplus1_Armijo at which Armijo (Wolfe 1) criterion is satisfied, 'cos both criterions are sometimes not met.
	NUMBER f_xk = HMMProblem::getSumLogPOPara(fb->xndat, fb->x_data);
	NUMBER f_xkplus1 = 0;
	
    fb->init(FBS_PARcopy);
    fb->init(FBS_GRADcopy);
    
    fb->copy(FBS_PAR, FBS_PARcopy); // copy parameter
    fb->copy(FBS_GRAD, FBS_GRADcopy); // copy initial gradient
	// compute p_k * -p_k >>>> now current gradient by current direction
	NUMBER p_k_by_neg_p_k = 0;
	for(i=0; i<nS; i++)
	{
		if(fb->pi != NULL) p_k_by_neg_p_k += fb->gradPI[i]*fb->dirPI[i];
		if(fb->A  != NULL) for(j=0; j<nS; j++) p_k_by_neg_p_k += fb->gradA[i][j]*fb->dirA[i][j];
		if(fb->B  != NULL) for(m=0; m<nO; m++) p_k_by_neg_p_k += fb->gradB[i][m]*fb->dirB[i][m];
	}
	int iter = 0; // limit iter steps to 20, actually now 10, via ArmijoMinStep
	while( !compliesArmijo && e > this->p->ArmijoMinStep) {
		// update
		for(i=0; i<nS; i++) {
			if(fb->pi != NULL) fb->pi[i] = fb->PIcopy[i] + e * fb->dirPI[i];
            if(fb->A  != NULL)
                for(j=0; j<nS; j++)
                    fb->A[i][j] = fb->Acopy[i][j] + e * fb->dirA[i][j];
            if(fb->B  != NULL)
                for(m=0; m<nO; m++)
                    fb->B[i][m] = fb->Bcopy[i][m] + e * fb->dirB[i][m];
		}
		// scale
		if( !this->hasNon01Constraints() || fb->observe_non01_boundaries==0 ) {
			if(fb->pi != NULL) projectsimplex(fb->pi, nS);
			for(i=0; i<nS; i++) {
				if(fb->A != NULL) projectsimplex(fb->A[i], nS);
				if(fb->B != NULL) projectsimplex(fb->B[i], nO);
			}
		} else {
			if(fb->pi != NULL) projectsimplexbounded(fb->pi, this->getLbPI(), this->getUbPI(), nS);
			for(i=0; i<nS; i++) {
				if(fb->A != NULL) projectsimplexbounded(fb->A[i], this->getLbA()[i], this->getUbA()[i], nS);
				if(fb->B != NULL) projectsimplexbounded(fb->B[i], this->getLbB()[i], this->getUbB()[i], nO);
			}
		}
		// recompute alpha and p(O|param)
		computeAlphaAndPOParam(fb->xndat, fb->x_data);
		// compute f(x_{k+1})
		f_xkplus1 = HMMProblem::getSumLogPOPara(fb->xndat, fb->x_data);
		// compute Armijo compliance
		compliesArmijo = (f_xkplus1 <= (f_xk + (this->p->ArmijoC1 * e * p_k_by_neg_p_k)));
        // compute Wolfe 2
        NUMBER p_k_by_neg_p_kp1 = 0;
        computeGradients(fb);
        fb->doLog10ScaleGentleByRow(FBS_GRAD);
        for(i=0; i<nS; i++)
        {
            if(fb->pi != NULL) p_k_by_neg_p_kp1 += fb->dirPI[i]*fb->gradPI[i];
            if(fb->A  != NULL) for(j=0; j<nS; j++) p_k_by_neg_p_kp1 += fb->dirA[i][j]*fb->gradA[i][j];
            if(fb->B  != NULL) for(m=0; m<nO; m++) p_k_by_neg_p_kp1 += fb->dirB[i][m]*fb->gradB[i][m];
        }
        compliesWolfe2 = (p_k_by_neg_p_kp1 >= this->p->ArmijoC2 * p_k_by_neg_p_k);
        
        if( compliesArmijo && e_Armijo==-1 ){
            e_Armijo = e; // save the first time Armijo is statisfied, in case we'll roll back to it when Wolfe 2 is finnaly not satisfied
            f_xkplus1_Armijo = f_xkplus1;
        }
        
        e /= (compliesArmijo && compliesWolfe2)?1:this->p->ArmijoReduceFactor;
        iter++;
	} // armijo loop
    
    fb->copy(FBS_GRADcopy, FBS_GRAD); // return the original gradient in its place
    
    if(!compliesArmijo) { // we couldn't step away from current, copy the inital point back
        e = 0;
        fb->copy(FBS_PARcopy, FBS_PAR);
        f_xkplus1 = f_xk;
    } else if(compliesArmijo && !compliesWolfe2) { // we couldn't step away from current, copy the inital point back
        e = e_Armijo;
        f_xkplus1 = f_xkplus1_Armijo;
        // create new versions of FBS_PAR using e_Armijo as a step
        // update
        for(i=0; i<nS; i++) {
            if(fb->pi != NULL) {
                fb->pi[i] = fb->PIcopy[i] + e * fb->dirPI[i];
                if( (fb->pi[i]<0 || fb->pi[i] >1) && (fb->pi[i] > 0) && (fb->pi[i] < 1) ) {
                    fprintf(stderr, "ERROR! pi value is not within [0, 1] range!\n");
                }
            }
            if(fb->A  != NULL)
                for(j=0; j<nS; j++) {
                    fb->A[i][j] = fb->Acopy[i][j] + e * fb->dirA[i][j];
                    if( (fb->A[i][j]<0 || fb->A[i][j] >1) && (fb->A[i][j] > 0) && (fb->A[i][j] < 1) ) {
                        fprintf(stderr, "ERROR! A value is not within [0, 1] range!\n");
                    }
                }
            if(fb->B  != NULL)
                for(m=0; m<nO; m++) {
                    fb->B[i][m] = fb->Bcopy[i][m] + e * fb->dirB[i][m];
                    if( (fb->B[i][m]<0 || fb->B[i][m] >1) && (fb->B[i][m] > 0) && (fb->B[i][m] < 1) ) {
                        fprintf(stderr, "ERROR! B value is not within [0, 1] range!\n");
                    }
                }
        }
        // project parameters to simplex if needs be
        if(fb->projecttosimplex==1) {
            // scale
            if( !this->hasNon01Constraints() || fb->observe_non01_boundaries==0 ) {
                if(fb->pi != NULL) projectsimplex(fb->pi, nS);
                for(i=0; i<nS; i++) {
                    if(fb->A  != NULL) projectsimplex(fb->A[i], nS);
                    if(fb->B  != NULL) projectsimplex(fb->B[i], nO);
                }
            } else {
                if(fb->pi != NULL) projectsimplexbounded(fb->pi, this->getLbPI(), this->getUbPI(), nS);
                for(i=0; i<nS; i++) {
                    if(fb->A  != NULL) projectsimplexbounded(fb->A[i], this->getLbA()[i], this->getUbA()[i], nS);
                    if(fb->B  != NULL) projectsimplexbounded(fb->B[i], this->getLbB()[i], this->getUbB()[i], nO);
                }
            }
        }
        // ^^^^^ end of create new versions of FBS_PAR using e_Armijo as a step
    }
    fb->destroy(FBS_PARcopy);
    fb->destroy(FBS_GRADcopy);
    return f_xkplus1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x88(%rdi), %rax
movzbl 0x8b8(%rax), %r15d
movzbl 0x8b9(%rax), %r12d
movq %rsi, %rdi
movl $0x3, %esi
callq 0xb70e
movq 0x88(%r14), %rax
movzbl 0x40(%rax), %eax
leal -0x1(%rax), %ecx
cmpl $0x3, %ecx
ja 0x1537a
leaq 0x1f450(%rip), %rax     # 0x343c4
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
testb %r15b, %r15b
jle 0x15395
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
cmpq $0x0, 0x20(%rbx)
sete %sil
testb %r12b, %r12b
setle %dl
orb %sil, %dl
xorpd %xmm4, %xmm4
xorl %esi, %esi
testq %rax, %rax
je 0x14fc6
movq 0x58(%rbx), %rdi
movq 0x70(%rbx), %r8
movsd (%rdi,%rsi,8), %xmm0
movhpd (%r8,%rsi,8), %xmm0     # xmm0 = xmm0[0],mem[0]
mulpd %xmm0, %xmm0
addpd %xmm0, %xmm4
testq %rcx, %rcx
je 0x14ffa
movq 0x60(%rbx), %rdi
movq 0x78(%rbx), %r8
movq (%rdi,%rsi,8), %rdi
movq (%r8,%rsi,8), %r8
xorl %r9d, %r9d
movsd (%rdi,%r9,8), %xmm0
movhpd (%r8,%r9,8), %xmm0      # xmm0 = xmm0[0],mem[0]
mulpd %xmm0, %xmm0
addpd %xmm0, %xmm4
incq %r9
cmpq %r9, %r15
jne 0x14fde
testb %dl, %dl
jne 0x15030
movq 0x68(%rbx), %rdi
movq 0x80(%rbx), %r8
movq (%rdi,%rsi,8), %rdi
movq (%r8,%rsi,8), %r8
xorl %r9d, %r9d
movsd (%rdi,%r9,8), %xmm0
movhpd (%r8,%r9,8), %xmm0      # xmm0 = xmm0[0],mem[0]
mulpd %xmm0, %xmm0
addpd %xmm0, %xmm4
incq %r9
cmpq %r9, %r12
jne 0x15014
incq %rsi
cmpq %r15, %rsi
jne 0x14fa6
jmp 0x15399
testb %r15b, %r15b
jle 0x15395
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
cmpq $0x0, 0x20(%rbx)
sete %sil
testb %r12b, %r12b
setle %dl
orb %sil, %dl
xorpd %xmm4, %xmm4
xorl %esi, %esi
testq %rax, %rax
je 0x1509e
movq 0x58(%rbx), %rdi
movq 0x70(%rbx), %r8
movsd (%rdi,%rsi,8), %xmm0
movsd (%r8,%rsi,8), %xmm1
subsd %xmm0, %xmm1
movq 0xd0(%rbx), %rdi
movhpd (%rdi,%rsi,8), %xmm0    # xmm0 = xmm0[0],mem[0]
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm0, %xmm1
addpd %xmm1, %xmm4
testq %rcx, %rcx
je 0x150eb
movq 0x60(%rbx), %rdi
movq 0x78(%rbx), %r8
movq (%rdi,%rsi,8), %rdi
movq (%r8,%rsi,8), %r8
movq 0xd8(%rbx), %r9
movq (%r9,%rsi,8), %r9
xorl %r10d, %r10d
movsd (%rdi,%r10,8), %xmm0
movsd (%r8,%r10,8), %xmm1
subsd %xmm0, %xmm1
movhpd (%r9,%r10,8), %xmm0     # xmm0 = xmm0[0],mem[0]
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm0, %xmm1
addpd %xmm1, %xmm4
incq %r10
cmpq %r10, %r15
jne 0x150c1
testb %dl, %dl
jne 0x1513a
movq 0x68(%rbx), %rdi
movq 0x80(%rbx), %r8
movq (%rdi,%rsi,8), %rdi
movq (%r8,%rsi,8), %r8
movq 0xe0(%rbx), %r9
movq (%r9,%rsi,8), %r9
xorl %r10d, %r10d
movsd (%rdi,%r10,8), %xmm0
movsd (%r8,%r10,8), %xmm1
subsd %xmm0, %xmm1
movhpd (%r9,%r10,8), %xmm0     # xmm0 = xmm0[0],mem[0]
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm0, %xmm1
addpd %xmm1, %xmm4
incq %r10
cmpq %r10, %r12
jne 0x15110
incq %rsi
cmpq %r15, %rsi
jne 0x1506a
jmp 0x15399
testb %r15b, %r15b
jle 0x15395
movq 0x10(%rbx), %rax
cmpq $0x0, 0x20(%rbx)
movq 0x18(%rbx), %rcx
sete %sil
testb %r12b, %r12b
setle %dl
orb %sil, %dl
xorpd %xmm4, %xmm4
xorl %esi, %esi
movapd 0x1e7c4(%rip), %xmm0    # 0x33940
testq %rax, %rax
je 0x151b8
movq 0x58(%rbx), %rdi
movq 0x70(%rbx), %r8
movsd (%rdi,%rsi,8), %xmm1
movapd %xmm1, %xmm2
xorpd %xmm0, %xmm2
movq 0xd0(%rbx), %rdi
movsd (%r8,%rsi,8), %xmm3
movhpd (%rdi,%rsi,8), %xmm2    # xmm2 = xmm2[0],mem[0]
subsd %xmm1, %xmm3
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
mulpd %xmm2, %xmm1
addpd %xmm1, %xmm4
testq %rcx, %rcx
je 0x1520d
movq 0x60(%rbx), %rdi
movq 0x78(%rbx), %r9
movq (%rdi,%rsi,8), %rdi
movq 0xd8(%rbx), %r8
movq (%r8,%rsi,8), %r8
movq (%r9,%rsi,8), %r9
xorl %r10d, %r10d
movsd (%rdi,%r10,8), %xmm1
movapd %xmm1, %xmm2
xorpd %xmm0, %xmm2
movsd (%r9,%r10,8), %xmm3
subsd %xmm1, %xmm3
movhpd (%r8,%r10,8), %xmm2     # xmm2 = xmm2[0],mem[0]
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
mulpd %xmm2, %xmm1
addpd %xmm1, %xmm4
incq %r10
cmpq %r10, %r15
jne 0x151db
testb %dl, %dl
jne 0x15264
movq 0x68(%rbx), %rdi
movq 0x80(%rbx), %r9
movq (%rdi,%rsi,8), %rdi
movq 0xe0(%rbx), %r8
movq (%r8,%rsi,8), %r8
movq (%r9,%rsi,8), %r9
xorl %r10d, %r10d
movsd (%rdi,%r10,8), %xmm1
movapd %xmm1, %xmm2
xorpd %xmm0, %xmm2
movsd (%r9,%r10,8), %xmm3
subsd %xmm1, %xmm3
movhpd (%r8,%r10,8), %xmm2     # xmm2 = xmm2[0],mem[0]
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
mulpd %xmm2, %xmm1
addpd %xmm1, %xmm4
incq %r10
cmpq %r10, %r12
jne 0x15232
incq %rsi
cmpq %r15, %rsi
jne 0x1517c
jmp 0x15399
testb %r15b, %r15b
jle 0x15395
movq 0x10(%rbx), %rax
cmpq $0x0, 0x20(%rbx)
movq 0x18(%rbx), %rcx
sete %sil
testb %r12b, %r12b
setle %dl
orb %sil, %dl
xorpd %xmm4, %xmm4
xorl %esi, %esi
movapd 0x1e69a(%rip), %xmm0    # 0x33940
testq %rax, %rax
je 0x152da
movq 0x58(%rbx), %rdi
movq 0x70(%rbx), %r8
movsd (%rdi,%rsi,8), %xmm1
movsd (%r8,%rsi,8), %xmm2
movapd %xmm2, %xmm3
subsd %xmm1, %xmm3
xorpd %xmm0, %xmm1
unpcklpd %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
unpcklpd %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0]
mulpd %xmm1, %xmm3
addpd %xmm3, %xmm4
testq %rcx, %rcx
je 0x15322
movq 0x60(%rbx), %rdi
movq 0x78(%rbx), %r8
movq (%rdi,%rsi,8), %rdi
movq (%r8,%rsi,8), %r8
xorl %r9d, %r9d
movsd (%rdi,%r9,8), %xmm1
movsd (%r8,%r9,8), %xmm2
movapd %xmm2, %xmm3
subsd %xmm1, %xmm3
xorpd %xmm0, %xmm1
unpcklpd %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
unpcklpd %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0]
mulpd %xmm1, %xmm3
addpd %xmm3, %xmm4
incq %r9
cmpq %r9, %r15
jne 0x152f2
testb %dl, %dl
jne 0x1536c
movq 0x68(%rbx), %rdi
movq 0x80(%rbx), %r8
movq (%rdi,%rsi,8), %rdi
movq (%r8,%rsi,8), %r8
xorl %r9d, %r9d
movsd (%rdi,%r9,8), %xmm1
movsd (%r8,%r9,8), %xmm2
movapd %xmm2, %xmm3
subsd %xmm1, %xmm3
xorpd %xmm0, %xmm1
unpcklpd %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
unpcklpd %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0]
mulpd %xmm1, %xmm3
addpd %xmm3, %xmm4
incq %r9
cmpq %r9, %r12
jne 0x1533c
incq %rsi
cmpq %r15, %rsi
jne 0x152a6
jmp 0x15399
movsbl %al, %edx
movq 0x29c54(%rip), %rax     # 0x3efd8
movq (%rax), %rdi
leaq 0x1f487(%rip), %rsi     # 0x34815
xorl %eax, %eax
callq 0x4330
xorpd %xmm4, %xmm4
movapd %xmm4, (%rsp)
movapd %xmm4, %xmm0
unpckhpd %xmm4, %xmm0            # xmm0 = xmm0[1],xmm4[1]
callq 0x8df8
movsd %xmm0, 0x20(%rsp)
movq %rbx, %rdi
movl $0x8, %esi
callq 0xaf84
testb %r15b, %r15b
jle 0x154b9
movapd (%rsp), %xmm1
divsd 0x20(%rsp), %xmm1
xorpd %xmm0, %xmm0
cmplesd %xmm1, %xmm0
andpd %xmm1, %xmm0
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
cmpq $0x0, 0x20(%rbx)
sete %sil
testb %r12b, %r12b
setle %dl
orb %sil, %dl
xorl %esi, %esi
testq %rax, %rax
je 0x15426
movq 0xd0(%rbx), %rdi
movsd (%rdi,%rsi,8), %xmm1
mulsd %xmm0, %xmm1
movq 0x58(%rbx), %rdi
movq 0xb8(%rbx), %r8
subsd (%rdi,%rsi,8), %xmm1
movsd %xmm1, (%r8,%rsi,8)
testq %rcx, %rcx
je 0x1546a
movq 0x60(%rbx), %rdi
movq 0xc0(%rbx), %r9
movq (%rdi,%rsi,8), %rdi
movq 0xd8(%rbx), %r8
movq (%r8,%rsi,8), %r8
movq (%r9,%rsi,8), %r9
xorl %r10d, %r10d
movsd (%r8,%r10,8), %xmm1
mulsd %xmm0, %xmm1
subsd (%rdi,%r10,8), %xmm1
movsd %xmm1, (%r9,%r10,8)
incq %r10
cmpq %r10, %r15
jne 0x1544c
testb %dl, %dl
jne 0x154ad
movq 0x68(%rbx), %rdi
movq 0xc8(%rbx), %r9
movq (%rdi,%rsi,8), %rdi
movq 0xe0(%rbx), %r8
movq (%r8,%rsi,8), %r8
movq (%r9,%rsi,8), %r9
xorl %r10d, %r10d
movsd (%r8,%r10,8), %xmm1
mulsd %xmm0, %xmm1
subsd (%rdi,%r10,8), %xmm1
movsd %xmm1, (%r9,%r10,8)
incq %r10
cmpq %r10, %r12
jne 0x1548f
incq %rsi
cmpq %r15, %rsi
jne 0x153fb
movq %rbx, %rdi
movl $0x8, %esi
callq 0xb70e
movq 0x88(%r14), %rax
movslq 0xe8(%rbx), %rcx
testq %rcx, %rcx
xorpd %xmm1, %xmm1
jle 0x15505
movq 0xf0(%rbx), %rdx
xorl %esi, %esi
movq (%rdx,%rsi,8), %rdi
cmpl $0x0, 0x4(%rdi)
xorpd %xmm0, %xmm0
jne 0x154f9
movsd 0x50(%rdi), %xmm0
addsd %xmm0, %xmm1
incq %rsi
cmpq %rsi, %rcx
jne 0x154e6
movsd %xmm1, 0x30(%rsp)
movsd 0x968(%rax), %xmm0
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl $0x5, %esi
callq 0xaf10
movq %rbx, %rdi
movl $0x9, %esi
callq 0xaf10
movq %rbx, %rdi
movl $0x1, %esi
movl $0x5, %edx
callq 0xb03a
movq %rbx, %rdi
movl $0x3, %esi
movl $0x9, %edx
callq 0xb03a
xorpd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
xorpd %xmm1, %xmm1
testb %r15b, %r15b
jle 0x15619
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
cmpq $0x0, 0x20(%rbx)
sete %sil
testb %r12b, %r12b
setle %dl
orb %sil, %dl
xorl %esi, %esi
testq %rax, %rax
je 0x155a8
movq 0x58(%rbx), %rdi
movq 0xb8(%rbx), %r8
movsd (%rdi,%rsi,8), %xmm0
mulsd (%r8,%rsi,8), %xmm0
addsd %xmm0, %xmm1
testq %rcx, %rcx
je 0x155db
movq 0x60(%rbx), %rdi
movq 0xc0(%rbx), %r8
movq (%rdi,%rsi,8), %rdi
movq (%r8,%rsi,8), %r8
xorl %r9d, %r9d
movsd (%rdi,%r9,8), %xmm0
mulsd (%r8,%r9,8), %xmm0
addsd %xmm0, %xmm1
incq %r9
cmpq %r9, %r15
jne 0x155c3
testb %dl, %dl
jne 0x1560d
movq 0x68(%rbx), %rdi
movq 0xc8(%rbx), %r8
movq (%rdi,%rsi,8), %rdi
movq (%r8,%rsi,8), %r8
xorl %r9d, %r9d
movsd (%rdi,%r9,8), %xmm0
mulsd (%r8,%r9,8), %xmm0
addsd %xmm0, %xmm1
incq %r9
cmpq %r9, %r12
jne 0x155f5
incq %rsi
cmpq %r15, %rsi
jne 0x15589
movsd %xmm1, 0x18(%rsp)
movq 0x88(%r14), %rax
movsd 0x1e2ba(%rip), %xmm0    # 0x338e8
xorl %r13d, %r13d
movsd (%rsp), %xmm1
ucomisd 0x970(%rax), %xmm1
jbe 0x15beb
movapd %xmm0, 0x50(%rsp)
testb %r15b, %r15b
jle 0x15726
testb %r12b, %r12b
setle %dil
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
movq 0x20(%rbx), %rdx
testq %rdx, %rdx
sete %sil
orb %dil, %sil
xorl %edi, %edi
testq %rax, %rax
je 0x1569a
movq 0xa0(%rbx), %r8
movq 0xb8(%rbx), %r9
movsd (%r9,%rdi,8), %xmm0
mulsd %xmm1, %xmm0
addsd (%r8,%rdi,8), %xmm0
movsd %xmm0, (%rax,%rdi,8)
testq %rcx, %rcx
je 0x156da
movq 0xa8(%rbx), %r8
movq 0xc0(%rbx), %r9
movq (%r8,%rdi,8), %r8
movq (%r9,%rdi,8), %r9
movq (%rcx,%rdi,8), %r10
xorl %r11d, %r11d
movsd (%r9,%r11,8), %xmm0
mulsd %xmm1, %xmm0
addsd (%r8,%r11,8), %xmm0
movsd %xmm0, (%r10,%r11,8)
incq %r11
cmpq %r11, %r15
jne 0x156bc
testb %sil, %sil
jne 0x1571a
movq 0xb0(%rbx), %r8
movq 0xc8(%rbx), %r9
movq (%r8,%rdi,8), %r8
movq (%r9,%rdi,8), %r9
movq (%rdx,%rdi,8), %r10
xorl %r11d, %r11d
movsd (%r9,%r11,8), %xmm0
mulsd %xmm1, %xmm0
addsd (%r8,%r11,8), %xmm0
movsd %xmm0, (%r10,%r11,8)
incq %r11
cmpq %r11, %r12
jne 0x156fc
incq %rdi
cmpq %r15, %rdi
jne 0x15672
cmpb $0x0, 0x80(%r14)
movsd %xmm1, (%rsp)
je 0x157e1
cmpb $0x0, 0xf9(%rbx)
movq 0x10(%rbx), %rdi
je 0x157e5
testq %rdi, %rdi
je 0x15760
movq 0x50(%r14), %rsi
movq 0x68(%r14), %rdx
movsbl %r15b, %ecx
callq 0x7997
testb %r15b, %r15b
jle 0x1582e
xorl %ebp, %ebp
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x157a1
movq (%rax,%rbp,8), %rdi
cmpb $0x0, 0x80(%r14)
movq 0x58(%r14), %rax
cmoveq %r13, %rax
movq (%rax,%rbp,8), %rsi
movq 0x70(%r14), %rax
cmoveq %r13, %rax
movq (%rax,%rbp,8), %rdx
movsbl %r15b, %ecx
callq 0x7997
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x157d7
movq (%rax,%rbp,8), %rdi
cmpb $0x0, 0x80(%r14)
movq 0x60(%r14), %rax
cmoveq %r13, %rax
movq (%rax,%rbp,8), %rsi
movq 0x78(%r14), %rax
cmoveq %r13, %rax
movq (%rax,%rbp,8), %rdx
movsbl %r12b, %ecx
callq 0x7997
incq %rbp
cmpq %rbp, %r15
jne 0x1576b
jmp 0x1582e
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x157f3
movsbl %r15b, %esi
callq 0x6836
testb %r15b, %r15b
jle 0x1582e
xorl %ebp, %ebp
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x15810
movq (%rax,%rbp,8), %rdi
movsbl %r15b, %esi
callq 0x6836
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x15826
movq (%rax,%rbp,8), %rdi
movsbl %r12b, %esi
callq 0x6836
incq %rbp
cmpq %rbp, %r15
jne 0x157fa
movl 0xe8(%rbx), %esi
movq 0xf0(%rbx), %rdx
movq %r14, %rdi
callq 0x11908
movslq 0xe8(%rbx), %rax
xorpd %xmm2, %xmm2
testq %rax, %rax
movsd (%rsp), %xmm1
jle 0x15880
movq 0xf0(%rbx), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
cmpl $0x0, 0x4(%rsi)
xorpd %xmm0, %xmm0
jne 0x15874
movsd 0x50(%rsi), %xmm0
addsd %xmm0, %xmm2
incq %rdx
cmpq %rdx, %rax
jne 0x15861
movapd %xmm2, 0x20(%rsp)
movq (%r14), %rax
movq 0x88(%r14), %rcx
movsd 0x950(%rcx), %xmm0
mulsd %xmm1, %xmm0
movapd %xmm0, 0x40(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq *0x80(%rax)
movq %rbx, %rdi
movl $0x3, %esi
callq 0xb70e
xorpd %xmm5, %xmm5
movapd 0x20(%rsp), %xmm4
testb %r15b, %r15b
movsd 0x30(%rsp), %xmm1
jle 0x15980
testb %r12b, %r12b
setle %sil
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
cmpq $0x0, 0x20(%rbx)
sete %dl
orb %sil, %dl
xorl %esi, %esi
testq %rax, %rax
je 0x1590f
movq 0x58(%rbx), %rdi
movq 0xb8(%rbx), %r8
movsd (%r8,%rsi,8), %xmm0
mulsd (%rdi,%rsi,8), %xmm0
addsd %xmm0, %xmm5
testq %rcx, %rcx
je 0x15942
movq 0x60(%rbx), %r8
movq 0xc0(%rbx), %rdi
movq (%rdi,%rsi,8), %rdi
movq (%r8,%rsi,8), %r8
xorl %r9d, %r9d
movsd (%rdi,%r9,8), %xmm0
mulsd (%r8,%r9,8), %xmm0
addsd %xmm0, %xmm5
incq %r9
cmpq %r9, %r15
jne 0x1592a
testb %dl, %dl
jne 0x15974
movq 0x68(%rbx), %r8
movq 0xc8(%rbx), %rdi
movq (%rdi,%rsi,8), %rdi
movq (%r8,%rsi,8), %r8
xorl %r9d, %r9d
movsd (%rdi,%r9,8), %xmm0
mulsd (%r8,%r9,8), %xmm0
addsd %xmm0, %xmm5
incq %r9
cmpq %r9, %r12
jne 0x1595c
incq %rsi
cmpq %r15, %rsi
jne 0x158f0
movapd 0x40(%rsp), %xmm7
mulsd 0x18(%rsp), %xmm7
addsd %xmm1, %xmm7
movapd 0x50(%rsp), %xmm2
movapd %xmm2, %xmm0
movsd 0x1df46(%rip), %xmm1    # 0x338e8
cmpeqpd %xmm1, %xmm0
movapd %xmm4, %xmm1
cmplepd %xmm7, %xmm1
andpd %xmm0, %xmm1
movd %xmm1, %eax
movsd (%rsp), %xmm1
movapd %xmm1, %xmm6
movapd %xmm4, %xmm3
testb $0x1, %al
jne 0x159d3
movapd %xmm2, %xmm6
movsd 0x38(%rsp), %xmm3
ucomisd %xmm4, %xmm7
movq 0x88(%r14), %rax
movsd 0x958(%rax), %xmm2
mulsd 0x18(%rsp), %xmm2
jb 0x159fc
ucomisd %xmm2, %xmm5
movsd 0x1def6(%rip), %xmm0    # 0x338f0
jae 0x15a04
movsd 0x960(%rax), %xmm0
ucomisd %xmm4, %xmm7
divsd %xmm0, %xmm1
movsd %xmm3, 0x38(%rsp)
movapd %xmm6, %xmm0
jb 0x15636
movsd %xmm6, 0x18(%rsp)
movsd %xmm3, (%rsp)
movq %rbx, %rdi
movl $0x9, %esi
movl $0x3, %edx
movsd %xmm5, 0x50(%rsp)
movsd %xmm2, 0x40(%rsp)
callq 0xb03a
movsd 0x50(%rsp), %xmm0
ucomisd 0x40(%rsp), %xmm0
jae 0x15c1b
testb %r15b, %r15b
movsd (%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
jle 0x15c49
xorl %r13d, %r13d
xorpd %xmm3, %xmm3
movsd 0x1de76(%rip), %xmm4    # 0x338f0
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x15ac3
movq 0xa0(%rbx), %rcx
movq 0xb8(%rbx), %rdx
movsd (%rdx,%r13,8), %xmm0
mulsd %xmm2, %xmm0
addsd (%rcx,%r13,8), %xmm0
movsd %xmm0, (%rax,%r13,8)
ucomisd %xmm0, %xmm3
ja 0x15ab3
ucomisd %xmm4, %xmm0
jbe 0x15ac3
ucomisd %xmm3, %xmm0
jbe 0x15ac3
ucomisd %xmm0, %xmm4
ja 0x15bca
cmpq $0x0, 0x18(%rbx)
je 0x15b3d
xorl %ebp, %ebp
movq 0x18(%rbx), %rax
movq 0xa8(%rbx), %rcx
movq (%rcx,%r13,8), %rcx
movq 0xc0(%rbx), %rdx
movq (%rdx,%r13,8), %rdx
movsd (%rdx,%rbp,8), %xmm0
mulsd %xmm2, %xmm0
addsd (%rcx,%rbp,8), %xmm0
movq (%rax,%r13,8), %rax
movsd %xmm0, (%rax,%rbp,8)
ucomisd %xmm0, %xmm3
ja 0x15b09
ucomisd %xmm4, %xmm0
jbe 0x15b15
ucomisd %xmm3, %xmm0
jbe 0x15b15
ucomisd %xmm0, %xmm4
ja 0x15b1f
incq %rbp
cmpq %rbp, %r15
jne 0x15acc
jmp 0x15b3d
callq 0x4c43
movsd 0x1ddc4(%rip), %xmm4    # 0x338f0
xorpd %xmm3, %xmm3
movsd 0x18(%rsp), %xmm2
movsd (%rsp), %xmm1
jmp 0x15b15
cmpq $0x0, 0x20(%rbx)
je 0x15bbc
testb %r12b, %r12b
jle 0x15bbc
xorl %ebp, %ebp
movq 0x20(%rbx), %rax
movq 0xb0(%rbx), %rcx
movq (%rcx,%r13,8), %rcx
movq 0xc8(%rbx), %rdx
movq (%rdx,%r13,8), %rdx
movsd (%rdx,%rbp,8), %xmm0
mulsd %xmm2, %xmm0
addsd (%rcx,%rbp,8), %xmm0
movq (%rax,%r13,8), %rax
movsd %xmm0, (%rax,%rbp,8)
ucomisd %xmm0, %xmm3
ja 0x15b88
ucomisd %xmm4, %xmm0
jbe 0x15b94
ucomisd %xmm3, %xmm0
jbe 0x15b94
ucomisd %xmm0, %xmm4
ja 0x15b9e
incq %rbp
cmpq %rbp, %r12
jne 0x15b4b
jmp 0x15bbc
callq 0x4c5f
movsd 0x1dd45(%rip), %xmm4    # 0x338f0
xorpd %xmm3, %xmm3
movsd 0x18(%rsp), %xmm2
movsd (%rsp), %xmm1
jmp 0x15b94
incq %r13
cmpq %r15, %r13
jne 0x15a7a
jmp 0x15c49
callq 0x4c27
movsd 0x1dd19(%rip), %xmm4    # 0x338f0
xorpd %xmm3, %xmm3
movsd 0x18(%rsp), %xmm2
movsd (%rsp), %xmm1
jmp 0x15ac3
movq %rbx, %rdi
movl $0x9, %esi
movl $0x3, %edx
callq 0xb03a
movq %rbx, %rdi
movl $0x5, %esi
movl $0x1, %edx
callq 0xb03a
movsd 0x30(%rsp), %xmm0
movapd %xmm0, 0x20(%rsp)
movq %rbx, %rdi
movl $0x5, %esi
callq 0xafc0
movq %rbx, %rdi
movl $0x9, %esi
callq 0xafc0
movaps 0x20(%rsp), %xmm0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x1, 0xf8(%rbx)
jne 0x15d21
cmpb $0x0, 0x80(%r14)
je 0x15d2c
cmpb $0x0, 0xf9(%rbx)
movq 0x10(%rbx), %rdi
je 0x15d30
testq %rdi, %rdi
je 0x15c8b
movq 0x50(%r14), %rsi
movq 0x68(%r14), %rdx
movsbl %r15b, %ecx
callq 0x7997
testb %r15b, %r15b
jle 0x15d8e
xorl %r13d, %r13d
xorl %ebp, %ebp
movsd (%rsp), %xmm0
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x15cd9
movq (%rax,%rbp,8), %rdi
cmpb $0x0, 0x80(%r14)
movq 0x58(%r14), %rax
cmoveq %r13, %rax
movq (%rax,%rbp,8), %rsi
movq 0x70(%r14), %rax
cmoveq %r13, %rax
movq (%rax,%rbp,8), %rdx
movsbl %r15b, %ecx
callq 0x7997
movsd (%rsp), %xmm0
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x15d14
movq (%rax,%rbp,8), %rdi
cmpb $0x0, 0x80(%r14)
movq 0x60(%r14), %rax
cmoveq %r13, %rax
movq (%rax,%rbp,8), %rsi
movq 0x78(%r14), %rax
cmoveq %r13, %rax
movq (%rax,%rbp,8), %rdx
movsbl %r12b, %ecx
callq 0x7997
movsd (%rsp), %xmm0
incq %rbp
cmpq %rbp, %r15
jne 0x15c9e
jmp 0x15c15
movapd %xmm1, 0x20(%rsp)
jmp 0x15c1b
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x15d3e
movsbl %r15b, %esi
callq 0x6836
testb %r15b, %r15b
jle 0x15d8e
xorl %r14d, %r14d
movsd (%rsp), %xmm0
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x15d66
movq (%rax,%r14,8), %rdi
movsbl %r15b, %esi
callq 0x6836
movsd (%rsp), %xmm0
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x15d81
movq (%rax,%r14,8), %rdi
movsbl %r12b, %esi
callq 0x6836
movsd (%rsp), %xmm0
incq %r14
cmpq %r14, %r15
jne 0x15d4b
jmp 0x15c15
movsd (%rsp), %xmm0
jmp 0x15c15