// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/HMMProblemAGK.cpp
// Function: HMMProblemAGK::toFile(char const*)
void HMMProblemAGK::toFile(const char *filename) {
	FILE *fid = fopen(filename,"w");
	if(fid == NULL) {
		fprintf(stderr,"Can't write output model file %s\n",filename);
		exit(1);
	}
    
    // write solved id
    writeSolverInfo(fid, this->p);
    
	fprintf(fid,"Null skill ratios\t");
	for(NPAR m=0; m<this->p->nO; m++)
		fprintf(fid," %12.10f%s",this->null_obs_ratio[m],(m==(this->p->nO-1))?"\n":"\t");
	NCAT k, g;
    NPAR i,j,m;
	std::map<NCAT,std::string>::iterator it;
	for(g=0;g<this->p->nG; g++) {
		it = this->p->map_group_bwd->find(g);
		fprintf(fid,"%d\t%s\n",g,it->second.c_str());
		fprintf(fid,"Ag\t");
		for(i=0; i<this->p->nS; i++)
			for(j=0; j<this->p->nS; j++)
				fprintf(fid,"%12.10f%s",this->Ag[g][i][j],(i==(this->p->nS-1) && j==(this->p->nS-1))?"\n":"\t");
    }
	for(k=0;k<this->p->nK;k++) {
		it = this->p->map_skill_bwd->find(k);
		fprintf(fid,"%d\t%s\n",k,it->second.c_str());
		fprintf(fid,"PI\t");
		for(i=0; i<this->p->nS; i++)
			fprintf(fid,"%12.10f%s",this->pi[k][i],(i==(this->p->nS-1))?"\n":"\t");
		fprintf(fid,"Ak\t");
		for(i=0; i<this->p->nS; i++)
			for(j=0; j<this->p->nS; j++)
				fprintf(fid,"%12.10f%s",this->A[k][i][j],(i==(this->p->nS-1) && j==(this->p->nS-1))?"\n":"\t");
		fprintf(fid,"B\t");
		for(i=0; i<this->p->nS; i++)
			for(m=0; m<this->p->nO; m++)
				fprintf(fid,"%12.10f%s",this->B[k][i][m],(i==(this->p->nS-1) && m==(this->p->nO-1))?"\n":"\t");
	}
	fclose(fid);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r15
movq %rdi, 0x8(%rsp)
leaq 0x16e05(%rip), %rsi     # 0x354b6
movq %r15, %rdi
callq 0x4290
testq %rax, %rax
je 0x1ec1e
movq %rax, %r14
movq 0x8(%rsp), %rbx
movq 0x88(%rbx), %rsi
movq %rax, %rdi
callq 0xa118
leaq 0x16dfa(%rip), %rdi     # 0x354da
movl $0x12, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x4480
movq 0x88(%rbx), %rax
movb 0x8b9(%rax), %al
leaq 0x15b57(%rip), %r13     # 0x3425d
testb %al, %al
jle 0x1e75b
xorl %r15d, %r15d
leaq 0x1717a(%rip), %r12     # 0x3588e
movq 0x8(%rsp), %rbx
movsbl %al, %eax
decl %eax
movq %r13, %rdx
cmpl %eax, %r15d
je 0x1e72d
leaq 0x17479(%rip), %rdx     # 0x35ba6
movq 0x18(%rbx), %rax
movsd (%rax,%r15,8), %xmm0
movq %r14, %rdi
movq %r12, %rsi
movb $0x1, %al
callq 0x4330
incq %r15
movq 0x88(%rbx), %rax
movsbq 0x8b9(%rax), %rax
cmpq %rax, %r15
jl 0x1e719
movq %r14, 0x10(%rsp)
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
cmpl $0x0, 0x8bc(%rax)
jle 0x1e8e3
xorl %edx, %edx
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %rbx
movq 0x928(%rax), %rax
movq 0x10(%rax), %r8
addq $0x8, %rax
movq %rax, %rcx
testq %r8, %r8
je 0x1e7ba
movq %rax, %rcx
movslq 0x20(%r8), %rsi
xorl %edi, %edi
cmpq %rsi, %rdx
setg %dil
cmovleq %r8, %rcx
movq 0x10(%r8,%rdi,8), %r8
testq %r8, %r8
jne 0x1e79f
cmpq %rax, %rcx
movq 0x10(%rsp), %r14
je 0x1e7cf
movslq 0x20(%rcx), %rsi
cmpq %rsi, %rdx
cmovgeq %rcx, %rax
movq 0x28(%rax), %rcx
movq %r14, %rdi
leaq 0x16d1a(%rip), %rsi     # 0x354f7
movq %rdx, 0x20(%rsp)
xorl %eax, %eax
callq 0x4330
movl $0x3, %esi
movl $0x1, %edx
leaq 0x1720e(%rip), %rdi     # 0x35a08
movq %r14, %rcx
callq 0x4480
movq 0x88(%rbx), %rax
cmpb $0x0, 0x8b8(%rax)
jle 0x1e8c4
xorl %r8d, %r8d
movq 0x88(%rbx), %rax
movb 0x8b8(%rax), %al
testb %al, %al
leaq 0x15a2e(%rip), %rsi     # 0x3425d
leaq 0x17370(%rip), %rbp     # 0x35ba6
movq 0x20(%rsp), %r12
jle 0x1e8a9
xorl %r15d, %r15d
movsbl %al, %eax
movq 0x8(%rsp), %rcx
movq 0x90(%rcx), %rcx
movq (%rcx,%r12,8), %rcx
movq (%rcx,%r8,8), %rcx
movsd (%rcx,%r15,8), %xmm0
decl %eax
movl %r15d, %ecx
xorl %eax, %ecx
xorl %r8d, %eax
orl %ecx, %eax
movq %rbp, %rdx
cmoveq %rsi, %rdx
movq %r13, %rdi
movq %rsi, %r14
leaq 0x17012(%rip), %rsi     # 0x3588f
movb $0x1, %al
movq %r8, %rbx
callq 0x4330
movq %rbx, %r8
movq 0x8(%rsp), %rbx
movq %r14, %rsi
incq %r15
movq 0x88(%rbx), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %r15
jl 0x1e840
incq %r8
movq 0x88(%rbx), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %r8
jl 0x1e819
movq 0x20(%rsp), %rdx
incq %rdx
movq 0x88(%rbx), %rax
movslq 0x8bc(%rax), %rcx
cmpq %rcx, %rdx
jl 0x1e780
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
cmpl $0x0, 0x8c0(%rax)
jle 0x1ec06
leaq 0x16f8c(%rip), %r14     # 0x3588f
xorl %edx, %edx
movq 0x948(%rax), %rax
movq 0x10(%rax), %r8
addq $0x8, %rax
movq %rax, %rcx
testq %r8, %r8
movq 0x10(%rsp), %r15
je 0x1e93f
movq %rax, %rcx
movslq 0x20(%r8), %rsi
xorl %edi, %edi
cmpq %rsi, %rdx
setg %dil
cmovleq %r8, %rcx
movq 0x10(%r8,%rdi,8), %r8
testq %r8, %r8
jne 0x1e924
cmpq %rax, %rcx
leaq 0x15914(%rip), %r13     # 0x3425d
leaq 0x17256(%rip), %r12     # 0x35ba6
je 0x1e95d
movslq 0x20(%rcx), %rsi
cmpq %rsi, %rdx
cmovgeq %rcx, %rax
movq 0x28(%rax), %rcx
movq %r15, %rdi
leaq 0x16b8c(%rip), %rsi     # 0x354f7
xorl %eax, %eax
movq %rdx, 0x18(%rsp)
callq 0x4330
movl $0x3, %esi
movl $0x1, %edx
leaq 0x16b76(%rip), %rdi     # 0x354fe
movq %r15, %rcx
callq 0x4480
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movb 0x8b8(%rax), %al
testb %al, %al
movq %r15, %rbp
jle 0x1e9f7
xorl %r15d, %r15d
movsbl %al, %eax
movq 0x8(%rsp), %rbx
movq 0x38(%rbx), %rcx
movq 0x18(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movsd (%rcx,%r15,8), %xmm0
decl %eax
cmpl %eax, %r15d
movq %r12, %rdx
cmoveq %r13, %rdx
movq %rbp, %rdi
movq %r14, %rsi
movb $0x1, %al
callq 0x4330
incq %r15
movq 0x88(%rbx), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %r15
jl 0x1e9ac
movl $0x3, %esi
movl $0x1, %edx
leaq 0x17004(%rip), %rdi     # 0x35a0c
movq %rbp, %rcx
callq 0x4480
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
cmpb $0x0, 0x8b8(%rax)
jle 0x1eae5
xorl %edi, %edi
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movb 0x8b8(%rax), %al
testb %al, %al
leaq 0x15817(%rip), %r12     # 0x3425d
leaq 0x17159(%rip), %rdx     # 0x35ba6
movq 0x10(%rsp), %r14
leaq 0x16e36(%rip), %rbx     # 0x3588f
movq 0x18(%rsp), %rbp
jle 0x1eac5
xorl %r15d, %r15d
movq %rdi, 0x20(%rsp)
movsbl %al, %eax
movq 0x8(%rsp), %rcx
movq 0x40(%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movq (%rcx,%rdi,8), %rcx
movsd (%rcx,%r15,8), %xmm0
decl %eax
movl %r15d, %ecx
xorl %eax, %ecx
xorl %edi, %eax
orl %ecx, %eax
movq %rdx, %r13
cmoveq %r12, %rdx
movq %r14, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x4330
movq 0x20(%rsp), %rdi
movq %r13, %rdx
incq %r15
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %r15
jl 0x1ea68
incq %rdi
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %rdi
jl 0x1ea2b
movl $0x2, %esi
movl $0x1, %edx
leaq 0x16a0f(%rip), %rdi     # 0x35505
movq 0x10(%rsp), %rcx
callq 0x4480
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
cmpb $0x0, 0x8b8(%rax)
jle 0x1ebdb
xorl %r12d, %r12d
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movb 0x8b9(%rax), %cl
testb %cl, %cl
leaq 0x15726(%rip), %rbx     # 0x3425d
leaq 0x17068(%rip), %r14     # 0x35ba6
movq 0x10(%rsp), %rdi
leaq 0x16d45(%rip), %rbp     # 0x3588f
movq 0x18(%rsp), %r13
jle 0x1ebbb
xorl %r15d, %r15d
movsbl %cl, %ecx
movq 0x8(%rsp), %rdx
movq 0x48(%rdx), %rdx
movq (%rdx,%r13,8), %rdx
movq (%rdx,%r12,8), %rdx
movsd (%rdx,%r15,8), %xmm0
movsbl 0x8b8(%rax), %eax
decl %eax
xorl %r12d, %eax
decl %ecx
xorl %r15d, %ecx
orl %eax, %ecx
movq %r14, %rdx
cmoveq %rbx, %rdx
movq %rbp, %rsi
movb $0x1, %al
movq %rdi, %r14
callq 0x4330
movq %r14, %rdi
leaq 0x17007(%rip), %r14     # 0x35ba6
incq %r15
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movsbq 0x8b9(%rax), %rcx
cmpq %rcx, %r15
jl 0x1eb54
incq %r12
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %r12
jl 0x1eb1c
movq 0x18(%rsp), %rdx
incq %rdx
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movslq 0x8c0(%rax), %rcx
cmpq %rcx, %rdx
leaq 0x16c8f(%rip), %r14     # 0x3588f
jl 0x1e905
movq 0x10(%rsp), %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4200
movq %r15, %rdi
callq 0x4f43