// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/HMMProblemPiGKww.cpp
// Function: HMMProblemPiGKww::GradientDescent()
NUMBER HMMProblemPiGKww::GradientDescent() {
	NCAT k, g, x;
    NPAR nS = this->p->nS; NPAR nO = this->p->nO; NCAT nK = this->p->nK, nG = this->p->nG;
    NUMBER loglik = 0;
    FitResult fr;

//    // all together
//    NUMBER ** copyPI = init2D<NUMBER>((NDAT)this->sizes[0], (NDAT)nS);
//    NUMBER ** copyPIg = init2D<NUMBER>(nG, (NDAT)nS);
//    NUMBER *** copyA =  init3D<NUMBER>((NDAT)this->sizes[1], (NDAT)nS, (NDAT)nS);
//    NUMBER *** copyB =  init3D<NUMBER>((NDAT)this->sizes[2], (NDAT)nS, (NDAT)nO);

    //
	// 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(nS, nO, nK, 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
        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;
        
        
        int i = 0; // count runs
        while(skip_k<nK || skip_g<nG /*|| frww.conv==0*/ ) {
            //
            // Skills first
            //
            for(k=0; k<nK && skip_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(nS, nO, nK, nG, this->p->tol, this->p->tol_mode);
                // link and fit
                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);
                }
                
//                NCAT xndat = this->p->k_numg[k];
//                struct data** x_data = this->p->k_g_data[k];
//                cpy1D<NUMBER>(this->pi[k],copyPI[k],nS); /*prep hide*/
                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) {
                    if(fr.iter==1 /*e<=this->p->tol*/ || skip_g==nG) { // converged quick, or don't care (others all converged
                        iter_qual_skill[k]++;
                        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
                            skip_k++;
                            if( !this->p->quiet && ( /*(!conv && iter<this->p->maxiter) ||*/ (fr.conv || fr.iter==this->p->maxiter) )) {
                                computeAlphaAndPOParam(fb->xndat, fb->x_data);
                                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
//                swap1D<NUMBER>(this->pi[k],copyPI[k],nS); /*hide*/
                delete fb;
            } // for all skills
            //
            // PIg second
            //
            for(g=0; g<nG && skip_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(nS, nO, nK, nG, this->p->tol, this->p->tol_mode);
//                NCAT xndat = this->p->g_numk[g];
//                struct data** x_data = this->p->g_k_data[g];
//                cpy1D<NUMBER>(this->PIg[g],copyPIg[g],nS); /*prep hide*/
                // vvvvvvvvvvvvvvvvvvvvv ONLY PART THAT IS DIFFERENT FROM others
                fb->link(this->getPIg(g), NULL, NULL, this->p->g_numk[g], this->p->g_k_data[g]);
                fb->Cslice = 1;
                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);
                }
                // decide on convergence
                fr = GradientDescentBit(fb);
				
				// count number of concecutive failures
				if(fr.iter==this->p->maxiter) {
					iter_fail_group[g]++;
				} else {
					iter_fail_group[g]=0;
				}
				
                if(i>=first_iteration_qualify) {
                    if(fr.iter==1 /*e<=this->p->tol*/ || skip_k==nK) { // converged quick, or don't care (others all converged
                        iter_qual_group[g]++;
                        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
                            skip_g++;
                            if( !this->p->quiet && ( /*(!conv && iter<this->p->maxiter) ||*/ (fr.conv || fr.iter==this->p->maxiter) )) {
                                computeAlphaAndPOParam(fb->xndat, fb->x_data);
                                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
//                swap1D<NUMBER>(this->PIg[g],copyPIg[g],nS); /*hide*/
            } // for all groups
            
//            // vvv temporary explorative
//            NCAT xndat = this->p->nSeq;
//            struct data** x_data = this->p->k_data;
//            
//            this->ww[0]=1; this->ww[1]=1; this->ww[2]=0;
//            computeAlphaAndPOParam(xndat, x_data);
//            NUMBER l1 = loglik = getSumLogPOPara(this->p->nSeq, this->p->k_data);
//            
//            this->ww[0]=1.01; this->ww[1]=1; this->ww[2]=0;
//            computeAlphaAndPOParam(xndat, x_data);
//            NUMBER l2 = loglik = getSumLogPOPara(this->p->nSeq, this->p->k_data);
//
//            this->ww[0]=1.05; this->ww[1]=1; this->ww[2]=0;
//            computeAlphaAndPOParam(xndat, x_data);
//            NUMBER l3 = loglik = getSumLogPOPara(this->p->nSeq, this->p->k_data);
//            // ^^^ temporary explorative
//            
            
            
            //
            // ww third
            //
            // fit bit and for result for ww
            FitResult frww;
            FitBit *fbww = new FitBit(nS, nO, nK, nG, this->p->tol, 1/*do project to simplex*/);
            fbww->link(this->ww, NULL, NULL, this->p->nSeq, this->p->k_data);

            fbww->init(FBS_PARm1);
            fbww->init(FBS_GRAD);
            if(this->p->solver==METHOD_CGD) {
                fbww->init(FBS_GRADm1);
                fbww->init(FBS_DIRm1);
            }
//            NCAT xndat = this->p->nSeq;
//            struct data** x_data = this->p->k_data;
            computeAlphaAndPOParam(fbww->xndat, fbww->x_data);
//            loglik = getSumLogPOPara(this->p->nSeq, this->p->k_data);
            bool non01constraints = this->non01constraints;
            this->non01constraints = false;
            frww = GradientDescentBit(fbww);
            this->non01constraints = non01constraints;
//            loglik = getSumLogPOPara(this->p->nSeq, this->p->k_data);
            
//            // unhide
//            cpy2D<NUMBER>(copyPI,this->PI,nK,nS);
//            cpy2D<NUMBER>(copyPIg,this->PIg,nG,nS);
//            cpy3D<NUMBER>(copyA,this->A,nK,nS,nS);
//            cpy3D<NUMBER>(copyB,this->B,nK,nS,nS);
            delete fbww;
            i++;
        }
        // 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
    loglik = getSumLogPOPara(this->p->nSeq, this->p->k_data);
    return loglik;

//    // all together
//    if(copyPI!=NULL) free2D(copyPI,(NDAT)this->sizes[0]);
//    if(copyPIg!=NULL) free2D(copyPIg,(NDAT)nG);
//    if(copyA !=NULL) free3D(copyA, (NDAT)this->sizes[1], (NDAT)nS);
//    if(copyB !=NULL) free3D(copyB, (NDAT)this->sizes[2], (NDAT)nS);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %r13
movq 0x88(%rdi), %rbx
movslq 0x8c0(%rbx), %r15
movslq 0x8bc(%rbx), %r14
cmpb $0x0, 0x3d(%rbx)
movsbl 0x8b8(%rbx), %eax
movl %eax, 0x54(%rsp)
movsbl 0x8b9(%rbx), %eax
movl %eax, 0x50(%rsp)
movq %rdi, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movq %r14, 0x30(%rsp)
jle 0x1cb39
movl $0x110, %edi            # imm = 0x110
callq 0x4210
movq %rax, %rbp
movsd 0x28(%rbx), %xmm0
movsbl 0x30(%rbx), %r9d
movq %rax, %rdi
movl 0x54(%rsp), %esi
movl 0x50(%rsp), %edx
movl %r15d, %ecx
movl %r14d, %r8d
callq 0xa850
movq %r13, %rdi
xorl %esi, %esi
callq 0x114c2
movq %rax, %r15
movq %r13, %rdi
xorl %esi, %esi
callq 0x114de
movq %rax, %r12
movq %r13, %rdi
xorl %esi, %esi
callq 0x114fa
movq 0x88(%r13), %rcx
movl 0x8dc(%rcx), %r8d
movq 0x8f0(%rcx), %r9
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rax, %rcx
callq 0xac68
movq 0x88(%r13), %rax
cmpb $0x0, 0x981(%rax)
je 0x1c9c7
movq $0x0, 0x10(%rbp)
cmpb $0x0, 0x982(%rax)
je 0x1c9d8
movq $0x0, 0x18(%rbp)
cmpb $0x0, 0x983(%rax)
je 0x1c9e9
movq $0x0, 0x20(%rbp)
movq %rbp, %rdi
movl $0x2, %esi
callq 0xaf08
movq %rbp, %rdi
movl $0x7, %esi
callq 0xaf08
movq %rbp, %rdi
movl $0x3, %esi
callq 0xaf08
movq 0x88(%r13), %rax
cmpb $0x3, 0x3f(%rax)
jne 0x1ca37
movq %rbp, %rdi
movl $0x4, %esi
callq 0xaf08
movq %rbp, %rdi
movl $0x6, %esi
callq 0xaf08
movq 0x88(%r13), %rbx
movslq 0x8dc(%rbx), %r12
movl $0x4, %esi
movq %r12, %rdi
callq 0x4130
movq %rax, %r15
testq %r12, %r12
jle 0x1ca7f
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 0x1ca67
leaq 0x80(%rsp), %r13
movq %r13, %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x14dc4
movl (%r13), %r12d
movsd 0x8(%r13), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x18(%r13), %xmm0
movsd %xmm0, 0x48(%rsp)
movl 0x20(%r13), %r13d
movq 0x88(%rbx), %rbx
movslq 0x8dc(%rbx), %rax
testq %rax, %rax
jle 0x1caec
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 0x1cada
movq %r15, %rdi
callq 0x42a0
cmpb $0x0, 0x3c(%rbx)
jne 0x1cb1a
leaq 0x18da2(%rip), %rdi     # 0x358a3
movl %r12d, %esi
movsd 0x38(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movl %r13d, %edx
movb $0x2, %al
callq 0x4050
movq %rbp, %rdi
callq 0xa8f2
movl $0x110, %esi            # imm = 0x110
movq %rbp, %rdi
callq 0x4220
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %r15
movq 0x88(%r13), %rax
cmpb $0x2, 0x3d(%rax)
je 0x1d2cd
movsbl 0x978(%rax), %ecx
movl %ecx, 0x6c(%rsp)
movsbl 0x979(%rax), %eax
movl %eax, 0xc(%rsp)
movl $0x4, %esi
movq %r15, %rdi
callq 0x4130
movq %rax, 0x58(%rsp)
movl $0x4, %esi
movq 0x30(%rsp), %rdi
callq 0x4130
movq %rax, 0x28(%rsp)
movl $0x4, %esi
movq %r15, %rdi
callq 0x4130
movq %rax, 0x70(%rsp)
movl $0x4, %esi
movq 0x30(%rsp), %rdi
callq 0x4130
movq 0x30(%rsp), %rsi
movq %rax, 0x40(%rsp)
testl %r15d, %r15d
setg %al
testl %esi, %esi
setg %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x1d291
movl $0x0, 0x24(%rsp)
movl $0x0, 0x38(%rsp)
xorl %edx, %edx
testl %r15d, %r15d
movq 0x58(%rsp), %rcx
jle 0x1ceb1
cmpl %r15d, %edx
movq 0x70(%rsp), %rax
movl 0xc(%rsp), %edi
jge 0x1ceb5
xorl %r12d, %r12d
movl (%rcx,%r12,4), %r8d
cmpl %edi, %r8d
je 0x1ce9e
movl (%rax,%r12,4), %ebx
cmpl %edi, %ebx
je 0x1ce9e
movl %r8d, 0x60(%rsp)
movl %edx, 0x48(%rsp)
movl $0x110, %edi            # imm = 0x110
movq %rsi, %r14
callq 0x4210
movq %rax, %rbp
movq 0x88(%r13), %rax
movsd 0x28(%rax), %xmm0
movsbl 0x30(%rax), %r9d
movq %rbp, %rdi
movl 0x54(%rsp), %esi
movl 0x50(%rsp), %edx
movl %r15d, %ecx
movl %r14d, %r8d
callq 0xa850
movq %r13, %rdi
movl %r12d, %esi
callq 0x114c2
movq %rax, %r15
movq %r13, %rdi
movl %r12d, %esi
callq 0x114de
movq %rax, %r13
movq 0x10(%rsp), %rdi
movl %r12d, %esi
callq 0x114fa
movq 0x10(%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 %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq 0x10(%rsp), %r15
movq %rax, %rcx
callq 0xac68
movq 0x88(%r15), %rax
cmpb $0x0, 0x981(%rax)
je 0x1ccce
movq $0x0, 0x10(%rbp)
cmpb $0x0, 0x982(%rax)
je 0x1ccdf
movq $0x0, 0x18(%rbp)
cmpb $0x0, 0x983(%rax)
je 0x1ccf0
movq $0x0, 0x20(%rbp)
movb $0x0, 0xfa(%rbp)
movq %rbp, %rdi
movl $0x2, %esi
callq 0xaf08
movq %rbp, %rdi
movl $0x7, %esi
callq 0xaf08
movq %rbp, %rdi
movl $0x3, %esi
callq 0xaf08
movq 0x88(%r15), %rax
cmpb $0x3, 0x3f(%rax)
jne 0x1cd45
movq %rbp, %rdi
movl $0x4, %esi
callq 0xaf08
movq %rbp, %rdi
movl $0x6, %esi
callq 0xaf08
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x14dc4
movq %r15, %rax
movl 0x80(%rsp), %r13d
movsd 0x88(%rsp), %xmm0
movsd 0x98(%rsp), %xmm1
movl 0xa0(%rsp), %r15d
movq 0x88(%rax), %rax
movl 0x38(%rax), %ecx
incl %ebx
cmpl %ecx, %r13d
movl $0x0, %edx
cmovnel %edx, %ebx
movq 0x70(%rsp), %rdx
movl %ebx, (%rdx,%r12,4)
movl 0x24(%rsp), %edx
cmpl 0x6c(%rsp), %edx
jl 0x1ce68
cmpl $0x1, %r13d
movq 0x30(%rsp), %rdx
je 0x1cdce
cmpl %edx, 0x38(%rsp)
je 0x1cdce
movq 0x58(%rsp), %rax
movl $0x0, (%rax,%r12,4)
jmp 0x1ce68
movl 0x60(%rsp), %edi
incl %edi
movq 0x58(%rsp), %rsi
movl %edi, (%rsi,%r12,4)
movl 0xc(%rsp), %esi
cmpl %esi, %edi
je 0x1cdeb
cmpl %edx, 0x38(%rsp)
jne 0x1ce68
cmpl %edx, 0x38(%rsp)
movl 0x48(%rsp), %edi
jne 0x1cdfe
movq 0x58(%rsp), %rdx
movl %esi, (%rdx,%r12,4)
cmpl %ecx, %r13d
sete %cl
incl %edi
testl %r15d, %r15d
setne %dl
cmpb $0x0, 0x3c(%rax)
movl %edi, 0x48(%rsp)
jne 0x1ce68
orb %cl, %dl
je 0x1ce68
movl 0xe8(%rbp), %esi
movq 0xf0(%rbp), %rdx
movq 0x10(%rsp), %rdi
movsd %xmm0, 0x78(%rsp)
movsd %xmm1, 0x60(%rsp)
callq 0x11a86
leaq 0x18a9c(%rip), %rdi     # 0x358e0
movl 0x24(%rsp), %esi
movl 0x48(%rsp), %edx
movl %r12d, %ecx
movl %r13d, %r8d
movsd 0x78(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movl %r15d, %r9d
movb $0x2, %al
callq 0x4050
movq %rbp, %rdi
callq 0xa8f2
movl $0x110, %esi            # imm = 0x110
movq %rbp, %rdi
callq 0x4220
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %r15
movq 0x30(%rsp), %rsi
movq 0x70(%rsp), %rax
movl 0xc(%rsp), %edi
movq 0x58(%rsp), %rcx
movl 0x48(%rsp), %edx
incq %r12
cmpq %r15, %r12
jge 0x1ceb5
cmpl %r15d, %edx
jl 0x1cbfc
jmp 0x1ceb5
movl 0xc(%rsp), %edi
movl %edx, 0x48(%rsp)
testl %esi, %esi
setg %al
cmpl %esi, 0x38(%rsp)
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1d17c
xorl %r12d, %r12d
movq 0x40(%rsp), %rax
movq 0x28(%rsp), %rcx
movl (%rcx,%r12,4), %r14d
cmpl %edi, %r14d
je 0x1d16a
movl (%rax,%r12,4), %ebx
cmpl %edi, %ebx
je 0x1d16a
movl $0x110, %edi            # imm = 0x110
callq 0x4210
movq %rax, %rbp
movq 0x88(%r13), %rax
movsd 0x28(%rax), %xmm0
movsbl 0x30(%rax), %r9d
movq %rbp, %rdi
movl 0x54(%rsp), %esi
movl 0x50(%rsp), %edx
movl %r15d, %ecx
movq 0x30(%rsp), %r8
callq 0xa850
movq (%r13), %rax
movq %r13, %rdi
movl %r12d, %esi
callq *0xc0(%rax)
movq 0x88(%r13), %rcx
movq 0x900(%rcx), %rdx
movq 0x910(%rcx), %rcx
movl (%rdx,%r12,4), %r8d
movq (%rcx,%r12,8), %r9
movq %rbp, %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xac68
movb $0x1, 0xfa(%rbp)
movq 0x88(%r13), %rax
cmpb $0x0, 0x981(%rax)
je 0x1cf87
movq $0x0, 0x10(%rbp)
cmpb $0x0, 0x982(%rax)
je 0x1cf98
movq $0x0, 0x18(%rbp)
cmpb $0x0, 0x983(%rax)
je 0x1cfa9
movq $0x0, 0x20(%rbp)
movq %rbp, %rdi
movl $0x2, %esi
callq 0xaf08
movq %rbp, %rdi
movl $0x7, %esi
callq 0xaf08
movq %rbp, %rdi
movl $0x3, %esi
callq 0xaf08
movq 0x88(%r13), %rax
cmpb $0x3, 0x3f(%rax)
jne 0x1cff7
movq %rbp, %rdi
movl $0x4, %esi
callq 0xaf08
movq %rbp, %rdi
movl $0x6, %esi
callq 0xaf08
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x14dc4
movl 0x80(%rsp), %r15d
movsd 0x88(%rsp), %xmm0
movsd 0x98(%rsp), %xmm1
movq %r13, %rax
movl 0xa0(%rsp), %r13d
movq 0x88(%rax), %rax
movl 0x38(%rax), %ecx
incl %ebx
cmpl %ecx, %r15d
movl $0x0, %edx
cmovnel %edx, %ebx
movq 0x40(%rsp), %rdx
movl %ebx, (%rdx,%r12,4)
movl 0x24(%rsp), %edx
cmpl 0x6c(%rsp), %edx
jge 0x1d076
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %r15
movq 0x30(%rsp), %rsi
movq 0x40(%rsp), %rax
movl 0xc(%rsp), %edi
jmp 0x1d165
cmpl $0x1, %r15d
movq 0x30(%rsp), %rsi
movl 0xc(%rsp), %edi
movl 0x48(%rsp), %r8d
je 0x1d0b2
cmpl 0x18(%rsp), %r8d
je 0x1d0b2
movq 0x28(%rsp), %rcx
movl $0x0, (%rcx,%r12,4)
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %r15
movq 0x40(%rsp), %rax
jmp 0x1d16a
incl %r14d
movq 0x28(%rsp), %rdx
movl %r14d, (%rdx,%r12,4)
cmpl %edi, %r14d
je 0x1d0d4
cmpl 0x18(%rsp), %r8d
je 0x1d0d4
movq 0x10(%rsp), %r13
jmp 0x1d15b
cmpl 0x18(%rsp), %r8d
jne 0x1d0e4
movq 0x28(%rsp), %rdx
movl %edi, (%rdx,%r12,4)
cmpl %ecx, %r15d
sete %cl
incl 0x38(%rsp)
testl %r13d, %r13d
setne %dl
cmpb $0x0, 0x3c(%rax)
jne 0x1d0ca
orb %cl, %dl
je 0x1d0ca
movl 0xe8(%rbp), %esi
movq 0xf0(%rbp), %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movsd %xmm0, 0x78(%rsp)
movsd %xmm1, 0x60(%rsp)
callq 0x11a86
leaq 0x18801(%rip), %rdi     # 0x3592c
movl 0x24(%rsp), %esi
movl 0x38(%rsp), %edx
movl %r12d, %ecx
movl %r15d, %r8d
movsd 0x78(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movl %r13d, %r9d
movq %rbx, %r13
movb $0x2, %al
callq 0x4050
movl 0xc(%rsp), %edi
movq 0x30(%rsp), %rsi
movq 0x18(%rsp), %r15
movq 0x40(%rsp), %rax
movq 0x28(%rsp), %rcx
incq %r12
cmpq %rsi, %r12
jge 0x1d17c
cmpl %esi, 0x38(%rsp)
jl 0x1cedd
movl $0x110, %edi            # imm = 0x110
movq %rsi, %rbx
callq 0x4210
movq %rax, %r14
movq 0x88(%r13), %rax
movsd 0x28(%rax), %xmm0
movq %r14, %rdi
movl 0x54(%rsp), %esi
movl 0x50(%rsp), %edx
movl %r15d, %ecx
movl %ebx, %r8d
movl $0x1, %r9d
callq 0xa850
movq 0x88(%r13), %rax
movq 0x98(%r13), %rsi
movl 0x8dc(%rax), %r8d
movq 0x8f0(%rax), %r9
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xac68
movq %r14, %rdi
movl $0x2, %esi
callq 0xaf08
movq %r14, %rdi
movl $0x3, %esi
callq 0xaf08
movq 0x88(%r13), %rax
cmpb $0x3, 0x3f(%rax)
jne 0x1d21d
movq %r14, %rdi
movl $0x4, %esi
callq 0xaf08
movq %r14, %rdi
movl $0x6, %esi
callq 0xaf08
movl 0xe8(%r14), %esi
movq 0xf0(%r14), %rdx
movq %r13, %rdi
callq 0x11a86
movb 0x80(%r13), %bl
movb $0x0, 0x80(%r13)
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x14dc4
movb %bl, 0x80(%r13)
movq %r14, %rdi
callq 0xa8f2
movl $0x110, %esi            # imm = 0x110
movq %r14, %rdi
callq 0x4220
incl 0x24(%rsp)
movl 0x48(%rsp), %edx
cmpl %r15d, %edx
movq 0x30(%rsp), %rsi
jl 0x1cbd9
cmpl %esi, 0x38(%rsp)
jl 0x1cbd9
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x1d2a0
callq 0x42a0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1d2af
callq 0x42a0
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x1d2be
callq 0x42a0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1d2cd
callq 0x42a0
movq 0x88(%r13), %rax
movl 0x8dc(%rax), %esi
movq 0x8f0(%rax), %rdx
movq %r13, %rdi
callq 0x1161c
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1d304
movq %r14, %rdi
jmp 0x1d307
jmp 0x1d304
movq %rbp, %rdi
movq %rax, %rbx
movl $0x110, %esi            # imm = 0x110
callq 0x4220
movq %rbx, %rdi
callq 0x4430