// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/HMMProblemAGK.cpp
// Function: HMMProblemAGK::GradientDescent()
NUMBER HMMProblemAGK::GradientDescent() {
	NCAT k=0, g=0, /*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"
        NCAT first_iteration_qualify = this->p->first_iteration_qualify; // at what iteration, qualification for skill/group convergence should start
        NCAT iterations_to_qualify = this->p->iterations_to_qualify; // how many concecutive iterations necessary for skill/group to qualify as converged
        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;
        // utilize fitting larger data first
        
        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) {
                //
                // Skills first
                //
//                printf("... while in,  run=%3d, k=%6d, skippedK=%6d, g=%6d, skippedG=%6d, thread id=%d\n",i,k,skip_k,g,skip_g, omp_get_thread_num());//PAR
                if(skip_k<nK) {
//                    printf("... still k,   run=%3d, k=%6d, skippedK=%6d, g=%6d, skippedG=%6d, thread id=%d\n",i,k,skip_k,g,skip_g, omp_get_thread_num());//PAR
//                    #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;
//                        printf("... doing k,   run=%3d, k=%6d, skippedK=%6d, g=%6d, skippedG=%6d, thread id=%d\n",i,k,skip_k,g,skip_g, omp_get_thread_num());//PAR
                        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){
//                    printf("... still g,   run=%3d, k=%6d, skippedK=%6d, g=%6d, skippedG=%6d, thread id=%d\n",i,k,skip_k,g,skip_g, omp_get_thread_num());//PAR
//                    #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;
//                        printf("... doing g,   run=%3d, k=%6d, skippedK=%6d, g=%6d, skippedG=%6d, thread id=%d\n",i,k,skip_k,g,skip_g, omp_get_thread_num());//PAR
                        FitBit *fb = new FitBit(this->p->nS, this->p->nO, this->p->nK, this->p->nG, this->p->tol, this->p->tol_mode);
                        // link
                        // vvvvvvvvvvvvvvvvvvvvv ONLY PART THAT IS DIFFERENT FROM HMMProblemPiGK
                        fb->link(NULL, this->getAg(g), 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++;
//                    printf("... done run,  run=%3d, k=%6d, skippedK=%6d, g=%6d, skippedG=%6d, thread id=%d\n",i,k,skip_k,g,skip_g, omp_get_thread_num());//PAR
//                }//PAR
//                printf("... while out, run=%3d, k=%6d, skippedK=%6d, g=%6d, skippedG=%6d, thread id=%d\n",i,k,skip_k,g,skip_g, omp_get_thread_num());//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
    
    // 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, %r14
movq 0x88(%rdi), %rbx
movslq 0x8c0(%rbx), %r13
movslq 0x8bc(%rbx), %r15
cmpb $0x0, 0x3d(%rbx)
movq %rdi, 0x18(%rsp)
movq %r15, 0x40(%rsp)
jle 0x1eec3
movl $0x110, %edi            # imm = 0x110
callq 0x4210
movq %rax, %r12
movsbl 0x8b8(%rbx), %esi
movsbl 0x8b9(%rbx), %edx
movl 0x8c0(%rbx), %ecx
movl 0x8bc(%rbx), %r8d
movsd 0x28(%rbx), %xmm0
movsbl 0x30(%rbx), %r9d
movq %rax, %rdi
callq 0xa850
movq %r14, %rdi
xorl %esi, %esi
callq 0x114c2
movq %rax, %r14
movq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x114de
movq %rax, %r15
movq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x114fa
movq 0x18(%rsp), %rcx
movq 0x88(%rcx), %rcx
movl 0x8dc(%rcx), %r8d
movq 0x8f0(%rcx), %r9
movq %r12, %rdi
movq %r14, %rsi
movq 0x18(%rsp), %rbx
movq %r15, %rdx
movq %rax, %rcx
callq 0xac68
movq 0x88(%rbx), %rax
cmpb $0x0, 0x981(%rax)
je 0x1ed70
movq $0x0, 0x10(%r12)
cmpb $0x0, 0x982(%rax)
je 0x1ed82
movq $0x0, 0x18(%r12)
cmpb $0x0, 0x983(%rax)
je 0x1ed94
movq $0x0, 0x20(%r12)
movq %r12, %rdi
movl $0x2, %esi
callq 0xaf08
movq %r12, %rdi
movl $0x7, %esi
callq 0xaf08
movq %r12, %rdi
movl $0x3, %esi
callq 0xaf08
movq 0x88(%rbx), %rax
cmpb $0x3, 0x3f(%rax)
jne 0x1ede2
movq %r12, %rdi
movl $0x4, %esi
callq 0xaf08
movq %r12, %rdi
movl $0x6, %esi
callq 0xaf08
movq 0x88(%rbx), %rbx
movslq 0x8dc(%rbx), %r15
movl $0x4, %esi
movq %r15, %rdi
callq 0x4130
movq %rax, %r14
testq %r15, %r15
jle 0x1ee2a
movq 0x8e8(%rbx), %rax
addq $0x58, %rax
xorl %ecx, %ecx
movl (%rax), %edx
movl %edx, (%r14,%rcx,4)
movl $0x0, (%rax)
incq %rcx
addq $0x60, %rax
cmpq %rcx, %r15
jne 0x1ee12
leaq 0x60(%rsp), %rdi
movq 0x18(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
callq 0x14dc4
movq 0x88(%rbx), %rbx
movslq 0x8dc(%rbx), %rax
testq %rax, %rax
jle 0x1ee71
movq 0x8e8(%rbx), %rcx
addq $0x58, %rcx
xorl %edx, %edx
movl (%r14,%rdx,4), %esi
movl %esi, (%rcx)
incq %rdx
addq $0x60, %rcx
cmpq %rdx, %rax
jne 0x1ee5f
movq %r14, %rdi
callq 0x42a0
cmpb $0x0, 0x3c(%rbx)
movq 0x40(%rsp), %r15
jne 0x1eea9
movl 0x60(%rsp), %esi
movsd 0x68(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
movl 0x80(%rsp), %edx
leaq 0x16a01(%rip), %rdi     # 0x358a3
movb $0x2, %al
callq 0x4050
movq %r12, %rdi
callq 0xa8f2
movl $0x110, %esi            # imm = 0x110
movq %r12, %rdi
callq 0x4220
movq 0x18(%rsp), %r14
movq 0x88(%r14), %rax
cmpb $0x2, 0x3d(%rax)
je 0x1f557
movsbl 0x978(%rax), %ecx
movl %ecx, 0x34(%rsp)
movsbl 0x979(%rax), %ebx
movl $0x4, %esi
movq %r13, %rdi
callq 0x4130
movq %rax, %rbp
movl $0x4, %esi
movq %r15, %rdi
callq 0x4130
movq %rax, %r12
movl $0x4, %esi
movq %r13, %rdi
callq 0x4130
movq %rax, 0x50(%rsp)
movl $0x4, %esi
movq %r15, %rdi
callq 0x4130
movq %rbp, %rsi
movq %rax, 0x48(%rsp)
testl %r13d, %r13d
setg %al
testl %r15d, %r15d
setg %r8b
movl %eax, %ecx
movb %r8b, 0xb(%rsp)
orb %r8b, %cl
testb $0x1, %cl
movq %r12, 0x28(%rsp)
je 0x1f51a
movl %ebx, %edx
movl %r13d, %r8d
movl %r15d, %r9d
movl $0x0, 0x14(%rsp)
xorl %ecx, %ecx
movl $0x0, 0xc(%rsp)
movl %ebx, 0x24(%rsp)
movq %rsi, 0x58(%rsp)
movq %r8, 0x90(%rsp)
movq %r9, 0x88(%rsp)
movq %r13, 0x38(%rsp)
movl %ecx, 0x10(%rsp)
testl %r13d, %r13d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1f24e
xorl %r13d, %r13d
movq 0x50(%rsp), %rax
movl (%rsi,%r13,4), %ebx
cmpl %edx, %ebx
je 0x1f242
movl (%rax,%r13,4), %r15d
cmpl %edx, %r15d
jne 0x1efc6
movq 0x40(%rsp), %r15
jmp 0x1f242
movl $0x110, %edi            # imm = 0x110
callq 0x4210
movq %rax, %r12
movq 0x88(%r14), %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 %r12, %rdi
callq 0xa850
movq %r14, %rdi
movl %r13d, %esi
callq 0x114c2
movq %rax, %rbp
movq %r14, %rdi
movl %r13d, %esi
callq 0x114de
movq %rax, %r14
movq 0x18(%rsp), %rdi
movl %r13d, %esi
callq 0x114fa
movq 0x18(%rsp), %rcx
movq 0x88(%rcx), %rcx
movq 0x8e0(%rcx), %rdx
movq 0x8f8(%rcx), %rcx
movl (%rdx,%r13,4), %r8d
movq (%rcx,%r13,8), %r9
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq 0x18(%rsp), %r14
movq %rax, %rcx
callq 0xac68
movq 0x88(%r14), %rax
cmpb $0x0, 0x981(%rax)
je 0x1f081
movq $0x0, 0x10(%r12)
cmpb $0x0, 0x982(%rax)
je 0x1f093
movq $0x0, 0x18(%r12)
cmpb $0x0, 0x983(%rax)
je 0x1f0a5
movq $0x0, 0x20(%r12)
movb $0x0, 0xfa(%r12)
movq %r12, %rdi
movl $0x2, %esi
callq 0xaf08
movq %r12, %rdi
movl $0x7, %esi
callq 0xaf08
movq %r12, %rdi
movl $0x3, %esi
callq 0xaf08
movq 0x88(%r14), %rax
cmpb $0x3, 0x3f(%rax)
jne 0x1f0fc
movq %r12, %rdi
movl $0x4, %esi
callq 0xaf08
movq %r12, %rdi
movl $0x6, %esi
callq 0xaf08
leaq 0x60(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x14dc4
movl 0x60(%rsp), %r8d
movq 0x88(%r14), %rcx
movl 0x38(%rcx), %eax
incl %r15d
cmpl %eax, %r8d
movl $0x0, %edx
cmovnel %edx, %r15d
movq 0x50(%rsp), %rdx
movl %r15d, (%rdx,%r13,4)
movl 0x14(%rsp), %edx
cmpl 0x34(%rsp), %edx
jge 0x1f152
cmpl $0x0, 0xe8(%r12)
je 0x1f152
movq 0x40(%rsp), %r15
jmp 0x1f20a
cmpl $0x1, %r8d
movq 0x40(%rsp), %r15
movl 0x10(%rsp), %edi
je 0x1f183
cmpl %r15d, %edi
je 0x1f183
cmpl $0x0, 0xe8(%r12)
je 0x1f183
movq 0x58(%rsp), %rax
movl $0x0, (%rax,%r13,4)
jmp 0x1f20a
incl %ebx
movq 0x58(%rsp), %rsi
movl %ebx, (%rsi,%r13,4)
cmpl $0x0, 0xe8(%r12)
movl 0x24(%rsp), %edx
jne 0x1f1ac
movl %edx, (%rsi,%r13,4)
movl $0x1, 0x80(%rsp)
cmpl %edx, (%rsi,%r13,4)
je 0x1f1b7
cmpl %r15d, %edi
jne 0x1f20a
cmpl %r15d, %edi
jne 0x1f1c0
movl %edx, (%rsi,%r13,4)
incl 0xc(%rsp)
cmpb $0x0, 0x3c(%rcx)
jne 0x1f20a
cmpl %eax, %r8d
sete %al
movl 0x80(%rsp), %r9d
testl %r9d, %r9d
setne %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x1f20a
movsd 0x68(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
leaq 0x166e8(%rip), %rdi     # 0x358e0
movl 0x14(%rsp), %esi
movl 0xc(%rsp), %edx
movl %r13d, %ecx
movb $0x2, %al
callq 0x4050
movq %r12, %rdi
callq 0xa8f2
movl $0x110, %esi            # imm = 0x110
movq %r12, %rdi
callq 0x4220
movq 0x50(%rsp), %rax
movl 0x24(%rsp), %edx
movq 0x28(%rsp), %r12
movq 0x58(%rsp), %rsi
movq 0x90(%rsp), %r8
movq 0x88(%rsp), %r9
incq %r13
cmpq %r13, %r8
jne 0x1efa7
testl %r15d, %r15d
setg %al
movb 0xb(%rsp), %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1f4ee
xorl %r13d, %r13d
movq 0x48(%rsp), %rax
movl (%r12,%r13,4), %ebx
cmpl %edx, %ebx
je 0x1f4e2
movl (%rax,%r13,4), %ebp
cmpl %edx, %ebp
je 0x1f4e2
movl $0x110, %edi            # imm = 0x110
callq 0x4210
movq %rax, %r12
movq 0x88(%r14), %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 %r12, %rdi
callq 0xa850
movq %r14, %rdi
movl %r13d, %esi
callq 0x1e3e4
movq 0x88(%r14), %rcx
movq 0x900(%rcx), %rdx
movq 0x910(%rcx), %rcx
movl (%rdx,%r13,4), %r8d
movq (%rcx,%r13,8), %r9
movq %r12, %rdi
xorl %esi, %esi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0xac68
movb $0x0, 0xf9(%r12)
movq 0x88(%r14), %rax
cmpb $0x0, 0x981(%rax)
je 0x1f31d
movq $0x0, 0x10(%r12)
cmpb $0x0, 0x982(%rax)
je 0x1f32f
movq $0x0, 0x18(%r12)
cmpb $0x0, 0x983(%rax)
je 0x1f341
movq $0x0, 0x20(%r12)
movb $0x1, 0xfa(%r12)
movq %r12, %rdi
movl $0x2, %esi
callq 0xaf08
movq %r12, %rdi
movl $0x7, %esi
callq 0xaf08
movq %r12, %rdi
movl $0x3, %esi
callq 0xaf08
movq 0x88(%r14), %rax
cmpb $0x3, 0x3f(%rax)
jne 0x1f398
movq %r12, %rdi
movl $0x4, %esi
callq 0xaf08
movq %r12, %rdi
movl $0x6, %esi
callq 0xaf08
leaq 0x60(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x14dc4
movl 0x60(%rsp), %r8d
movq 0x88(%r14), %rcx
movl 0x38(%rcx), %eax
incl %ebp
cmpl %eax, %r8d
movl $0x0, %edx
cmovnel %edx, %ebp
movq 0x48(%rsp), %rdx
movl %ebp, (%rdx,%r13,4)
movl 0x14(%rsp), %edx
cmpl 0x34(%rsp), %edx
jge 0x1f3e6
cmpl $0x0, 0xe8(%r12)
jne 0x1f4aa
cmpl $0x1, %r8d
je 0x1f413
movl 0xc(%rsp), %edx
cmpl 0x38(%rsp), %edx
je 0x1f413
cmpl $0x0, 0xe8(%r12)
je 0x1f413
movq 0x28(%rsp), %rax
movl $0x0, (%rax,%r13,4)
jmp 0x1f4aa
incl %ebx
movq 0x28(%rsp), %rsi
movl %ebx, (%rsi,%r13,4)
cmpl $0x0, 0xe8(%r12)
movl 0x24(%rsp), %edx
jne 0x1f43c
movl %edx, (%rsi,%r13,4)
movl $0x1, 0x80(%rsp)
cmpl %edx, (%rsi,%r13,4)
je 0x1f44c
movl 0xc(%rsp), %edi
cmpl 0x38(%rsp), %edi
jne 0x1f4aa
movl 0xc(%rsp), %edi
cmpl 0x38(%rsp), %edi
movl 0x10(%rsp), %edi
jne 0x1f45e
movl %edx, (%rsi,%r13,4)
incl %edi
cmpb $0x0, 0x3c(%rcx)
movl %edi, 0x10(%rsp)
jne 0x1f4aa
cmpl %eax, %r8d
sete %al
movl 0x80(%rsp), %r9d
testl %r9d, %r9d
setne %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x1f4aa
movsd 0x68(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
leaq 0x16494(%rip), %rdi     # 0x3592c
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
movl %r13d, %ecx
movb $0x2, %al
callq 0x4050
movq %r12, %rdi
callq 0xa8f2
movl $0x110, %esi            # imm = 0x110
movq %r12, %rdi
callq 0x4220
movq 0x48(%rsp), %rax
movl 0x24(%rsp), %edx
movq 0x28(%rsp), %r12
movq 0x58(%rsp), %rsi
movq 0x90(%rsp), %r8
movq 0x88(%rsp), %r9
incq %r13
cmpq %r13, %r9
jne 0x1f26b
incl 0x14(%rsp)
movl 0x10(%rsp), %ecx
cmpl %r15d, %ecx
setl 0xb(%rsp)
movq 0x38(%rsp), %r13
cmpl %r13d, 0xc(%rsp)
setl %al
jl 0x1ef8a
cmpl %r15d, %ecx
jl 0x1ef8a
testq %rsi, %rsi
je 0x1f52c
movq %rsi, %rdi
callq 0x42a0
movq 0x28(%rsp), %r12
testq %r12, %r12
je 0x1f539
movq %r12, %rdi
callq 0x42a0
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x1f548
callq 0x42a0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x1f557
callq 0x42a0
movq 0x88(%r14), %rax
movl 0x8dc(%rax), %esi
movq 0x8f0(%rax), %rdx
movq %r14, %rdi
callq 0x1161c
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1f589
jmp 0x1f589
movq %rax, %rbx
movl $0x110, %esi            # imm = 0x110
movq %r12, %rdi
callq 0x4220
movq %rbx, %rdi
callq 0x4430
nop