// File: 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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x33ed4(%rip), %rsi     # 0x5058a
callq 0x5370
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1c6ec
movq 0x3e90b(%rip), %rax     # 0x5afd8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x33eb1(%rip), %rsi     # 0x5058c
movb $0x0, %al
callq 0x5440
movl $0x1, %edi
callq 0x5390
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rdi
movq 0x88(%rax), %rsi
callq 0xbc70
movq -0x18(%rbp), %rdi
leaq 0x33ea3(%rip), %rsi     # 0x505ae
movb $0x0, %al
callq 0x5440
movb $0x0, -0x19(%rbp)
movq -0x40(%rbp), %rcx
movsbl -0x19(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1c7aa
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq 0x18(%rcx), %rax
movsbq -0x19(%rbp), %rdx
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, -0x48(%rbp)
movsbl -0x19(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1c775
leaq 0x33236(%rip), %rax     # 0x4f9a5
movq %rax, -0x58(%rbp)
jmp 0x1c782
leaq 0x344fe(%rip), %rax     # 0x50c7a
movq %rax, -0x58(%rbp)
jmp 0x1c782
movsd -0x48(%rbp), %xmm0
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rdx
leaq 0x33e2b(%rip), %rsi     # 0x505c1
movb $0x1, %al
callq 0x5440
movb -0x19(%rbp), %al
addb $0x1, %al
movb %al, -0x19(%rbp)
jmp 0x1c716
leaq -0x28(%rbp), %rdi
callq 0x170b0
movl $0x0, -0x20(%rbp)
movq -0x40(%rbp), %rcx
movl -0x20(%rbp), %eax
movq 0x88(%rcx), %rcx
cmpl 0x8c0(%rcx), %eax
jge 0x1cb40
movq -0x40(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x948(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x27d20
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x5c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x17160
movq %rax, %rdi
addq $0x8, %rdi
callq 0x5110
movq -0x68(%rbp), %rdi
movl -0x5c(%rbp), %edx
movq %rax, %rcx
leaq 0x33d9c(%rip), %rsi     # 0x505cb
movb $0x0, %al
callq 0x5440
movq -0x18(%rbp), %rdi
leaq 0x33d91(%rip), %rsi     # 0x505d2
movb $0x0, %al
callq 0x5440
movb $0x0, -0x31(%rbp)
movq -0x40(%rbp), %rcx
movsbl -0x31(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1c8ec
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
movq 0x38(%rcx), %rax
movslq -0x20(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movsbq -0x31(%rbp), %rdx
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, -0x70(%rbp)
movsbl -0x31(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1c8b7
leaq 0x330f4(%rip), %rax     # 0x4f9a5
movq %rax, -0x80(%rbp)
jmp 0x1c8c4
leaq 0x343bc(%rip), %rax     # 0x50c7a
movq %rax, -0x80(%rbp)
jmp 0x1c8c4
movsd -0x70(%rbp), %xmm0
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rdx
leaq 0x3408b(%rip), %rsi     # 0x50963
movb $0x1, %al
callq 0x5440
movb -0x31(%rbp), %al
addb $0x1, %al
movb %al, -0x31(%rbp)
jmp 0x1c84c
movq -0x18(%rbp), %rdi
leaq 0x33cdf(%rip), %rsi     # 0x505d6
movb $0x0, %al
callq 0x5440
movb $0x0, -0x31(%rbp)
movq -0x40(%rbp), %rcx
movsbl -0x31(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1ca0e
movb $0x0, -0x32(%rbp)
movq -0x40(%rbp), %rcx
movsbl -0x32(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1c9ff
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rax, -0x90(%rbp)
movq 0x40(%rcx), %rax
movslq -0x20(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movsbq -0x31(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movsbq -0x32(%rbp), %rdx
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, -0x88(%rbp)
movsbl -0x31(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1c9be
movq -0x40(%rbp), %rcx
movsbl -0x32(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1c9be
leaq 0x32ff0(%rip), %rax     # 0x4f9a5
movq %rax, -0x98(%rbp)
jmp 0x1c9ce
leaq 0x342b5(%rip), %rax     # 0x50c7a
movq %rax, -0x98(%rbp)
jmp 0x1c9ce
movsd -0x88(%rbp), %xmm0
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rdx
leaq 0x33f78(%rip), %rsi     # 0x50963
movb $0x1, %al
callq 0x5440
movb -0x32(%rbp), %al
addb $0x1, %al
movb %al, -0x32(%rbp)
jmp 0x1c924
jmp 0x1ca01
movb -0x31(%rbp), %al
addb $0x1, %al
movb %al, -0x31(%rbp)
jmp 0x1c902
movq -0x18(%rbp), %rdi
leaq 0x33bc0(%rip), %rsi     # 0x505d9
movb $0x0, %al
callq 0x5440
movb $0x0, -0x31(%rbp)
movq -0x40(%rbp), %rcx
movsbl -0x31(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1cb30
movb $0x0, -0x33(%rbp)
movq -0x40(%rbp), %rcx
movsbl -0x33(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1cb21
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq 0x48(%rcx), %rax
movslq -0x20(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movsbq -0x31(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movsbq -0x33(%rbp), %rdx
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsbl -0x31(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1cae0
movq -0x40(%rbp), %rcx
movsbl -0x33(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1cae0
leaq 0x32ece(%rip), %rax     # 0x4f9a5
movq %rax, -0xb0(%rbp)
jmp 0x1caf0
leaq 0x34193(%rip), %rax     # 0x50c7a
movq %rax, -0xb0(%rbp)
jmp 0x1caf0
movsd -0xa0(%rbp), %xmm0
movq -0xa8(%rbp), %rdi
movq -0xb0(%rbp), %rdx
leaq 0x33e56(%rip), %rsi     # 0x50963
movb $0x1, %al
callq 0x5440
movb -0x33(%rbp), %al
addb $0x1, %al
movb %al, -0x33(%rbp)
jmp 0x1ca46
jmp 0x1cb23
movb -0x31(%rbp), %al
addb $0x1, %al
movb %al, -0x31(%rbp)
jmp 0x1ca24
jmp 0x1cb32
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1c7ba
movq -0x18(%rbp), %rdi
callq 0x52c0
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)