// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/HMMProblem.cpp
// Function: HMMProblem::toFileSkill(char const*)
void HMMProblem::toFileSkill(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," %10.7f%s",this->null_obs_ratio[m],(m==(this->p->nO-1))?"\n":"\t");
    
	NCAT k;
	std::map<NCAT,std::string>::iterator it;
	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());
		NPAR i,j,m;
		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,"A\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 $0x18, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x22bd3(%rip), %rsi     # 0x354b6
movq %r15, %rdi
callq 0x4290
testq %rax, %rax
je 0x12c9f
movq %rax, %r13
movq 0x88(%rbx), %rsi
movq %rax, %rdi
callq 0xa118
leaq 0x22bcd(%rip), %rdi     # 0x354da
movl $0x12, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x4480
movq 0x88(%rbx), %rax
movb 0x8b9(%rax), %al
leaq 0x2192a(%rip), %rbp     # 0x3425d
leaq 0x2326c(%rip), %r14     # 0x35ba6
testb %al, %al
movq %rbx, (%rsp)
jle 0x1298e
xorl %r15d, %r15d
leaq 0x22ba1(%rip), %r12     # 0x354ed
movsbl %al, %eax
decl %eax
movq %rbp, %rdx
cmpl %eax, %r15d
je 0x1295c
movq %r14, %rdx
movq 0x18(%rbx), %rax
movsd (%rax,%r15,8), %xmm0
movq %r13, %rdi
movq %r12, %rsi
movb $0x1, %al
callq 0x4330
movq (%rsp), %rbx
incq %r15
movq 0x88(%rbx), %rax
movsbq 0x8b9(%rax), %rax
cmpq %rax, %r15
jl 0x1294c
movq 0x88(%rbx), %rax
cmpl $0x0, 0x8c0(%rax)
jle 0x12c89
leaq 0x22ee6(%rip), %rbx     # 0x3588f
xorl %r12d, %r12d
movq %r13, 0x8(%rsp)
movq 0x948(%rax), %rax
movq 0x10(%rax), %rdx
addq $0x8, %rax
movq %rax, %rcx
testq %rdx, %rdx
je 0x129e6
movq %rax, %rcx
movslq 0x20(%rdx), %rsi
xorl %edi, %edi
cmpq %rsi, %r12
setg %dil
cmovleq %rdx, %rcx
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0x129cb
cmpq %rax, %rcx
je 0x129f6
movslq 0x20(%rcx), %rdx
cmpq %rdx, %r12
cmovgeq %rcx, %rax
movq 0x28(%rax), %rcx
movq %r13, %rdi
leaq 0x22af3(%rip), %rsi     # 0x354f7
movl %r12d, %edx
xorl %eax, %eax
callq 0x4330
movl $0x3, %esi
movl $0x1, %edx
leaq 0x22adf(%rip), %rdi     # 0x354fe
movq %r13, %rcx
callq 0x4480
movq (%rsp), %rcx
movq 0x88(%rcx), %rax
movb 0x8b8(%rax), %al
testb %al, %al
jle 0x12a84
xorl %r15d, %r15d
movsbl %al, %eax
movq 0x38(%rcx), %rcx
movq (%rcx,%r12,8), %rcx
movsd (%rcx,%r15,8), %xmm0
decl %eax
cmpl %eax, %r15d
movq %r14, %rdx
cmoveq %rbp, %rdx
movq %r13, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x4330
movq (%rsp), %rcx
incq %r15
movq 0x88(%rcx), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %r15
jl 0x12a3f
movq %r12, 0x10(%rsp)
movl $0x2, %esi
movl $0x1, %edx
leaq 0x22a68(%rip), %rdi     # 0x35502
movq %r13, %rcx
callq 0x4480
movq (%rsp), %rcx
movq 0x88(%rcx), %rax
cmpb $0x0, 0x8b8(%rax)
jle 0x12b68
xorl %r14d, %r14d
movq 0x88(%rcx), %rax
movb 0x8b8(%rax), %al
testb %al, %al
leaq 0x2178a(%rip), %r13     # 0x3425d
leaq 0x230cc(%rip), %r12     # 0x35ba6
movq 0x8(%rsp), %rdi
leaq 0x22da9(%rip), %rsi     # 0x3588f
movq 0x10(%rsp), %rbp
jle 0x12b4d
xorl %r15d, %r15d
movsbl %al, %eax
movq 0x40(%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movq (%rcx,%r14,8), %rcx
movsd (%rcx,%r15,8), %xmm0
decl %eax
movl %r15d, %ecx
xorl %eax, %ecx
xorl %r14d, %eax
orl %ecx, %eax
movq %r12, %rdx
cmoveq %r13, %rdx
movq %rdi, %rbx
movb $0x1, %al
movq %rsi, %r13
callq 0x4330
movq %r13, %rsi
movq %rbx, %rdi
leaq 0x2172b(%rip), %r13     # 0x3425d
movq (%rsp), %rcx
incq %r15
movq 0x88(%rcx), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %r15
jl 0x12af0
incq %r14
movq 0x88(%rcx), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %r14
jl 0x12abd
movl $0x2, %esi
movl $0x1, %edx
leaq 0x2298c(%rip), %rdi     # 0x35505
movq 0x8(%rsp), %rcx
callq 0x4480
movq (%rsp), %rdx
movq 0x88(%rdx), %rax
cmpb $0x0, 0x8b8(%rax)
jle 0x12c50
xorl %r14d, %r14d
movq 0x88(%rdx), %rax
movb 0x8b9(%rax), %cl
testb %cl, %cl
leaq 0x216a9(%rip), %r13     # 0x3425d
leaq 0x22feb(%rip), %r12     # 0x35ba6
movq 0x8(%rsp), %rdi
leaq 0x22cc8(%rip), %rsi     # 0x3588f
movq 0x10(%rsp), %rbp
jle 0x12c35
xorl %r15d, %r15d
movsbl %cl, %ecx
movq 0x48(%rdx), %rdx
movq (%rdx,%rbp,8), %rdx
movq (%rdx,%r14,8), %rdx
movsd (%rdx,%r15,8), %xmm0
movsbl 0x8b8(%rax), %eax
decl %eax
xorl %r14d, %eax
decl %ecx
xorl %r15d, %ecx
orl %eax, %ecx
movq %r12, %rdx
cmoveq %r13, %rdx
movb $0x1, %al
movq %rdi, %rbx
movq %rsi, %r13
callq 0x4330
movq %r13, %rsi
movq %rbx, %rdi
leaq 0x21643(%rip), %r13     # 0x3425d
movq (%rsp), %rdx
incq %r15
movq 0x88(%rdx), %rax
movsbq 0x8b9(%rax), %rcx
cmpq %rcx, %r15
jl 0x12bd1
incq %r14
movq 0x88(%rdx), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %r14
jl 0x12b9e
movq 0x10(%rsp), %r12
incq %r12
movq 0x88(%rdx), %rax
movslq 0x8c0(%rax), %rcx
cmpq %rcx, %r12
leaq 0x215ed(%rip), %rbp     # 0x3425d
leaq 0x22f2f(%rip), %r14     # 0x35ba6
movq 0x8(%rsp), %r13
leaq 0x22c0c(%rip), %rbx     # 0x3588f
jl 0x129b1
movq %r13, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4200
movq %r15, %rdi
callq 0x4b90
nop