// File: /workspace/github_cpp_makefile_star2_O1/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 $0x78, %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 0xb768
movq 0x88(%r14), %rax
movzbl 0x40(%rax), %eax
leal -0x1(%rax), %ecx
cmpl $0x3, %ecx
ja 0x154d2
leaq 0x2025c(%rip), %rax     # 0x35334
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
testb %r15b, %r15b
jle 0x154ed
movq 0x10(%rbx), %rax
cmpq $0x0, 0x20(%rbx)
movq 0x18(%rbx), %rcx
sete %sil
testb %r12b, %r12b
setle %dl
orb %sil, %dl
xorpd %xmm0, %xmm0
xorl %esi, %esi
xorpd %xmm4, %xmm4
testq %rax, %rax
je 0x15136
movq 0x58(%rbx), %rdi
movq 0x70(%rbx), %r8
movsd (%rdi,%rsi,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm4
movsd (%r8,%rsi,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
testq %rcx, %rcx
je 0x15172
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
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm4
movsd (%r8,%r9,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %r9
cmpq %r9, %r15
jne 0x1514e
testb %dl, %dl
jne 0x151b0
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
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm4
movsd (%r8,%r9,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %r9
cmpq %r9, %r12
jne 0x1518c
incq %rsi
cmpq %r15, %rsi
jne 0x1510e
jmp 0x154f5
testb %r15b, %r15b
jle 0x154ed
movq 0x10(%rbx), %rax
cmpq $0x0, 0x20(%rbx)
movq 0x18(%rbx), %rcx
sete %sil
testb %r12b, %r12b
setle %dl
orb %sil, %dl
xorpd %xmm0, %xmm0
xorl %esi, %esi
xorpd %xmm4, %xmm4
testq %rax, %rax
je 0x15222
movq 0x58(%rbx), %rdi
movq 0x70(%rbx), %r8
movsd (%rdi,%rsi,8), %xmm1
movsd (%r8,%rsi,8), %xmm2
subsd %xmm1, %xmm2
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm4
movq 0xd0(%rbx), %rdi
mulsd (%rdi,%rsi,8), %xmm2
addsd %xmm2, %xmm0
testq %rcx, %rcx
je 0x1526f
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), %xmm1
movsd (%r8,%r10,8), %xmm2
subsd %xmm1, %xmm2
mulsd %xmm2, %xmm1
mulsd (%r9,%r10,8), %xmm2
addsd %xmm1, %xmm4
addsd %xmm2, %xmm0
incq %r10
cmpq %r10, %r15
jne 0x15245
testb %dl, %dl
jne 0x152be
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), %xmm1
movsd (%r8,%r10,8), %xmm2
subsd %xmm1, %xmm2
mulsd %xmm2, %xmm1
mulsd (%r9,%r10,8), %xmm2
addsd %xmm1, %xmm4
addsd %xmm2, %xmm0
incq %r10
cmpq %r10, %r12
jne 0x15294
incq %rsi
cmpq %r15, %rsi
jne 0x151ee
jmp 0x154f5
testb %r15b, %r15b
jle 0x154ed
movq 0x10(%rbx), %rax
cmpq $0x0, 0x20(%rbx)
movq 0x18(%rbx), %rcx
sete %sil
testb %r12b, %r12b
setle %dl
orb %sil, %dl
xorpd %xmm0, %xmm0
xorl %esi, %esi
xorpd %xmm4, %xmm4
testq %rax, %rax
je 0x15330
movq 0x58(%rbx), %rdi
movq 0x70(%rbx), %r8
movsd (%rdi,%rsi,8), %xmm1
movsd (%r8,%rsi,8), %xmm2
subsd %xmm1, %xmm2
mulsd %xmm1, %xmm1
subsd %xmm1, %xmm4
movq 0xd0(%rbx), %rdi
mulsd (%rdi,%rsi,8), %xmm2
addsd %xmm2, %xmm0
testq %rcx, %rcx
je 0x1537d
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
movsd (%r9,%r10,8), %xmm2
subsd %xmm1, %xmm2
mulsd %xmm1, %xmm1
mulsd (%r8,%r10,8), %xmm2
subsd %xmm1, %xmm4
addsd %xmm2, %xmm0
incq %r10
cmpq %r10, %r15
jne 0x15353
testb %dl, %dl
jne 0x153cc
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
movsd (%r9,%r10,8), %xmm2
subsd %xmm1, %xmm2
mulsd %xmm1, %xmm1
mulsd (%r8,%r10,8), %xmm2
subsd %xmm1, %xmm4
addsd %xmm2, %xmm0
incq %r10
cmpq %r10, %r12
jne 0x153a2
incq %rsi
cmpq %r15, %rsi
jne 0x152fc
jmp 0x154f5
testb %r15b, %r15b
jle 0x154ed
movq 0x10(%rbx), %rax
cmpq $0x0, 0x20(%rbx)
movq 0x18(%rbx), %rcx
sete %sil
testb %r12b, %r12b
setle %dl
orb %sil, %dl
xorpd %xmm0, %xmm0
xorl %esi, %esi
xorpd %xmm4, %xmm4
testq %rax, %rax
je 0x1543a
movq 0x58(%rbx), %rdi
movq 0x70(%rbx), %r8
movsd (%rdi,%rsi,8), %xmm1
movsd (%r8,%rsi,8), %xmm2
movapd %xmm2, %xmm3
subsd %xmm1, %xmm3
mulsd %xmm1, %xmm3
subsd %xmm3, %xmm4
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
testq %rcx, %rcx
je 0x1547e
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
mulsd %xmm1, %xmm3
subsd %xmm3, %xmm4
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %r9
cmpq %r9, %r15
jne 0x15452
testb %dl, %dl
jne 0x154c4
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
mulsd %xmm1, %xmm3
subsd %xmm3, %xmm4
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %r9
cmpq %r9, %r12
jne 0x15498
incq %rsi
cmpq %r15, %rsi
jne 0x1540a
jmp 0x154f5
movsbl %al, %edx
movq 0x2aafc(%rip), %rax     # 0x3ffd8
movq (%rax), %rdi
leaq 0x2029f(%rip), %rsi     # 0x35785
xorl %eax, %eax
callq 0x4330
xorpd %xmm4, %xmm4
xorpd %xmm0, %xmm0
movapd %xmm4, (%rsp)
callq 0x8d88
movsd %xmm0, 0x30(%rsp)
movq %rbx, %rdi
movl $0x8, %esi
callq 0xaf7c
testb %r15b, %r15b
jle 0x1560d
movapd (%rsp), %xmm1
divsd 0x30(%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 0x1557a
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 0x155be
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 0x155a0
testb %dl, %dl
jne 0x15601
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 0x155e3
incq %rsi
cmpq %r15, %rsi
jne 0x1554f
movq %rbx, %rdi
movl $0x8, %esi
callq 0xb768
movq 0x88(%r14), %rax
movslq 0xe8(%rbx), %rcx
testq %rcx, %rcx
xorpd %xmm1, %xmm1
jle 0x15659
movq 0xf0(%rbx), %rdx
xorl %esi, %esi
movq (%rdx,%rsi,8), %rdi
cmpl $0x0, 0x4(%rdi)
xorpd %xmm0, %xmm0
jne 0x1564d
movsd 0x50(%rdi), %xmm0
addsd %xmm0, %xmm1
incq %rsi
cmpq %rsi, %rcx
jne 0x1563a
movsd %xmm1, 0x28(%rsp)
movsd 0x968(%rax), %xmm0
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl $0x5, %esi
callq 0xaf08
movq %rbx, %rdi
movl $0x9, %esi
callq 0xaf08
movq %rbx, %rdi
movl $0x1, %esi
movl $0x5, %edx
callq 0xb032
movq %rbx, %rdi
movl $0x3, %esi
movl $0x9, %edx
callq 0xb032
xorpd %xmm5, %xmm5
xorpd %xmm3, %xmm3
testb %r15b, %r15b
jle 0x15767
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 0x156f6
movq 0x58(%rbx), %rdi
movq 0xb8(%rbx), %r8
movsd (%rdi,%rsi,8), %xmm0
mulsd (%r8,%rsi,8), %xmm0
addsd %xmm0, %xmm3
testq %rcx, %rcx
je 0x15729
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, %xmm3
incq %r9
cmpq %r9, %r15
jne 0x15711
testb %dl, %dl
jne 0x1575b
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, %xmm3
incq %r9
cmpq %r9, %r12
jne 0x15743
incq %rsi
cmpq %r15, %rsi
jne 0x156d7
movq 0x88(%r14), %rax
movsd (%rsp), %xmm1
ucomisd 0x970(%rax), %xmm1
jbe 0x15bab
xorpd %xmm0, %xmm0
movsd 0x1f15b(%rip), %xmm2    # 0x348e8
movapd %xmm2, 0x50(%rsp)
xorl %r13d, %r13d
movsd %xmm3, 0x18(%rsp)
movsd %xmm0, 0x48(%rsp)
testb %r15b, %r15b
jle 0x1587e
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 0x157f2
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 0x15832
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 0x15814
testb %sil, %sil
jne 0x15872
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 0x15854
incq %rdi
cmpq %r15, %rdi
jne 0x157ca
movsd %xmm1, (%rsp)
cmpb $0x1, 0x80(%r14)
jne 0x15939
cmpb $0x0, 0xf9(%rbx)
je 0x15939
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x158b8
movq 0x50(%r14), %rsi
movq 0x68(%r14), %rdx
movsbl %r15b, %ecx
callq 0x79f5
testb %r15b, %r15b
jle 0x15986
xorl %ebp, %ebp
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x158f9
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 0x79f5
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x1592f
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 0x79f5
incq %rbp
cmpq %rbp, %r15
jne 0x158c3
jmp 0x15986
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x1594b
movsbl %r15b, %esi
callq 0x692d
testb %r15b, %r15b
jle 0x15986
xorl %ebp, %ebp
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x15968
movq (%rax,%rbp,8), %rdi
movsbl %r15b, %esi
callq 0x692d
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x1597e
movq (%rax,%rbp,8), %rdi
movsbl %r12b, %esi
callq 0x692d
incq %rbp
cmpq %rbp, %r15
jne 0x15952
movl 0xe8(%rbx), %esi
movq 0xf0(%rbx), %rdx
movq %r14, %rdi
callq 0x11a86
movslq 0xe8(%rbx), %rax
xorpd %xmm4, %xmm4
testq %rax, %rax
movsd 0x28(%rsp), %xmm1
movsd (%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
jle 0x159e4
movq 0xf0(%rbx), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
cmpl $0x0, 0x4(%rsi)
xorpd %xmm0, %xmm0
jne 0x159d8
movsd 0x50(%rsi), %xmm0
addsd %xmm0, %xmm4
incq %rdx
cmpq %rdx, %rax
jne 0x159c5
movq (%r14), %rax
movq 0x88(%r14), %rcx
movsd 0x950(%rcx), %xmm0
mulsd %xmm2, %xmm0
mulsd %xmm3, %xmm0
addsd %xmm1, %xmm0
movapd %xmm4, 0x30(%rsp)
movapd %xmm0, 0x60(%rsp)
ucomisd %xmm4, %xmm0
setae %cl
movl %ecx, 0x24(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq *0x80(%rax)
movq %rbx, %rdi
movl $0x3, %esi
callq 0xb768
xorpd %xmm7, %xmm7
testb %r15b, %r15b
movapd 0x50(%rsp), %xmm4
jle 0x15af1
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 0x15a80
movq 0x58(%rbx), %rdi
movq 0xb8(%rbx), %r8
movsd (%r8,%rsi,8), %xmm0
mulsd (%rdi,%rsi,8), %xmm0
addsd %xmm0, %xmm7
testq %rcx, %rcx
je 0x15ab3
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, %xmm7
incq %r9
cmpq %r9, %r15
jne 0x15a9b
testb %dl, %dl
jne 0x15ae5
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, %xmm7
incq %r9
cmpq %r9, %r12
jne 0x15acd
incq %rsi
cmpq %r15, %rsi
jne 0x15a61
movq 0x88(%r14), %rax
movsd 0x958(%rax), %xmm0
movsd 0x18(%rsp), %xmm3
mulsd %xmm3, %xmm0
ucomisd %xmm0, %xmm7
setae %bpl
movapd %xmm4, %xmm1
movsd 0x1edca(%rip), %xmm2    # 0x348e8
cmpeqpd %xmm2, %xmm1
movapd 0x30(%rsp), %xmm5
movapd %xmm5, %xmm2
movapd 0x60(%rsp), %xmm8
cmplepd %xmm8, %xmm2
andpd %xmm1, %xmm2
movd %xmm2, %ecx
movsd (%rsp), %xmm1
movapd %xmm1, %xmm6
movapd %xmm5, %xmm2
testb $0x1, %cl
jne 0x15b5e
movapd %xmm4, %xmm6
movsd 0x48(%rsp), %xmm2
ucomisd %xmm5, %xmm8
jb 0x15b73
ucomisd %xmm0, %xmm7
movsd 0x1ed7f(%rip), %xmm0    # 0x348f0
jae 0x15b7b
movsd 0x960(%rax), %xmm0
ucomisd %xmm5, %xmm8
jae 0x15c08
divsd %xmm0, %xmm1
movq 0x88(%r14), %rax
ucomisd 0x970(%rax), %xmm1
movapd %xmm6, 0x50(%rsp)
movapd %xmm2, %xmm0
ja 0x1579c
jmp 0x15bc1
movsd 0x1ed35(%rip), %xmm6    # 0x348e8
xorl %ebp, %ebp
xorpd %xmm2, %xmm2
movl $0x0, 0x24(%rsp)
movsd %xmm6, 0x18(%rsp)
movapd %xmm5, 0x30(%rsp)
movapd %xmm2, (%rsp)
movq %rbx, %rdi
movl $0x9, %esi
movl $0x3, %edx
callq 0xb032
cmpb $0x0, 0x24(%rsp)
jne 0x15c25
movq %rbx, %rdi
movl $0x5, %esi
movl $0x1, %edx
callq 0xb032
movsd 0x28(%rsp), %xmm0
jmp 0x15efe
movsd %xmm6, 0x18(%rsp)
movapd %xmm2, (%rsp)
movq %rbx, %rdi
movl $0x9, %esi
movl $0x3, %edx
callq 0xb032
movapd 0x30(%rsp), %xmm0
testb %bpl, %bpl
jne 0x15efe
testb %r15b, %r15b
movapd (%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
jle 0x15dc8
xorl %r13d, %r13d
xorpd %xmm3, %xmm3
movsd 0x1ec99(%rip), %xmm4    # 0x348f0
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x15ca0
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 0x15c90
ucomisd %xmm4, %xmm0
jbe 0x15ca0
ucomisd %xmm3, %xmm0
jbe 0x15ca0
ucomisd %xmm0, %xmm4
ja 0x15da7
cmpq $0x0, 0x18(%rbx)
je 0x15d1a
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 0x15ce6
ucomisd %xmm4, %xmm0
jbe 0x15cf2
ucomisd %xmm3, %xmm0
jbe 0x15cf2
ucomisd %xmm0, %xmm4
ja 0x15cfc
incq %rbp
cmpq %rbp, %r15
jne 0x15ca9
jmp 0x15d1a
callq 0x4c5b
movsd 0x1ebe7(%rip), %xmm4    # 0x348f0
xorpd %xmm3, %xmm3
movsd 0x18(%rsp), %xmm2
movapd (%rsp), %xmm1
jmp 0x15cf2
cmpq $0x0, 0x20(%rbx)
je 0x15d99
testb %r12b, %r12b
jle 0x15d99
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 0x15d65
ucomisd %xmm4, %xmm0
jbe 0x15d71
ucomisd %xmm3, %xmm0
jbe 0x15d71
ucomisd %xmm0, %xmm4
ja 0x15d7b
incq %rbp
cmpq %rbp, %r12
jne 0x15d28
jmp 0x15d99
callq 0x4c77
movsd 0x1eb68(%rip), %xmm4    # 0x348f0
xorpd %xmm3, %xmm3
movsd 0x18(%rsp), %xmm2
movapd (%rsp), %xmm1
jmp 0x15d71
incq %r13
cmpq %r15, %r13
jne 0x15c57
jmp 0x15dc8
callq 0x4c3f
movsd 0x1eb3c(%rip), %xmm4    # 0x348f0
xorpd %xmm3, %xmm3
movsd 0x18(%rsp), %xmm2
movapd (%rsp), %xmm1
jmp 0x15ca0
cmpb $0x1, 0xf8(%rbx)
jne 0x15efa
cmpb $0x1, 0x80(%r14)
jne 0x15e9d
cmpb $0x0, 0xf9(%rbx)
je 0x15e9d
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x15e0f
movq 0x50(%r14), %rsi
movq 0x68(%r14), %rdx
movsbl %r15b, %ecx
callq 0x79f5
movapd (%rsp), %xmm1
testb %r15b, %r15b
jle 0x15efa
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x15e58
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 0x79f5
movapd (%rsp), %xmm1
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x15e93
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 0x79f5
movapd (%rsp), %xmm1
incq %rbp
cmpq %rbp, %r15
jne 0x15e1d
jmp 0x15efa
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x15eb4
movsbl %r15b, %esi
callq 0x692d
movapd (%rsp), %xmm1
testb %r15b, %r15b
jle 0x15efa
xorl %r14d, %r14d
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x15ed7
movq (%rax,%r14,8), %rdi
movsbl %r15b, %esi
callq 0x692d
movapd (%rsp), %xmm1
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x15ef2
movq (%rax,%r14,8), %rdi
movsbl %r12b, %esi
callq 0x692d
movapd (%rsp), %xmm1
incq %r14
cmpq %r14, %r15
jne 0x15ebc
movapd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movq %rbx, %rdi
movl $0x5, %esi
callq 0xafb8
movq %rbx, %rdi
movl $0x9, %esi
callq 0xafb8
movsd 0x28(%rsp), %xmm0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop