// File: myudelson[P]hmm-scalable/HMMProblemSlicedAB.cpp
// Function: HMMProblemSlicedAB::toFileSkill(char const*)
void HMMProblemSlicedAB::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," %12.10f%s",this->null_obs_ratio[m],(m==(this->p->nO-1))?"\n":"\t");
    
	NCAT k;
    NPAR z;
	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");
        for(z=0;z<this->p->nZ;z++) {
            fprintf(fid,"A - slice %d \t",z);
            for(i=0; i<this->p->nS; i++)
                for(j=0; j<this->p->nS; j++)
                    fprintf(fid,"%12.10f%s",this->A[k][z][i][j],(i==(this->p->nS-1) && j==(this->p->nS-1))?"\n":"\t");
            fprintf(fid,"B - slice %d \t",z);
            for(i=0; i<this->p->nS; i++)
                for(m=0; m<this->p->nO; m++)
                    fprintf(fid,"%12.10f%s",this->B[k][z][i][m],(i==(this->p->nS-1) && m==(this->p->nO-1))?"\n":"\t");
        }
	}
	fclose(fid);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x15104(%rip), %rsi     # 0x5058a
callq 0x5370
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x3b4bc
movq 0x1fb3b(%rip), %rax     # 0x5afd8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x150e1(%rip), %rsi     # 0x5058c
movb $0x0, %al
callq 0x5440
movl $0x1, %edi
callq 0x5390
movq -0x48(%rbp), %rax
movq -0x18(%rbp), %rdi
movq 0x88(%rax), %rsi
callq 0xbc70
movq -0x18(%rbp), %rdi
leaq 0x150d3(%rip), %rsi     # 0x505ae
movb $0x0, %al
callq 0x5440
movb $0x0, -0x19(%rbp)
movq -0x48(%rbp), %rcx
movsbl -0x19(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x3b57a
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq 0x18(%rcx), %rax
movsbq -0x19(%rbp), %rdx
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movsbl -0x19(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3b545
leaq 0x14466(%rip), %rax     # 0x4f9a5
movq %rax, -0x60(%rbp)
jmp 0x3b552
leaq 0x1572e(%rip), %rax     # 0x50c7a
movq %rax, -0x60(%rbp)
jmp 0x3b552
movsd -0x50(%rbp), %xmm0
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rdx
leaq 0x153fc(%rip), %rsi     # 0x50962
movb $0x1, %al
callq 0x5440
movb -0x19(%rbp), %al
addb $0x1, %al
movb %al, -0x19(%rbp)
jmp 0x3b4e6
leaq -0x30(%rbp), %rdi
callq 0x170b0
movl $0x0, -0x20(%rbp)
movq -0x48(%rbp), %rcx
movl -0x20(%rbp), %eax
movq 0x88(%rcx), %rcx
cmpl 0x8c0(%rcx), %eax
jge 0x3b96a
movq -0x48(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x948(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x27d20
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x64(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x17160
movq %rax, %rdi
addq $0x8, %rdi
callq 0x5110
movq -0x70(%rbp), %rdi
movl -0x64(%rbp), %edx
movq %rax, %rcx
leaq 0x14fcc(%rip), %rsi     # 0x505cb
movb $0x0, %al
callq 0x5440
movq -0x18(%rbp), %rdi
leaq 0x14fc1(%rip), %rsi     # 0x505d2
movb $0x0, %al
callq 0x5440
movb $0x0, -0x39(%rbp)
movq -0x48(%rbp), %rcx
movsbl -0x39(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x3b6c5
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
movq 0x38(%rcx), %rax
movslq -0x20(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movsbq -0x39(%rbp), %rdx
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, -0x78(%rbp)
movsbl -0x39(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3b68a
leaq 0x14324(%rip), %rax     # 0x4f9a5
movq %rax, -0x88(%rbp)
jmp 0x3b69a
leaq 0x155e9(%rip), %rax     # 0x50c7a
movq %rax, -0x88(%rbp)
jmp 0x3b69a
movsd -0x78(%rbp), %xmm0
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rdx
leaq 0x152b2(%rip), %rsi     # 0x50963
movb $0x1, %al
callq 0x5440
movb -0x39(%rbp), %al
addb $0x1, %al
movb %al, -0x39(%rbp)
jmp 0x3b61c
movb $0x0, -0x21(%rbp)
movq -0x48(%rbp), %rcx
movsbl -0x21(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8c8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x3b95a
movq -0x18(%rbp), %rdi
movsbl -0x21(%rbp), %edx
leaq 0x15577(%rip), %rsi     # 0x50c6d
movb $0x0, %al
callq 0x5440
movb $0x0, -0x39(%rbp)
movq -0x48(%rbp), %rcx
movsbl -0x39(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x3b819
movb $0x0, -0x3a(%rbp)
movq -0x48(%rbp), %rcx
movsbl -0x3a(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x3b80a
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
movq 0x90(%rcx), %rax
movslq -0x20(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movsbq -0x21(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movsbq -0x39(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movsbq -0x3a(%rbp), %rdx
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, -0x90(%rbp)
movsbl -0x39(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3b7c9
movq -0x48(%rbp), %rcx
movsbl -0x3a(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3b7c9
leaq 0x141e5(%rip), %rax     # 0x4f9a5
movq %rax, -0xa0(%rbp)
jmp 0x3b7d9
leaq 0x154aa(%rip), %rax     # 0x50c7a
movq %rax, -0xa0(%rbp)
jmp 0x3b7d9
movsd -0x90(%rbp), %xmm0
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %rdx
leaq 0x1516d(%rip), %rsi     # 0x50963
movb $0x1, %al
callq 0x5440
movb -0x3a(%rbp), %al
addb $0x1, %al
movb %al, -0x3a(%rbp)
jmp 0x3b723
jmp 0x3b80c
movb -0x39(%rbp), %al
addb $0x1, %al
movb %al, -0x39(%rbp)
jmp 0x3b701
movq -0x18(%rbp), %rdi
movsbl -0x21(%rbp), %edx
leaq 0x15454(%rip), %rsi     # 0x50c7c
movb $0x0, %al
callq 0x5440
movb $0x0, -0x39(%rbp)
movq -0x48(%rbp), %rcx
movsbl -0x39(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x3b94b
movb $0x0, -0x3b(%rbp)
movq -0x48(%rbp), %rcx
movsbl -0x3b(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x3b93c
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq 0x98(%rcx), %rax
movslq -0x20(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movsbq -0x21(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movsbq -0x39(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movsbq -0x3b(%rbp), %rdx
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsbl -0x39(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3b8fb
movq -0x48(%rbp), %rcx
movsbl -0x3b(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3b8fb
leaq 0x140b3(%rip), %rax     # 0x4f9a5
movq %rax, -0xb8(%rbp)
jmp 0x3b90b
leaq 0x15378(%rip), %rax     # 0x50c7a
movq %rax, -0xb8(%rbp)
jmp 0x3b90b
movsd -0xa8(%rbp), %xmm0
movq -0xb0(%rbp), %rdi
movq -0xb8(%rbp), %rdx
leaq 0x1503b(%rip), %rsi     # 0x50963
movb $0x1, %al
callq 0x5440
movb -0x3b(%rbp), %al
addb $0x1, %al
movb %al, -0x3b(%rbp)
jmp 0x3b855
jmp 0x3b93e
movb -0x39(%rbp), %al
addb $0x1, %al
movb %al, -0x39(%rbp)
jmp 0x3b833
jmp 0x3b94d
movb -0x21(%rbp), %al
addb $0x1, %al
movb %al, -0x21(%rbp)
jmp 0x3b6c9
jmp 0x3b95c
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3b58a
movq -0x18(%rbp), %rdi
callq 0x52c0
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)