// File: /workspace/github_cpp_makefile_star2_O2/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 $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x88(%rdi), %rax
movb 0x8b8(%rax), %bpl
movb 0x8b9(%rax), %r15b
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x8f0e
movq 0x88(%r14), %rax
movzbl 0x40(%rax), %eax
leal -0x1(%rax), %ecx
movb %bpl, (%rsp)
movzbl %bpl, %r13d
movb %r15b, 0x4(%rsp)
movzbl %r15b, %ebp
cmpl $0x3, %ecx
ja 0x11af8
leaq 0x1bcb9(%rip), %rax     # 0x2d3c4
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
xorl %eax, %eax
testb %r13b, %r13b
cmovlel %eax, %r13d
testb %bpl, %bpl
cmovlel %eax, %ebp
movl $0xff, %edx
andl %edx, %r13d
movl %ebp, %ecx
andl %edx, %ecx
xorpd %xmm4, %xmm4
cmpq %r13, %rax
je 0x11b2f
cmpq $0x0, 0x10(%rbx)
je 0x1175d
movq 0x58(%rbx), %rdx
movq 0x70(%rbx), %rsi
movsd (%rdx,%rax,8), %xmm0
movhpd (%rsi,%rax,8), %xmm0    # xmm0 = xmm0[0],mem[0]
mulpd %xmm0, %xmm0
addpd %xmm0, %xmm4
cmpq $0x0, 0x18(%rbx)
je 0x11792
xorl %edx, %edx
cmpq %rdx, %r13
je 0x11792
movq 0x60(%rbx), %rsi
movq 0x78(%rbx), %rdi
movq (%rsi,%rax,8), %rsi
movq (%rdi,%rax,8), %rdi
movsd (%rsi,%rdx,8), %xmm0
movhpd (%rdi,%rdx,8), %xmm0    # xmm0 = xmm0[0],mem[0]
mulpd %xmm0, %xmm0
addpd %xmm0, %xmm4
incq %rdx
jmp 0x11766
cmpq $0x0, 0x20(%rbx)
je 0x117ca
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x117ca
movq 0x68(%rbx), %rsi
movq 0x80(%rbx), %rdi
movq (%rsi,%rax,8), %rsi
movq (%rdi,%rax,8), %rdi
movsd (%rsi,%rdx,8), %xmm0
movhpd (%rdi,%rdx,8), %xmm0    # xmm0 = xmm0[0],mem[0]
mulpd %xmm0, %xmm0
addpd %xmm0, %xmm4
incq %rdx
jmp 0x1179b
incq %rax
jmp 0x11733
xorl %eax, %eax
testb %r13b, %r13b
cmovlel %eax, %r13d
testb %bpl, %bpl
cmovlel %eax, %ebp
movl $0xff, %edx
andl %edx, %r13d
movl %ebp, %ecx
andl %edx, %ecx
xorpd %xmm4, %xmm4
cmpq %r13, %rax
je 0x11b2f
cmpq $0x0, 0x10(%rbx)
je 0x1182f
movq 0x58(%rbx), %rdx
movq 0x70(%rbx), %rsi
movsd (%rdx,%rax,8), %xmm0
movsd (%rsi,%rax,8), %xmm1
subsd %xmm0, %xmm1
movq 0xd0(%rbx), %rdx
movhpd (%rdx,%rax,8), %xmm0    # xmm0 = xmm0[0],mem[0]
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm0, %xmm1
addpd %xmm1, %xmm4
cmpq $0x0, 0x18(%rbx)
je 0x1187c
xorl %edx, %edx
cmpq %rdx, %r13
je 0x1187c
movq 0x60(%rbx), %rsi
movq 0x78(%rbx), %rdi
movq (%rsi,%rax,8), %rsi
movsd (%rsi,%rdx,8), %xmm0
movq (%rdi,%rax,8), %rsi
movsd (%rsi,%rdx,8), %xmm1
subsd %xmm0, %xmm1
movq 0xd8(%rbx), %rsi
movq (%rsi,%rax,8), %rsi
movhpd (%rsi,%rdx,8), %xmm0    # xmm0 = xmm0[0],mem[0]
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm0, %xmm1
addpd %xmm1, %xmm4
incq %rdx
jmp 0x11838
cmpq $0x0, 0x20(%rbx)
je 0x118cc
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x118cc
movq 0x68(%rbx), %rsi
movq 0x80(%rbx), %rdi
movq (%rsi,%rax,8), %rsi
movsd (%rsi,%rdx,8), %xmm0
movq (%rdi,%rax,8), %rsi
movsd (%rsi,%rdx,8), %xmm1
subsd %xmm0, %xmm1
movq 0xe0(%rbx), %rsi
movq (%rsi,%rax,8), %rsi
movhpd (%rsi,%rdx,8), %xmm0    # xmm0 = xmm0[0],mem[0]
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm0, %xmm1
addpd %xmm1, %xmm4
incq %rdx
jmp 0x11885
incq %rax
jmp 0x117f1
xorl %eax, %eax
testb %r13b, %r13b
cmovlel %eax, %r13d
testb %bpl, %bpl
cmovlel %eax, %ebp
movl $0xff, %edx
andl %edx, %r13d
movl %ebp, %ecx
andl %edx, %ecx
xorpd %xmm4, %xmm4
movapd 0x1b045(%rip), %xmm0    # 0x2c940
cmpq %r13, %rax
je 0x11b2f
cmpq $0x0, 0x10(%rbx)
je 0x11941
movq 0x58(%rbx), %rdx
movq 0x70(%rbx), %rsi
movsd (%rdx,%rax,8), %xmm1
movapd %xmm1, %xmm2
xorpd %xmm0, %xmm2
movq 0xd0(%rbx), %rdx
movsd (%rsi,%rax,8), %xmm3
movhpd (%rdx,%rax,8), %xmm2    # xmm2 = xmm2[0],mem[0]
subsd %xmm1, %xmm3
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
mulpd %xmm2, %xmm1
addpd %xmm1, %xmm4
cmpq $0x0, 0x18(%rbx)
je 0x11996
xorl %edx, %edx
cmpq %rdx, %r13
je 0x11996
movq 0x60(%rbx), %rsi
movq 0x78(%rbx), %rdi
movq (%rsi,%rax,8), %rsi
movsd (%rsi,%rdx,8), %xmm1
movapd %xmm1, %xmm2
xorpd %xmm0, %xmm2
movq 0xd8(%rbx), %rsi
movq (%rsi,%rax,8), %rsi
movq (%rdi,%rax,8), %rdi
movsd (%rdi,%rdx,8), %xmm3
subsd %xmm1, %xmm3
movhpd (%rsi,%rdx,8), %xmm2    # xmm2 = xmm2[0],mem[0]
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
mulpd %xmm2, %xmm1
addpd %xmm1, %xmm4
incq %rdx
jmp 0x1194a
cmpq $0x0, 0x20(%rbx)
je 0x119ee
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x119ee
movq 0x68(%rbx), %rsi
movq 0x80(%rbx), %rdi
movq (%rsi,%rax,8), %rsi
movsd (%rsi,%rdx,8), %xmm1
movapd %xmm1, %xmm2
xorpd %xmm0, %xmm2
movq 0xe0(%rbx), %rsi
movq (%rsi,%rax,8), %rsi
movq (%rdi,%rax,8), %rdi
movsd (%rdi,%rdx,8), %xmm3
subsd %xmm1, %xmm3
movhpd (%rsi,%rdx,8), %xmm2    # xmm2 = xmm2[0],mem[0]
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
mulpd %xmm2, %xmm1
addpd %xmm1, %xmm4
incq %rdx
jmp 0x1199f
incq %rax
jmp 0x118fb
xorl %eax, %eax
testb %r13b, %r13b
cmovlel %eax, %r13d
testb %bpl, %bpl
cmovlel %eax, %ebp
movl $0xff, %edx
andl %edx, %r13d
movl %ebp, %ecx
andl %edx, %ecx
xorpd %xmm4, %xmm4
movapd 0x1af23(%rip), %xmm0    # 0x2c940
cmpq %r13, %rax
je 0x11b2f
cmpq $0x0, 0x10(%rbx)
je 0x11a5b
movq 0x58(%rbx), %rdx
movq 0x70(%rbx), %rsi
movsd (%rdx,%rax,8), %xmm1
movsd (%rsi,%rax,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
cmpq $0x0, 0x18(%rbx)
je 0x11aa4
xorl %edx, %edx
cmpq %rdx, %r13
je 0x11aa4
movq 0x60(%rbx), %rsi
movq 0x78(%rbx), %rdi
movq (%rsi,%rax,8), %rsi
movsd (%rsi,%rdx,8), %xmm1
movq (%rdi,%rax,8), %rsi
movsd (%rsi,%rdx,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 %rdx
jmp 0x11a64
cmpq $0x0, 0x20(%rbx)
je 0x11af0
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x11af0
movq 0x68(%rbx), %rsi
movq 0x80(%rbx), %rdi
movq (%rsi,%rax,8), %rsi
movsd (%rsi,%rdx,8), %xmm1
movq (%rdi,%rax,8), %rsi
movsd (%rsi,%rdx,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 %rdx
jmp 0x11aad
incq %rax
jmp 0x11a1d
movsbl %al, %edx
movq 0x274d6(%rip), %rax     # 0x38fd8
movq (%rax), %rdi
leaq 0x1bd09(%rip), %rsi     # 0x2d815
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x4350
testb %r13b, %r13b
cmovlel %r15d, %r13d
testb %bpl, %bpl
cmovgl %ebp, %r15d
movzbl %r13b, %r13d
xorpd %xmm4, %xmm4
movl %r15d, %ebp
movapd %xmm4, 0x20(%rsp)
movapd %xmm4, %xmm0
unpckhpd %xmm4, %xmm0            # xmm0 = xmm0[1],xmm4[1]
callq 0x67cb
movapd 0x20(%rsp), %xmm1
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
cmplesd %xmm1, %xmm0
andpd %xmm1, %xmm0
movapd %xmm0, 0x20(%rsp)
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x8800
movapd 0x20(%rsp), %xmm1
movzbl %bpl, %r12d
xorl %eax, %eax
cmpq %r13, %rax
je 0x11c3b
cmpq $0x0, 0x10(%rbx)
je 0x11bab
movq 0xd0(%rbx), %rcx
movsd (%rcx,%rax,8), %xmm0
mulsd %xmm1, %xmm0
movq 0x58(%rbx), %rcx
movq 0xb8(%rbx), %rdx
subsd (%rcx,%rax,8), %xmm0
movsd %xmm0, (%rdx,%rax,8)
cmpq $0x0, 0x18(%rbx)
je 0x11bef
xorl %ecx, %ecx
cmpq %rcx, %r13
je 0x11bef
movq 0x60(%rbx), %rdx
movq (%rdx,%rax,8), %rdx
movq 0xd8(%rbx), %rsi
movq (%rsi,%rax,8), %rsi
movsd (%rsi,%rcx,8), %xmm0
mulsd %xmm1, %xmm0
subsd (%rdx,%rcx,8), %xmm0
movq 0xc0(%rbx), %rdx
movq (%rdx,%rax,8), %rdx
movsd %xmm0, (%rdx,%rcx,8)
incq %rcx
jmp 0x11bb4
cmpq $0x0, 0x20(%rbx)
je 0x11c33
xorl %ecx, %ecx
cmpq %rcx, %r12
je 0x11c33
movq 0x68(%rbx), %rdx
movq (%rdx,%rax,8), %rdx
movq 0xe0(%rbx), %rsi
movq (%rsi,%rax,8), %rsi
movsd (%rsi,%rcx,8), %xmm0
mulsd %xmm1, %xmm0
subsd (%rdx,%rcx,8), %xmm0
movq 0xc8(%rbx), %rdx
movq (%rdx,%rax,8), %rdx
movsd %xmm0, (%rdx,%rcx,8)
incq %rcx
jmp 0x11bf8
incq %rax
jmp 0x11b76
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x8f0e
movq 0x88(%r14), %rax
movsd 0x968(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movl 0xe8(%rbx), %esi
movq 0xf0(%rbx), %rdx
callq 0xe400
movsd %xmm0, 0x30(%rsp)
pushq $0x5
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x878c
pushq $0x9
popq %r15
movq %rbx, %rdi
movl %r15d, %esi
callq 0x878c
pushq $0x1
popq %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x88b6
pushq $0x3
popq %rsi
movq %rbx, %rdi
movl %r15d, %edx
callq 0x88b6
xorpd %xmm2, %xmm2
xorl %eax, %eax
cmpq %r13, %rax
je 0x11d49
cmpq $0x0, 0x10(%rbx)
je 0x11cd9
movq 0x58(%rbx), %rcx
movq 0xb8(%rbx), %rdx
movsd (%rcx,%rax,8), %xmm0
mulsd (%rdx,%rax,8), %xmm0
addsd %xmm0, %xmm2
cmpq $0x0, 0x18(%rbx)
je 0x11d0d
xorl %ecx, %ecx
cmpq %rcx, %r13
je 0x11d0d
movq 0x60(%rbx), %rdx
movq 0xc0(%rbx), %rsi
movq (%rdx,%rax,8), %rdx
movsd (%rdx,%rcx,8), %xmm0
movq (%rsi,%rax,8), %rdx
mulsd (%rdx,%rcx,8), %xmm0
addsd %xmm0, %xmm2
incq %rcx
jmp 0x11ce2
cmpq $0x0, 0x20(%rbx)
je 0x11d41
xorl %ecx, %ecx
cmpq %rcx, %r12
je 0x11d41
movq 0x68(%rbx), %rdx
movq 0xc8(%rbx), %rsi
movq (%rdx,%rax,8), %rdx
movsd (%rdx,%rcx,8), %xmm0
movq (%rsi,%rax,8), %rdx
mulsd (%rdx,%rcx,8), %xmm0
addsd %xmm0, %xmm2
incq %rcx
jmp 0x11d16
incq %rax
jmp 0x11cb0
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x1ab8d(%rip), %xmm1    # 0x2c8e8
xorl %ebp, %ebp
movsbl 0x4(%rsp), %eax
movl %eax, 0x4(%rsp)
movsbl (%rsp), %eax
movl %eax, (%rsp)
xorl %eax, %eax
xorl %r15d, %r15d
xorpd %xmm6, %xmm6
movsd 0x20(%rsp), %xmm5
movsd %xmm2, 0x38(%rsp)
movsd %xmm1, 0x18(%rsp)
testb $0x1, %al
jne 0x12102
movq 0x88(%r14), %rax
ucomisd 0x970(%rax), %xmm5
jbe 0x122ee
xorl %eax, %eax
cmpq %r13, %rax
je 0x11e66
movq 0x10(%rbx), %rcx
testq %rcx, %rcx
je 0x11dda
movq 0xa0(%rbx), %rdx
movq 0xb8(%rbx), %rsi
movsd (%rsi,%rax,8), %xmm0
mulsd %xmm5, %xmm0
addsd (%rdx,%rax,8), %xmm0
movsd %xmm0, (%rcx,%rax,8)
movq 0x18(%rbx), %rcx
testq %rcx, %rcx
je 0x11e1c
xorl %edx, %edx
cmpq %rdx, %r13
je 0x11e1c
movq 0xa8(%rbx), %rsi
movq 0xc0(%rbx), %rdi
movq (%rsi,%rax,8), %rsi
movq (%rdi,%rax,8), %rdi
movsd (%rdi,%rdx,8), %xmm0
mulsd %xmm5, %xmm0
addsd (%rsi,%rdx,8), %xmm0
movq (%rcx,%rax,8), %rsi
movsd %xmm0, (%rsi,%rdx,8)
incq %rdx
jmp 0x11de5
movq 0x20(%rbx), %rcx
testq %rcx, %rcx
je 0x11e5e
xorl %edx, %edx
cmpq %rdx, %r12
je 0x11e5e
movq 0xb0(%rbx), %rsi
movq 0xc8(%rbx), %rdi
movq (%rsi,%rax,8), %rsi
movq (%rdi,%rax,8), %rdi
movsd (%rdi,%rdx,8), %xmm0
mulsd %xmm5, %xmm0
addsd (%rsi,%rdx,8), %xmm0
movq (%rcx,%rax,8), %rsi
movsd %xmm0, (%rsi,%rdx,8)
incq %rdx
jmp 0x11e27
incq %rax
jmp 0x11da7
cmpb $0x0, 0x80(%r14)
movsd %xmm5, 0x20(%rsp)
je 0x11f1c
cmpb $0x0, 0xf9(%rbx)
movq 0x10(%rbx), %rdi
je 0x11f20
testq %rdi, %rdi
je 0x11ea0
movq 0x50(%r14), %rsi
movq 0x68(%r14), %rdx
movl (%rsp), %ecx
callq 0x5d80
xorl %r15d, %r15d
cmpq %r15, %r13
je 0x11f65
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x11ee1
movq (%rax,%r15,8), %rdi
cmpb $0x0, 0x80(%r14)
movq 0x58(%r14), %rax
cmoveq %rbp, %rax
movq (%rax,%r15,8), %rsi
movq 0x70(%r14), %rax
cmoveq %rbp, %rax
movq (%rax,%r15,8), %rdx
movl (%rsp), %ecx
callq 0x5d80
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x11f17
movq (%rax,%r15,8), %rdi
cmpb $0x0, 0x80(%r14)
movq 0x60(%r14), %rax
cmoveq %rbp, %rax
movq (%rax,%r15,8), %rsi
movq 0x78(%r14), %rax
cmoveq %rbp, %rax
movq (%rax,%r15,8), %rdx
movl 0x4(%rsp), %ecx
callq 0x5d80
incq %r15
jmp 0x11ea3
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x11f2d
movl (%rsp), %esi
callq 0x5600
xorl %r15d, %r15d
cmpq %r15, %r13
je 0x11f65
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x11f4a
movq (%rax,%r15,8), %rdi
movl (%rsp), %esi
callq 0x5600
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x11f60
movq (%rax,%r15,8), %rdi
movl 0x4(%rsp), %esi
callq 0x5600
incq %r15
jmp 0x11f30
movl 0xe8(%rbx), %esi
movq 0xf0(%rbx), %rdx
movq %r14, %rdi
callq 0xe7b0
movl 0xe8(%rbx), %esi
movq 0xf0(%rbx), %rdx
callq 0xe400
movsd %xmm0, 0x8(%rsp)
movq (%r14), %rax
movq 0x88(%r14), %rcx
movsd 0x950(%rcx), %xmm0
mulsd 0x20(%rsp), %xmm0
mulsd 0x38(%rsp), %xmm0
addsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq *0x80(%rax)
movq %rbx, %rdi
pushq $0x3
popq %rsi
callq 0x8f0e
xorpd %xmm0, %xmm0
xorl %eax, %eax
movsd 0x18(%rsp), %xmm4
cmpq %r13, %rax
je 0x12078
cmpq $0x0, 0x10(%rbx)
je 0x12008
movq 0x58(%rbx), %rcx
movq 0xb8(%rbx), %rdx
movsd (%rdx,%rax,8), %xmm1
mulsd (%rcx,%rax,8), %xmm1
addsd %xmm1, %xmm0
cmpq $0x0, 0x18(%rbx)
je 0x1203c
xorl %ecx, %ecx
cmpq %rcx, %r13
je 0x1203c
movq 0x60(%rbx), %rdx
movq 0xc0(%rbx), %rsi
movq (%rsi,%rax,8), %rsi
movsd (%rsi,%rcx,8), %xmm1
movq (%rdx,%rax,8), %rdx
mulsd (%rdx,%rcx,8), %xmm1
addsd %xmm1, %xmm0
incq %rcx
jmp 0x12011
cmpq $0x0, 0x20(%rbx)
je 0x12070
xorl %ecx, %ecx
cmpq %rcx, %r12
je 0x12070
movq 0x68(%rbx), %rdx
movq 0xc8(%rbx), %rsi
movq (%rsi,%rax,8), %rsi
movsd (%rsi,%rcx,8), %xmm1
movq (%rdx,%rax,8), %rdx
mulsd (%rdx,%rcx,8), %xmm1
addsd %xmm1, %xmm0
incq %rcx
jmp 0x12045
incq %rax
jmp 0x11fdf
movsd 0x8(%rsp), %xmm6
movsd 0x40(%rsp), %xmm7
ucomisd %xmm6, %xmm7
setae %al
movq 0x88(%r14), %rcx
movsd 0x958(%rcx), %xmm3
mulsd 0x38(%rsp), %xmm3
ucomisd %xmm3, %xmm0
setae %r15b
ucomisd 0x1a838(%rip), %xmm4    # 0x2c8e8
setnp %dl
sete %sil
andb %dl, %sil
movsd 0x20(%rsp), %xmm5
movapd %xmm5, %xmm1
movapd %xmm6, %xmm2
testb %sil, %al
jne 0x120d7
movapd %xmm4, %xmm1
movsd 0x10(%rsp), %xmm2
ucomisd %xmm6, %xmm7
jb 0x120eb
ucomisd %xmm3, %xmm0
movsd 0x1a807(%rip), %xmm0    # 0x2c8f0
jae 0x120f3
movsd 0x960(%rcx), %xmm0
divsd %xmm0, %xmm5
movsd %xmm2, 0x10(%rsp)
jmp 0x11d82
pushq $0x9
popq %rsi
pushq $0x3
popq %rdx
movq %rbx, %rdi
movsd %xmm6, 0x8(%rsp)
callq 0x88b6
testb $0x1, %r15b
jne 0x1242a
xorl %ebp, %ebp
xorpd %xmm2, %xmm2
movsd 0x1a7c2(%rip), %xmm3    # 0x2c8f0
movsd 0x18(%rsp), %xmm1
cmpq %r13, %rbp
je 0x12315
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x12183
movq 0xa0(%rbx), %rcx
movq 0xb8(%rbx), %rdx
movsd (%rdx,%rbp,8), %xmm0
mulsd %xmm1, %xmm0
addsd (%rcx,%rbp,8), %xmm0
movsd %xmm0, (%rax,%rbp,8)
ucomisd %xmm0, %xmm2
ja 0x12173
ucomisd %xmm3, %xmm0
jbe 0x12183
ucomisd %xmm2, %xmm0
jbe 0x12183
ucomisd %xmm0, %xmm3
ja 0x122bb
cmpq $0x0, 0x18(%rbx)
je 0x1221b
xorl %r15d, %r15d
cmpq %r15, %r13
je 0x1221b
movq 0x18(%rbx), %rax
movq 0xa8(%rbx), %rcx
movq (%rcx,%rbp,8), %rcx
movq 0xc0(%rbx), %rdx
movq (%rdx,%rbp,8), %rdx
movsd (%rdx,%r15,8), %xmm0
mulsd %xmm1, %xmm0
addsd (%rcx,%r15,8), %xmm0
movq (%rax,%rbp,8), %rax
movsd %xmm0, (%rax,%r15,8)
ucomisd %xmm0, %xmm2
ja 0x121da
ucomisd %xmm3, %xmm0
jbe 0x121e6
ucomisd %xmm2, %xmm0
jbe 0x121e6
ucomisd %xmm0, %xmm3
ja 0x121eb
incq %r15
jmp 0x12191
movq 0x26de6(%rip), %rax     # 0x38fd8
movq (%rax), %rcx
leaq 0x1b5c1(%rip), %rdi     # 0x2d7bd
pushq $0x2b
popq %rsi
pushq $0x1
popq %rdx
callq 0x44b0
movsd 0x1a6e1(%rip), %xmm3    # 0x2c8f0
xorpd %xmm2, %xmm2
movsd 0x18(%rsp), %xmm1
jmp 0x121e6
cmpq $0x0, 0x20(%rbx)
je 0x122b3
xorl %r15d, %r15d
cmpq %r15, %r12
je 0x122b3
movq 0x20(%rbx), %rax
movq 0xb0(%rbx), %rcx
movq (%rcx,%rbp,8), %rcx
movq 0xc8(%rbx), %rdx
movq (%rdx,%rbp,8), %rdx
movsd (%rdx,%r15,8), %xmm0
mulsd %xmm1, %xmm0
addsd (%rcx,%r15,8), %xmm0
movq (%rax,%rbp,8), %rax
movsd %xmm0, (%rax,%r15,8)
ucomisd %xmm0, %xmm2
ja 0x12272
ucomisd %xmm3, %xmm0
jbe 0x1227e
ucomisd %xmm2, %xmm0
jbe 0x1227e
ucomisd %xmm0, %xmm3
ja 0x12283
incq %r15
jmp 0x12229
movq 0x26d4e(%rip), %rax     # 0x38fd8
movq (%rax), %rcx
leaq 0x1b555(%rip), %rdi     # 0x2d7e9
pushq $0x2b
popq %rsi
pushq $0x1
popq %rdx
callq 0x44b0
movsd 0x1a649(%rip), %xmm3    # 0x2c8f0
xorpd %xmm2, %xmm2
movsd 0x18(%rsp), %xmm1
jmp 0x1227e
incq %rbp
jmp 0x12134
movq 0x26d16(%rip), %rax     # 0x38fd8
movq (%rax), %rcx
leaq 0x1b4c4(%rip), %rdi     # 0x2d790
pushq $0x2c
popq %rsi
pushq $0x1
popq %rdx
callq 0x44b0
movsd 0x1a611(%rip), %xmm3    # 0x2c8f0
xorpd %xmm2, %xmm2
movsd 0x18(%rsp), %xmm1
jmp 0x12183
pushq $0x9
popq %rsi
pushq $0x3
popq %rdx
movq %rbx, %rdi
callq 0x88b6
pushq $0x5
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x88b6
movsd 0x30(%rsp), %xmm0
jmp 0x12424
cmpb $0x1, 0xf8(%rbx)
jne 0x1241e
cmpb $0x0, 0x80(%r14)
je 0x123d5
cmpb $0x0, 0xf9(%rbx)
movq 0x10(%rbx), %rdi
je 0x123d9
testq %rdi, %rdi
je 0x12356
movq 0x50(%r14), %rsi
movq 0x68(%r14), %rdx
movl (%rsp), %ecx
callq 0x5d80
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpq %r15, %r13
je 0x1241e
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x1239a
movq (%rax,%r15,8), %rdi
cmpb $0x0, 0x80(%r14)
movq 0x58(%r14), %rax
cmoveq %r12, %rax
movq (%rax,%r15,8), %rsi
movq 0x70(%r14), %rax
cmoveq %r12, %rax
movq (%rax,%r15,8), %rdx
movl (%rsp), %ecx
callq 0x5d80
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x123d0
movq (%rax,%r15,8), %rdi
cmpb $0x0, 0x80(%r14)
movq 0x60(%r14), %rax
cmoveq %r12, %rax
movq (%rax,%r15,8), %rsi
movq 0x78(%r14), %rax
cmoveq %r12, %rax
movq (%rax,%r15,8), %rdx
movl 0x4(%rsp), %ecx
callq 0x5d80
incq %r15
jmp 0x1235c
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x123e6
movl (%rsp), %esi
callq 0x5600
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x1241e
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x12403
movq (%rax,%r14,8), %rdi
movl (%rsp), %esi
callq 0x5600
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x12419
movq (%rax,%r14,8), %rdi
movl 0x4(%rsp), %esi
callq 0x5600
incq %r14
jmp 0x123e9
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
pushq $0x5
popq %rsi
movq %rbx, %rdi
callq 0x883c
pushq $0x9
popq %rsi
movq %rbx, %rdi
callq 0x883c
movsd 0x8(%rsp), %xmm0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop