// File: /workspace/github_cpp_makefile_star2_O3/myudelson[P]hmm-scalable/HMMProblemPiGK.cpp
// Function: HMMProblemPiGK::GradientDescent()
NUMBER HMMProblemPiGK::GradientDescent() {
	NCAT k, g, /*ki, gi, nX, */x;
    NCAT nK = this->p->nK, nG = this->p->nG;

	//
	// fit all as 1 skill first, set group gradients to 0, and do not fit them
	//
	if(this->p->single_skill>0) {
        FitBit *fb = new FitBit(this->p->nS, this->p->nO, this->p->nK, this->p->nG, this->p->tol, this->p->tol_mode);
        fb->link( HMMProblem::getPI(0), HMMProblem::getA(0), HMMProblem::getB(0), this->p->nSeq, this->p->k_data);// link skill 0 (we'll copy fit parameters to others
        if(this->p->block_fitting[0]!=0) fb->pi = NULL;
        if(this->p->block_fitting[1]!=0) fb->A  = NULL;
        if(this->p->block_fitting[2]!=0) fb->B  = NULL;
        
        fb->init(FBS_PARm1);
        fb->init(FBS_PARm2);
        fb->init(FBS_GRAD);
        if(this->p->solver==METHOD_CGD) {
            fb->init(FBS_GRADm1);
            fb->init(FBS_DIRm1);
        }
        
        NCAT* original_ks = Calloc(NCAT, (size_t)this->p->nSeq);
        for(x=0; x<this->p->nSeq; x++) { original_ks[x] = this->p->all_data[x].k; this->p->all_data[x].k = 0; } // save progonal k's
        FitResult fr = GradientDescentBit(fb);
        for(x=0; x<this->p->nSeq; x++) { this->p->all_data[x].k = original_ks[x]; } // restore original k's
        free(original_ks);
        if( !this->p->quiet )
            printf("single skill iter#%3d p(O|param)= %15.7f >> %15.7f, conv=%d\n", fr.iter,fr.pO0,fr.pO,fr.conv);
        delete fb;
    }
	//
	// Main fit
	//
    if( this->p->single_skill!=2 ) { // if not "force single skill"
        NPAR first_iteration_qualify = this->p->first_iteration_qualify; // at what iteration, qualification for skill/group convergence should start
        NPAR iterations_to_qualify = this->p->iterations_to_qualify; // how many consecutive iterations necessary for skill/group to qualify as converged
        NCAT iterations_limit = this->p->iterations_limit; // how many consecutive iterations to do, negat3s prior two parameters
        NCAT* iter_qual_skill = Calloc(NCAT, (size_t)nK);
        NCAT* iter_qual_group = Calloc(NCAT, (size_t)nG);
        NCAT* iter_fail_skill = Calloc(NCAT, (size_t)nK); // counting concecutive number of failures to converge for skills
        NCAT* iter_fail_group = Calloc(NCAT, (size_t)nG); // counting concecutive number of failures to converge for groups
        int skip_k = 0, skip_g = 0;

        int i = 0; // count runs
//        int parallel_now = this->p->parallel==1; //PAR
//        #pragma omp parallel if(parallel_now) shared(iter_qual_group,iter_qual_skill,iter_fail_skill,iter_fail_group)//PAR
//        {//PAR
        while( (skip_k<nK || skip_g<nG) && i<iterations_limit) {
            //
            // Skills first
            //
            
            if(skip_k<nK) {
//                #pragma omp for schedule(dynamic) //PAR
                for(k=0; k<nK; k++) { // for all A,B-by-skill
                    if(iter_qual_skill[k]==iterations_to_qualify || iter_fail_skill[k]==iterations_to_qualify)
                        continue;
                    FitBit *fb = new FitBit(this->p->nS, this->p->nO, this->p->nK, this->p->nG, this->p->tol, this->p->tol_mode);
                    // link
                    fb->link( HMMProblem::getPI(k), HMMProblem::getA(k), HMMProblem::getB(k), this->p->k_numg[k], this->p->k_g_data[k]);// link skill 0 (we'll copy fit parameters to others
                    if(this->p->block_fitting[0]!=0) fb->pi = NULL;
                    if(this->p->block_fitting[1]!=0) fb->A  = NULL;
                    if(this->p->block_fitting[2]!=0) fb->B  = NULL;

                    fb->Cslice = 0;
                    fb->init(FBS_PARm1);
                    fb->init(FBS_PARm2);
                    fb->init(FBS_GRAD);
                    if(this->p->solver==METHOD_CGD) {
                        fb->init(FBS_GRADm1);
                        fb->init(FBS_DIRm1);
                    }
                    FitResult fr = GradientDescentBit(fb);

					// count number of concecutive failures
					if(fr.iter==this->p->maxiter) {
						iter_fail_skill[k]++;
					} else {
						iter_fail_skill[k]=0;
					}
					
					// decide on convergence
                    if(i>=first_iteration_qualify || fb->xndat==0) {
                        if(fr.iter==1 /*e<=this->p->tol*/ || skip_g==nG || fb->xndat==0) { // converged quick, or don't care (others all converged
                            iter_qual_skill[k]++;
                            if(fb->xndat==0) {
                                iter_qual_skill[k]=iterations_to_qualify;
                                fr.conv = 1;
                            }
                            if(iter_qual_skill[k]==iterations_to_qualify || skip_g==nG) {// criterion met, or don't care (others all converged)
                                if(skip_g==nG) iter_qual_skill[k]=iterations_to_qualify; // G not changing anymore
//                                #pragma omp critical(update_skip_k)//PAR
//                                {//PAR
                                    skip_k++;
//                                }//PAR
                                if( !this->p->quiet && ( /*(!conv && iter<this->p->maxiter) ||*/ (fr.conv || fr.iter==this->p->maxiter) )) {
                                    printf("run %2d skipK %4d skill %4d iter#%3d p(O|param)= %15.7f >> %15.7f, conv=%d\n",i,skip_k,k,fr.iter,fr.pO0,fr.pO,fr.conv);
                                }
                            }
                        }
                        else
                            iter_qual_skill[k]=0;
                    } // decide on convergence
                    delete fb;
                } // for all skills
            }
            //
            // PIg second
            //
            if(skip_g<nG && i<iterations_limit){
//                #pragma omp for schedule(dynamic)//PAR
                for(g=0; g<nG; g++) { // for all PI-by-user
                    if(iter_qual_group[g]==iterations_to_qualify || iter_fail_group[g]==iterations_to_qualify)
                        continue;
                    FitBit *fb = new FitBit(this->p->nS, this->p->nO, this->p->nK, this->p->nG, this->p->tol, this->p->tol_mode);
                    // link
                    fb->link(this->getPIg(g), NULL, NULL, this->p->g_numk[g], this->p->g_k_data[g]);
                    fb->observe_non01_boundaries=0;
                    if(this->p->block_fitting[0]!=0) fb->pi = NULL;
                    if(this->p->block_fitting[1]!=0) fb->A  = NULL;
                    if(this->p->block_fitting[2]!=0) fb->B  = NULL;

                    fb->Cslice = 1;
                    fb->init(FBS_PARm1);
                    fb->init(FBS_PARm2);
                    fb->init(FBS_GRAD);
                    if(this->p->solver==METHOD_CGD) {
                        fb->init(FBS_GRADm1);
                        fb->init(FBS_DIRm1);
                    }
                    FitResult fr = GradientDescentBit(fb);
					
					// count number of concecutive failures
					if(fr.iter==this->p->maxiter) {
						iter_fail_group[g]++;
					} else {
						iter_fail_group[g]=0;
					}
					
                    // decide on convergence
                    if(i>=first_iteration_qualify || fb->xndat==0) { //can qualify or  student had no skill labelled rows
                        if(fr.iter==1 /*e<=this->p->tol*/ || skip_k==nK || fb->xndat==0) { // converged quick, or don't care (others all converged), or
                            iter_qual_group[g]++;
                            if(fb->xndat==0) {
                                iter_qual_group[g]=iterations_to_qualify;
                                fr.conv = 1;
                            }
                            if(iter_qual_group[g]==iterations_to_qualify || skip_k==nK) {// criterion met, or don't care (others all converged)
                                if(skip_k==nK) iter_qual_group[g]=iterations_to_qualify; // K not changing anymore
//                                #pragma omp critical(update_skip_g)//PAR
//                                {//PAR
                                    skip_g++;
//                                }//PAR
                                if( !this->p->quiet && ( /*(!conv && iter<this->p->maxiter) ||*/ (fr.conv || fr.iter==this->p->maxiter) )) {
                                    printf("run %2d skipG %4d group %4d iter#%3d p(O|param)= %15.7f >> %15.7f, conv=%d\n",i,skip_g,g,fr.iter,fr.pO0,fr.pO,fr.conv);
                                }
                            }
                        }
                        else
                            iter_qual_group[g]=0;
                    } // decide on convergence
                    delete fb;
                } // for all groups
            }
//            fr.conv = checkConvergenceBig(fbs, nK+nG, this->p->tol, &crit);
//            
//            computeAlphaAndPOParam(this->p->nSeq, this->p->k_data);
//            ll = HMMProblem::getSumLogPOPara(this->p->nSeq, this->p->k_data);
//            printf("*%i ll=%15.7f, crit=%12.10f\n",i,ll,crit);
//            #pragma omp single//PAR
//            {//PAR
            i++;
//            }//PAR
        }
//        }//PAR
        // recycle qualifications
        if( iter_qual_skill != NULL ) free(iter_qual_skill);
        if( iter_qual_group != NULL) free(iter_qual_group);
        if( iter_fail_skill != NULL ) free(iter_fail_skill);
        if( iter_fail_group != NULL) free(iter_fail_group);

    } // if not "force single skill
        
//    for(x=0;x<nX;x++) delete fbs[x];
//    if(fbs!=NULL) free(fbs);
    
    /*
    if(false){
        NCAT q, x;
        NCAT nQ = this->p->nK + this->p->nG;
        FitBit **fbs = Calloc(FitBit*, (size_t)nQ);
        for(q=0;q<nQ;q++) {
            NCAT xndat;
            struct data** x_data;
            if(q<this->p->nK) { // skills
                x = q;
                xndat = this->p->k_numg[x];
                x_data = this->p->k_g_data[x];
                fbs[q] = new FitBit(this->p->nS, this->p->nO, this->p->nK, this->p->nG, this->p->tol, this->p->tol_mode);
                fbs[q]->link( HMMProblem::getPI(x), HMMProblem::getA(x), HMMProblem::getB(x), xndat, x_data);
            } else { // groups
                x = q - this->p->nK;
                xndat = this->p->g_numk[x];
                x_data = this->p->g_k_data[x];
                fbs[q] = new FitBit(this->p->nS, this->p->nO, this->p->nK, this->p->nG, this->p->tol, this->p->tol_mode);
                fbs[q]->link( this->getPIg(x), NULL, NULL, xndat, x_data);
            }
            fbs[q]->init(FBS_PARm1);
            fbs[q]->init(FBS_GRAD);
            if(this->p->solver==METHOD_CGD) {
                fbs[q]->init(FBS_GRADm1);
                fbs[q]->init(FBS_DIRm1);
            }
        }
        // FitResult fr=
        GradientDescentBitBig(fbs, nQ);
        
        for(q=0;q<nQ;q++) delete fbs[q];
        if(fbs!=NULL) free(fbs);
    }
    */

    // compute loglik
    return getSumLogPOPara(this->p->nSeq, this->p->k_data);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %r15
movq 0x88(%rdi), %rbx
movslq 0x8c0(%rbx), %r12
movslq 0x8bc(%rbx), %r14
cmpb $0x0, 0x3d(%rbx)
movq %rdi, 0x20(%rsp)
movq %r14, 0x90(%rsp)
jle 0x1ab10
movl $0x110, %edi            # imm = 0x110
callq 0x4210
movq %r14, %r8
movq %rax, %r14
movsbl 0x8b8(%rbx), %esi
movsbl 0x8b9(%rbx), %edx
movsd 0x28(%rbx), %xmm0
movsbl 0x30(%rbx), %r9d
movq %rax, %rdi
movq %r12, %r13
movl %r12d, %ecx
callq 0xa858
movq %r15, %rdi
xorl %esi, %esi
callq 0x11354
movq %rax, %r15
movq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x11370
movq %rax, %r12
movq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x1138c
movq 0x20(%rsp), %rcx
movq 0x88(%rcx), %rcx
movl 0x8dc(%rcx), %r8d
movq 0x8f0(%rcx), %r9
movq %r14, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %r15
movq %r12, %rdx
movq %rax, %rcx
callq 0xac70
movq 0x88(%r15), %rax
cmpb $0x0, 0x981(%rax)
je 0x1a9a8
movq $0x0, 0x10(%r14)
cmpb $0x0, 0x982(%rax)
je 0x1a9b9
movq $0x0, 0x18(%r14)
cmpb $0x0, 0x983(%rax)
je 0x1a9ca
movq $0x0, 0x20(%r14)
movq %r14, %rdi
movl $0x2, %esi
callq 0xaf10
movq %r14, %rdi
movl $0x7, %esi
callq 0xaf10
movq %r14, %rdi
movl $0x3, %esi
callq 0xaf10
movq 0x88(%r15), %rbx
cmpb $0x3, 0x3f(%rbx)
jne 0x1aa1f
movq %r14, %rdi
movl $0x4, %esi
callq 0xaf10
movq %r14, %rdi
movl $0x6, %esi
callq 0xaf10
movq 0x88(%r15), %rbx
movslq 0x8dc(%rbx), %r12
movl $0x4, %esi
movq %r12, %rdi
callq 0x4130
movq %rax, %r15
testq %r12, %r12
jle 0x1aa60
movq 0x8e8(%rbx), %rax
addq $0x58, %rax
xorl %ecx, %ecx
movl (%rax), %edx
movl %edx, (%r15,%rcx,4)
movl $0x0, (%rax)
incq %rcx
addq $0x60, %rax
cmpq %rcx, %r12
jne 0x1aa48
leaq 0x60(%rsp), %rdi
movq 0x20(%rsp), %rbx
movq %rbx, %rsi
movq %r14, %rdx
callq 0x14c44
movq 0x88(%rbx), %rbx
movslq 0x8dc(%rbx), %rax
testq %rax, %rax
jle 0x1aaa7
movq 0x8e8(%rbx), %rcx
addq $0x58, %rcx
xorl %edx, %edx
movl (%r15,%rdx,4), %esi
movl %esi, (%rcx)
incq %rdx
addq $0x60, %rcx
cmpq %rdx, %rax
jne 0x1aa95
movq %r15, %rdi
callq 0x42a0
cmpb $0x0, 0x3c(%rbx)
movq %r13, %r12
jne 0x1aadd
movl 0x60(%rsp), %esi
movsd 0x68(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
movl 0x80(%rsp), %edx
leaq 0x19e93(%rip), %rdi     # 0x34969
movb $0x2, %al
callq 0x4050
movq %r14, %rdi
callq 0xa8fa
movl $0x110, %esi            # imm = 0x110
movq %r14, %rdi
callq 0x4220
movq 0x20(%rsp), %r15
movq 0x88(%r15), %rbx
cmpb $0x2, 0x3d(%rbx)
movq 0x90(%rsp), %r14
je 0x1b18d
movsbl 0x978(%rbx), %eax
movl %eax, 0x34(%rsp)
movsbl 0x979(%rbx), %ebp
movl 0x97c(%rbx), %eax
movl %eax, 0x30(%rsp)
movl $0x4, %esi
movq %r12, %rdi
callq 0x4130
movq %rax, %rbx
movl $0x4, %esi
movq %r14, %rdi
callq 0x4130
movq %rax, 0x28(%rsp)
movl $0x4, %esi
movq %r12, %rdi
callq 0x4130
movq %rax, 0x40(%rsp)
movl $0x4, %esi
movq %r14, %rdi
callq 0x4130
movq %rbx, %rdi
movq %rax, 0x38(%rsp)
movq %r12, 0x88(%rsp)
testl %r12d, %r12d
setg %al
testl %r14d, %r14d
setg %r9b
movl %eax, %ecx
orb %r9b, %cl
testb $0x1, %cl
je 0x1b156
cmpl $0x0, 0x30(%rsp)
jle 0x1b156
movl %ebp, %edx
movl 0x88(%rsp), %esi
movl %r14d, %r8d
movl $0x0, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
movl $0x0, 0x10(%rsp)
movl %ebp, 0x1c(%rsp)
movq %rdi, 0x48(%rsp)
movq %rsi, 0x50(%rsp)
movq %r8, 0x58(%rsp)
movb %r9b, 0xf(%rsp)
testl %esi, %esi
setle %cl
notb %al
orb %cl, %al
testb $0x1, %al
jne 0x1aea3
xorl %r12d, %r12d
movq 0x40(%rsp), %rax
movq 0x28(%rsp), %r14
movl (%rdi,%r12,4), %ebx
cmpl %edx, %ebx
je 0x1ae95
movl (%rax,%r12,4), %r14d
cmpl %edx, %r14d
jne 0x1ac1c
movq 0x28(%rsp), %r14
jmp 0x1ae95
movl $0x110, %edi            # imm = 0x110
callq 0x4210
movq %rax, %r13
movq 0x88(%r15), %rax
movsbl 0x8b8(%rax), %esi
movsbl 0x8b9(%rax), %edx
movl 0x8c0(%rax), %ecx
movl 0x8bc(%rax), %r8d
movsd 0x28(%rax), %xmm0
movsbl 0x30(%rax), %r9d
movq %r13, %rdi
callq 0xa858
movq %r15, %rdi
movl %r12d, %esi
callq 0x11354
movq %rax, %r15
movq 0x20(%rsp), %rdi
movl %r12d, %esi
callq 0x11370
movq %rax, %rbp
movq 0x20(%rsp), %rdi
movl %r12d, %esi
callq 0x1138c
movq 0x20(%rsp), %rcx
movq 0x88(%rcx), %rcx
movq 0x8e0(%rcx), %rdx
movq 0x8f8(%rcx), %rcx
movl (%rdx,%r12,4), %r8d
movq (%rcx,%r12,8), %r9
movq %r13, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %r15
movq %rbp, %rdx
movq %rax, %rcx
callq 0xac70
movq 0x88(%r15), %rax
cmpb $0x0, 0x981(%rax)
je 0x1acd8
movq $0x0, 0x10(%r13)
cmpb $0x0, 0x982(%rax)
je 0x1ace9
movq $0x0, 0x18(%r13)
cmpb $0x0, 0x983(%rax)
je 0x1acfa
movq $0x0, 0x20(%r13)
movb $0x0, 0xfa(%r13)
movq %r13, %rdi
movl $0x2, %esi
callq 0xaf10
movq %r13, %rdi
movl $0x7, %esi
callq 0xaf10
movq %r13, %rdi
movl $0x3, %esi
callq 0xaf10
movq 0x88(%r15), %rax
cmpb $0x3, 0x3f(%rax)
jne 0x1ad50
movq %r13, %rdi
movl $0x4, %esi
callq 0xaf10
movq %r13, %rdi
movl $0x6, %esi
callq 0xaf10
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x14c44
movl 0x60(%rsp), %r8d
movq 0x88(%r15), %rcx
movl 0x38(%rcx), %eax
incl %r14d
cmpl %eax, %r8d
movl $0x0, %edx
cmovnel %edx, %r14d
movq 0x40(%rsp), %rdx
movl %r14d, (%rdx,%r12,4)
movl 0x18(%rsp), %edx
cmpl 0x34(%rsp), %edx
jge 0x1ada5
cmpl $0x0, 0xe8(%r13)
je 0x1ada5
movq 0x28(%rsp), %r14
jmp 0x1ae68
movl 0xe8(%r13), %edx
cmpl $0x1, %r8d
movq 0x90(%rsp), %rsi
movq 0x28(%rsp), %r14
movq 0x58(%rsp), %r9
je 0x1ade1
cmpl %r9d, 0x14(%rsp)
je 0x1ade1
testl %edx, %edx
movq 0x48(%rsp), %rdi
je 0x1ae00
movl $0x0, (%rdi,%r12,4)
jmp 0x1ae68
incl %ebx
movq 0x48(%rsp), %rdi
movl %ebx, (%rdi,%r12,4)
testl %edx, %edx
je 0x1ae00
movl 0x1c(%rsp), %edx
cmpl %edx, %ebx
je 0x1ae13
cmpl %esi, 0x14(%rsp)
jne 0x1ae68
jmp 0x1ae13
movl 0x1c(%rsp), %edx
movl %edx, (%rdi,%r12,4)
movl $0x1, 0x80(%rsp)
cmpl %r9d, 0x14(%rsp)
jne 0x1ae1e
movl %edx, (%rdi,%r12,4)
incl 0x10(%rsp)
cmpb $0x0, 0x3c(%rcx)
jne 0x1ae68
cmpl %eax, %r8d
sete %al
movl 0x80(%rsp), %r9d
testl %r9d, %r9d
setne %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x1ae68
movsd 0x68(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
leaq 0x19b50(%rip), %rdi     # 0x349a6
movl 0x18(%rsp), %esi
movl 0x10(%rsp), %edx
movl %r12d, %ecx
movb $0x2, %al
callq 0x4050
movq %r13, %rdi
callq 0xa8fa
movl $0x110, %esi            # imm = 0x110
movq %r13, %rdi
callq 0x4220
movl 0x1c(%rsp), %edx
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %r8
incq %r12
cmpq %r12, %rsi
jne 0x1abfd
jmp 0x1aea8
movq 0x28(%rsp), %r14
testl %r8d, %r8d
setg %al
movb 0xf(%rsp), %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1b128
xorl %r12d, %r12d
movq 0x38(%rsp), %rax
movl (%r14,%r12,4), %ebx
cmpl %edx, %ebx
je 0x1b11c
movl (%rax,%r12,4), %ebp
cmpl %edx, %ebp
je 0x1b11c
movl $0x110, %edi            # imm = 0x110
callq 0x4210
movq %rax, %r13
movq 0x88(%r15), %rax
movsbl 0x8b8(%rax), %esi
movsbl 0x8b9(%rax), %edx
movl 0x8c0(%rax), %ecx
movl 0x8bc(%rax), %r8d
movsd 0x28(%rax), %xmm0
movsbl 0x30(%rax), %r9d
movq %r13, %rdi
callq 0xa858
movq (%r15), %rax
movq %r15, %rdi
movl %r12d, %esi
callq *0xc0(%rax)
movq 0x88(%r15), %rcx
movq 0x900(%rcx), %rdx
movq 0x910(%rcx), %rcx
movl (%rdx,%r12,4), %r8d
movq (%rcx,%r12,8), %r9
movq %r13, %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xac70
movb $0x0, 0xf9(%r13)
movq 0x88(%r15), %rax
cmpb $0x0, 0x981(%rax)
je 0x1af79
movq $0x0, 0x10(%r13)
cmpb $0x0, 0x982(%rax)
je 0x1af8a
movq $0x0, 0x18(%r13)
cmpb $0x0, 0x983(%rax)
je 0x1af9b
movq $0x0, 0x20(%r13)
movb $0x1, 0xfa(%r13)
movq %r13, %rdi
movl $0x2, %esi
callq 0xaf10
movq %r13, %rdi
movl $0x7, %esi
callq 0xaf10
movq %r13, %rdi
movl $0x3, %esi
callq 0xaf10
movq 0x88(%r15), %rax
cmpb $0x3, 0x3f(%rax)
jne 0x1aff1
movq %r13, %rdi
movl $0x4, %esi
callq 0xaf10
movq %r13, %rdi
movl $0x6, %esi
callq 0xaf10
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x14c44
movl 0x60(%rsp), %r8d
movq 0x88(%r15), %rcx
movl 0x38(%rcx), %eax
incl %ebp
cmpl %eax, %r8d
movl $0x0, %edx
cmovnel %edx, %ebp
movq 0x38(%rsp), %rdx
movl %ebp, (%rdx,%r12,4)
movl 0x18(%rsp), %edx
cmpl 0x34(%rsp), %edx
jge 0x1b03e
cmpl $0x0, 0xe8(%r13)
jne 0x1b0ef
movl 0xe8(%r13), %edx
cmpl $0x1, %r8d
movq 0x50(%rsp), %rsi
je 0x1b067
cmpl %esi, 0x10(%rsp)
je 0x1b067
testl %edx, %edx
je 0x1b088
movl $0x0, (%r14,%r12,4)
jmp 0x1b0ef
incl %ebx
movl %ebx, (%r14,%r12,4)
testl %edx, %edx
je 0x1b088
movl 0x1c(%rsp), %edx
cmpl %edx, %ebx
je 0x1b09b
movl 0x10(%rsp), %edi
cmpl 0x88(%rsp), %edi
jne 0x1b0ef
jmp 0x1b09b
movl 0x1c(%rsp), %edx
movl %edx, (%r14,%r12,4)
movl $0x1, 0x80(%rsp)
cmpl %esi, 0x10(%rsp)
jne 0x1b0a5
movl %edx, (%r14,%r12,4)
incl 0x14(%rsp)
cmpb $0x0, 0x3c(%rcx)
jne 0x1b0ef
cmpl %eax, %r8d
sete %al
movl 0x80(%rsp), %r9d
testl %r9d, %r9d
setne %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x1b0ef
movsd 0x68(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
leaq 0x19915(%rip), %rdi     # 0x349f2
movl 0x18(%rsp), %esi
movl 0x14(%rsp), %edx
movl %r12d, %ecx
movb $0x2, %al
callq 0x4050
movq %r13, %rdi
callq 0xa8fa
movl $0x110, %esi            # imm = 0x110
movq %r13, %rdi
callq 0x4220
movq 0x38(%rsp), %rax
movl 0x1c(%rsp), %edx
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %r8
incq %r12
cmpq %r12, %r8
jne 0x1aec5
cmpl %esi, 0x10(%rsp)
setl %al
cmpl %r8d, 0x14(%rsp)
setl %r9b
movl %eax, %ecx
orb %r9b, %cl
testb $0x1, %cl
je 0x1b156
movl 0x18(%rsp), %ecx
incl %ecx
movl %ecx, 0x18(%rsp)
cmpl 0x30(%rsp), %ecx
jl 0x1abda
testq %rdi, %rdi
je 0x1b160
callq 0x42a0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1b16f
callq 0x42a0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1b17e
callq 0x42a0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x1b18d
callq 0x42a0
movq 0x88(%r15), %rax
movl 0x8dc(%rax), %esi
movq 0x8f0(%rax), %rdx
movq %r15, %rdi
callq 0x114ae
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x110, %esi            # imm = 0x110
movq %r14, %rdi
jmp 0x1b1d5
jmp 0x1b1ca
movq %rax, %rbx
movl $0x110, %esi            # imm = 0x110
movq %r13, %rdi
callq 0x4220
movq %rbx, %rdi
callq 0x4430