// File: myudelson[P]hmm-scalable/HMMProblem.cpp
// Function: HMMProblem::doLinearStep(FitBit*)
NUMBER HMMProblem::doLinearStep(FitBit *fb) {
	NPAR i,j,m;
    NPAR nS = fb->nS, nO = this->p->nO;
    fb->doLog10ScaleGentleByRow(FBS_GRAD);
	
    NCAT xndat = fb->xndat;
    struct data **x_data = fb->x_data;
    fb->init(FBS_PARcopy);
    fb->init(FBS_GRADcopy);
    
	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(xndat, x_data);
	NUMBER f_xkplus1 = 0;
	
    fb->copy(FBS_PAR, FBS_PARcopy); // save original parameters
    fb->copy(FBS_GRAD, FBS_GRADcopy); // save original gradient
	// compute p_k * -p_k
	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->gradPI[i];
		if(fb->A  != NULL) for(j=0; j<nS; j++) p_k_by_neg_p_k -= fb->gradA[i][j]*fb->gradA[i][j];
		if(fb->B  != NULL) for(m=0; m<nO; m++) p_k_by_neg_p_k -= fb->gradB[i][m]*fb->gradB[i][m];
	}
    
	int iter = 0; // limit iter steps to 20, via ArmijoMinStep (now 10)
    while( !(compliesArmijo && compliesWolfe2) && e > this->p->ArmijoMinStep) {
		// update
		for(i=0; i<nS; i++) {
            if(fb->pi != NULL) {
                fb->pi[i] = fb->PIcopy[i] - e * fb->gradPIcopy[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->gradAcopy[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->gradBcopy[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);
                }
            }
        }
        
		// recompute alpha and p(O|param)
		computeAlphaAndPOParam(xndat, x_data);
		// compute f(x_{k+1})
		f_xkplus1 = HMMProblem::getSumLogPOPara(xndat, 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;
        // NDAT ndat = computeGradients(fb);
        fb->doLog10ScaleGentleByRow(FBS_GRAD);
        for(i=0; i<nS; i++)
        {
            if(fb->pi != NULL) p_k_by_neg_p_kp1 -= fb->gradPIcopy[i]*fb->gradPI[i];
            if(fb->A  != NULL) for(j=0; j<nS; j++) p_k_by_neg_p_kp1 -= fb->gradAcopy[i][j]*fb->gradA[i][j];
            if(fb->B  != NULL) for(m=0; m<nO; m++) p_k_by_neg_p_kp1 -= fb->gradBcopy[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 // unnecessary
    
    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; // return the first Armijo-compliant e
        f_xkplus1 = f_xkplus1_Armijo; // return the first Armijo-compliant f_xkplus1
        // create new versions of FBS_PAR using e_Armijo as a step
        fb->copy(FBS_GRADcopy, FBS_GRAD); // return the old gradient
        // update
        for(i=0; i<nS; i++) {
            if(fb->pi != NULL) {
                fb->pi[i] = fb->PIcopy[i] - e * fb->gradPIcopy[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->gradAcopy[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->gradBcopy[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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rcx
movb 0x1(%rcx), %cl
movb %cl, -0x14(%rbp)
movq 0x88(%rax), %rax
movb 0x8b9(%rax), %al
movb %al, -0x15(%rbp)
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0xef90
movq -0x10(%rbp), %rax
movl 0xe8(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0xf0(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movl $0x5, %esi
callq 0xdcb0
movq -0x10(%rbp), %rdi
movl $0x9, %esi
callq 0xdcb0
movq -0x78(%rbp), %rdi
movq 0x88(%rdi), %rax
movsd 0x968(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movb $0x0, -0x31(%rbp)
movb $0x0, -0x32(%rbp)
movsd 0x2a315(%rip), %xmm0    # 0x4fa18
movsd %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x1a9f0
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x5, %edx
callq 0xe4d0
movq -0x10(%rbp), %rdi
movl $0x3, %esi
movl $0x9, %edx
callq 0xe4d0
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movb $0x0, -0x11(%rbp)
movsbl -0x11(%rbp), %eax
movsbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x258de
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x257c3
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x60(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x25849
movb $0x0, -0x12(%rbp)
movsbl -0x12(%rbp), %eax
movsbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x25847
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x60(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movb -0x12(%rbp), %al
addb $0x1, %al
movb %al, -0x12(%rbp)
jmp 0x257d2
jmp 0x25849
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x258cf
movb $0x0, -0x13(%rbp)
movsbl -0x13(%rbp), %eax
movsbl -0x15(%rbp), %ecx
cmpl %ecx, %eax
jge 0x258cd
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x60(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movb -0x13(%rbp), %al
addb $0x1, %al
movb %al, -0x13(%rbp)
jmp 0x25858
jmp 0x258cf
jmp 0x258d1
movb -0x11(%rbp), %al
addb $0x1, %al
movb %al, -0x11(%rbp)
jmp 0x2575b
movl $0x0, -0x64(%rbp)
testb $0x1, -0x31(%rbp)
je 0x258f6
xorl %eax, %eax
testb $0x1, -0x32(%rbp)
movb %al, -0x79(%rbp)
jne 0x25914
movq -0x78(%rbp), %rax
movsd -0x30(%rbp), %xmm0
movq 0x88(%rax), %rax
ucomisd 0x970(%rax), %xmm0
seta %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x25920
jmp 0x261a3
movb $0x0, -0x11(%rbp)
movsbl -0x11(%rbp), %eax
movsbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x25cec
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x25a2b
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movsbq -0x11(%rbp), %rcx
xorps %xmm0, %xmm0
ucomisd (%rax,%rcx,8), %xmm0
ja 0x259da
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x2a034(%rip), %xmm1    # 0x4fa08
ucomisd %xmm1, %xmm0
jbe 0x25a29
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x25a29
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd 0x29ffe(%rip), %xmm0    # 0x4fa08
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x25a29
movq 0x355c0(%rip), %rax     # 0x5afd8
movq (%rax), %rdi
leaq 0x2adb2(%rip), %rsi     # 0x507d4
movb $0x0, %al
callq 0x5440
jmp 0x25a2b
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x25b84
movb $0x0, -0x12(%rbp)
movsbl -0x12(%rbp), %eax
movsbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x25b82
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
xorps %xmm0, %xmm0
ucomisd (%rax,%rcx,8), %xmm0
ja 0x25b12
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x29efc(%rip), %xmm1    # 0x4fa08
ucomisd %xmm1, %xmm0
jbe 0x25b73
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x25b73
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd 0x29eb4(%rip), %xmm0    # 0x4fa08
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x25b73
movq 0x35476(%rip), %rax     # 0x5afd8
movq (%rax), %rdi
leaq 0x2ac95(%rip), %rsi     # 0x50801
movb $0x0, %al
callq 0x5440
jmp 0x25b75
movb -0x12(%rbp), %al
addb $0x1, %al
movb %al, -0x12(%rbp)
jmp 0x25a3e
jmp 0x25b84
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x25cdd
movb $0x0, -0x13(%rbp)
movsbl -0x13(%rbp), %eax
movsbl -0x15(%rbp), %ecx
cmpl %ecx, %eax
jge 0x25cdb
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
xorps %xmm0, %xmm0
ucomisd (%rax,%rcx,8), %xmm0
ja 0x25c6b
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x29da3(%rip), %xmm1    # 0x4fa08
ucomisd %xmm1, %xmm0
jbe 0x25ccc
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x25ccc
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd 0x29d5b(%rip), %xmm0    # 0x4fa08
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x25ccc
movq 0x3531d(%rip), %rax     # 0x5afd8
movq (%rax), %rdi
leaq 0x2ab68(%rip), %rsi     # 0x5082d
movb $0x0, %al
callq 0x5440
jmp 0x25cce
movb -0x13(%rbp), %al
addb $0x1, %al
movb %al, -0x13(%rbp)
jmp 0x25b97
jmp 0x25cdd
jmp 0x25cdf
movb -0x11(%rbp), %al
addb $0x1, %al
movb %al, -0x11(%rbp)
jmp 0x25924
movq -0x10(%rbp), %rax
movsbl 0xf8(%rax), %eax
cmpl $0x1, %eax
jne 0x25ee8
movq -0x78(%rbp), %rdi
callq 0x1a4e0
testb $0x1, %al
jne 0x25d0f
jmp 0x25d23
movq -0x10(%rbp), %rax
movsbl 0xf9(%rax), %eax
cmpl $0x0, %eax
jne 0x25daa
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x25d3f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movsbl -0x14(%rbp), %esi
callq 0x7980
movb $0x0, -0x11(%rbp)
movsbl -0x11(%rbp), %eax
movsbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x25da5
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x25d74
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movsbl -0x14(%rbp), %esi
callq 0x7980
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x25d99
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movsbl -0x15(%rbp), %esi
callq 0x7980
jmp 0x25d9b
movb -0x11(%rbp), %al
addb $0x1, %al
movb %al, -0x11(%rbp)
jmp 0x25d43
jmp 0x25ee6
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x25df7
movq -0x78(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x90(%rbp)
callq 0x1a6b0
movq -0x78(%rbp), %rdi
movq %rax, -0x88(%rbp)
callq 0x1a770
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rsi
movq %rax, %rdx
movsbl -0x14(%rbp), %ecx
callq 0x87e0
movb $0x0, -0x11(%rbp)
movsbl -0x11(%rbp), %eax
movsbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x25ee4
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x25e70
movq -0x78(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xa0(%rbp)
callq 0x1a6f0
movq -0x78(%rbp), %rdi
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x98(%rbp)
callq 0x1a7b0
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rsi
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movsbl -0x14(%rbp), %ecx
callq 0x87e0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x25ed5
movq -0x78(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xb0(%rbp)
callq 0x1a730
movq -0x78(%rbp), %rdi
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xa8(%rbp)
callq 0x1a7f0
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movsbl -0x15(%rbp), %ecx
callq 0x87e0
jmp 0x25ed7
movb -0x11(%rbp), %al
addb $0x1, %al
movb %al, -0x11(%rbp)
jmp 0x25dfb
jmp 0x25ee6
jmp 0x25ee8
movq -0x78(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x1b0c0
movq -0x78(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x1a9f0
movq -0x78(%rbp), %rax
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
movq 0x88(%rax), %rax
movsd 0x950(%rax), %xmm0
mulsd -0x30(%rbp), %xmm0
movsd -0x60(%rbp), %xmm3
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
setae %al
andb $0x1, %al
movb %al, -0x31(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0xef90
movb $0x0, -0x11(%rbp)
movsbl -0x11(%rbp), %eax
movsbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x260ee
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x25fcd
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x70(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x26056
movb $0x0, -0x12(%rbp)
movsbl -0x12(%rbp), %eax
movsbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x26054
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x70(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movb -0x12(%rbp), %al
addb $0x1, %al
movb %al, -0x12(%rbp)
jmp 0x25fdc
jmp 0x26056
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x260df
movb $0x0, -0x13(%rbp)
movsbl -0x13(%rbp), %eax
movsbl -0x15(%rbp), %ecx
cmpl %ecx, %eax
jge 0x260dd
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x70(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movb -0x13(%rbp), %al
addb $0x1, %al
movb %al, -0x13(%rbp)
jmp 0x26065
jmp 0x260df
jmp 0x260e1
movb -0x11(%rbp), %al
addb $0x1, %al
movb %al, -0x11(%rbp)
jmp 0x25f62
movq -0x78(%rbp), %rax
movsd -0x70(%rbp), %xmm0
movq 0x88(%rax), %rax
movsd 0x958(%rax), %xmm1
mulsd -0x60(%rbp), %xmm1
ucomisd %xmm1, %xmm0
setae %al
andb $0x1, %al
movb %al, -0x32(%rbp)
testb $0x1, -0x31(%rbp)
je 0x26146
movsd -0x40(%rbp), %xmm0
movsd 0x298ee(%rip), %xmm1    # 0x4fa18
ucomisd %xmm1, %xmm0
jne 0x26146
jp 0x26146
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
testb $0x1, -0x31(%rbp)
je 0x26164
testb $0x1, -0x32(%rbp)
je 0x26164
movsd 0x298ae(%rip), %xmm0    # 0x4fa08
movsd %xmm0, -0xb8(%rbp)
jmp 0x2617f
movq -0x78(%rbp), %rax
movq 0x88(%rax), %rax
movsd 0x960(%rax), %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0xb8(%rbp), %xmm1
movsd -0x30(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x258e5
testb $0x1, -0x31(%rbp)
jne 0x261d3
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl $0x5, %esi
movl $0x1, %edx
callq 0xe4d0
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x267da
testb $0x1, -0x31(%rbp)
je 0x267d8
testb $0x1, -0x32(%rbp)
jne 0x267d8
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movl $0x9, %esi
movl $0x3, %edx
callq 0xe4d0
movb $0x0, -0x11(%rbp)
movsbl -0x11(%rbp), %eax
movsbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x265da
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x26319
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movsbq -0x11(%rbp), %rcx
xorps %xmm0, %xmm0
ucomisd (%rax,%rcx,8), %xmm0
ja 0x262c8
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x29746(%rip), %xmm1    # 0x4fa08
ucomisd %xmm1, %xmm0
jbe 0x26317
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x26317
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movsbq -0x11(%rbp), %rcx
movsd 0x29710(%rip), %xmm0    # 0x4fa08
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x26317
movq 0x34cd2(%rip), %rax     # 0x5afd8
movq (%rax), %rdi
leaq 0x2a4c4(%rip), %rsi     # 0x507d4
movb $0x0, %al
callq 0x5440
jmp 0x26319
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x26472
movb $0x0, -0x12(%rbp)
movsbl -0x12(%rbp), %eax
movsbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x26470
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
xorps %xmm0, %xmm0
ucomisd (%rax,%rcx,8), %xmm0
ja 0x26400
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x2960e(%rip), %xmm1    # 0x4fa08
ucomisd %xmm1, %xmm0
jbe 0x26461
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x26461
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd 0x295c6(%rip), %xmm0    # 0x4fa08
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x26461
movq 0x34b88(%rip), %rax     # 0x5afd8
movq (%rax), %rdi
leaq 0x2a3a7(%rip), %rsi     # 0x50801
movb $0x0, %al
callq 0x5440
jmp 0x26463
movb -0x12(%rbp), %al
addb $0x1, %al
movb %al, -0x12(%rbp)
jmp 0x2632c
jmp 0x26472
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x265cb
movb $0x0, -0x13(%rbp)
movsbl -0x13(%rbp), %eax
movsbl -0x15(%rbp), %ecx
cmpl %ecx, %eax
jge 0x265c9
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
xorps %xmm0, %xmm0
ucomisd (%rax,%rcx,8), %xmm0
ja 0x26559
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x294b5(%rip), %xmm1    # 0x4fa08
ucomisd %xmm1, %xmm0
jbe 0x265ba
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x265ba
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x13(%rbp), %rcx
movsd 0x2946d(%rip), %xmm0    # 0x4fa08
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x265ba
movq 0x34a2f(%rip), %rax     # 0x5afd8
movq (%rax), %rdi
leaq 0x2a27a(%rip), %rsi     # 0x5082d
movb $0x0, %al
callq 0x5440
jmp 0x265bc
movb -0x13(%rbp), %al
addb $0x1, %al
movb %al, -0x13(%rbp)
jmp 0x26485
jmp 0x265cb
jmp 0x265cd
movb -0x11(%rbp), %al
addb $0x1, %al
movb %al, -0x11(%rbp)
jmp 0x26212
movq -0x10(%rbp), %rax
movsbl 0xf8(%rax), %eax
cmpl $0x1, %eax
jne 0x267d6
movq -0x78(%rbp), %rdi
callq 0x1a4e0
testb $0x1, %al
jne 0x265fd
jmp 0x26611
movq -0x10(%rbp), %rax
movsbl 0xf9(%rax), %eax
cmpl $0x0, %eax
jne 0x26698
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x2662d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movsbl -0x14(%rbp), %esi
callq 0x7980
movb $0x0, -0x11(%rbp)
movsbl -0x11(%rbp), %eax
movsbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x26693
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x26662
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movsbl -0x14(%rbp), %esi
callq 0x7980
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x26687
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movsbl -0x15(%rbp), %esi
callq 0x7980
jmp 0x26689
movb -0x11(%rbp), %al
addb $0x1, %al
movb %al, -0x11(%rbp)
jmp 0x26631
jmp 0x267d4
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x266e5
movq -0x78(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xc8(%rbp)
callq 0x1a6b0
movq -0x78(%rbp), %rdi
movq %rax, -0xc0(%rbp)
callq 0x1a770
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
movq %rax, %rdx
movsbl -0x14(%rbp), %ecx
callq 0x87e0
movb $0x0, -0x11(%rbp)
movsbl -0x11(%rbp), %eax
movsbl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x267d2
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x2675e
movq -0x78(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xd8(%rbp)
callq 0x1a6f0
movq -0x78(%rbp), %rdi
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xd0(%rbp)
callq 0x1a7b0
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rsi
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movsbl -0x14(%rbp), %ecx
callq 0x87e0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x267c3
movq -0x78(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xe8(%rbp)
callq 0x1a730
movq -0x78(%rbp), %rdi
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xe0(%rbp)
callq 0x1a7f0
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movsbl -0x15(%rbp), %ecx
callq 0x87e0
jmp 0x267c5
movb -0x11(%rbp), %al
addb $0x1, %al
movb %al, -0x11(%rbp)
jmp 0x266e9
jmp 0x267d4
jmp 0x267d6
jmp 0x267d8
jmp 0x267da
movq -0x10(%rbp), %rdi
movl $0x5, %esi
callq 0xe140
movq -0x10(%rbp), %rdi
movl $0x9, %esi
callq 0xe140
movsd -0x58(%rbp), %xmm0
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)