// File: myudelson[P]hmm-scalable/HMMProblemSlicedA.cpp
// Function: HMMProblemSlicedA::toFileSkill(char const*)
void HMMProblemSlicedA::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\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 $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xb704(%rip), %rsi      # 0x5058a
callq 0x5370
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x44ebc
movq 0x1613b(%rip), %rax     # 0x5afd8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0xb6e1(%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 0xb6d3(%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 0x44f7a
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 0x44f45
leaq 0xaa66(%rip), %rax      # 0x4f9a5
movq %rax, -0x60(%rbp)
jmp 0x44f52
leaq 0xbd2e(%rip), %rax      # 0x50c7a
movq %rax, -0x60(%rbp)
jmp 0x44f52
movsd -0x50(%rbp), %xmm0
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rdx
leaq 0xb9fc(%rip), %rsi      # 0x50962
movb $0x1, %al
callq 0x5440
movb -0x19(%rbp), %al
addb $0x1, %al
movb %al, -0x19(%rbp)
jmp 0x44ee6
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 0x4535a
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 0xb5cc(%rip), %rsi      # 0x505cb
movb $0x0, %al
callq 0x5440
movq -0x18(%rbp), %rdi
leaq 0xb5c1(%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 0x450c5
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 0x4508a
leaq 0xa924(%rip), %rax      # 0x4f9a5
movq %rax, -0x88(%rbp)
jmp 0x4509a
leaq 0xbbe9(%rip), %rax      # 0x50c7a
movq %rax, -0x88(%rbp)
jmp 0x4509a
movsd -0x78(%rbp), %xmm0
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rdx
leaq 0xb8b2(%rip), %rsi      # 0x50963
movb $0x1, %al
callq 0x5440
movb -0x39(%rbp), %al
addb $0x1, %al
movb %al, -0x39(%rbp)
jmp 0x4501c
movb $0x0, -0x21(%rbp)
movq -0x48(%rbp), %rcx
movsbl -0x21(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8c8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x45228
movq -0x18(%rbp), %rdi
movsbl -0x21(%rbp), %edx
leaq 0xbb77(%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 0x45219
movb $0x0, -0x3a(%rbp)
movq -0x48(%rbp), %rcx
movsbl -0x3a(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4520a
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 0x451c9
movq -0x48(%rbp), %rcx
movsbl -0x3a(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x451c9
leaq 0xa7e5(%rip), %rax      # 0x4f9a5
movq %rax, -0xa0(%rbp)
jmp 0x451d9
leaq 0xbaaa(%rip), %rax      # 0x50c7a
movq %rax, -0xa0(%rbp)
jmp 0x451d9
movsd -0x90(%rbp), %xmm0
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %rdx
leaq 0xb76d(%rip), %rsi      # 0x50963
movb $0x1, %al
callq 0x5440
movb -0x3a(%rbp), %al
addb $0x1, %al
movb %al, -0x3a(%rbp)
jmp 0x45123
jmp 0x4520c
movb -0x39(%rbp), %al
addb $0x1, %al
movb %al, -0x39(%rbp)
jmp 0x45101
jmp 0x4521b
movb -0x21(%rbp), %al
addb $0x1, %al
movb %al, -0x21(%rbp)
jmp 0x450c9
movq -0x18(%rbp), %rdi
leaq 0xb3a6(%rip), %rsi      # 0x505d9
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 0x4534a
movb $0x0, -0x3b(%rbp)
movq -0x48(%rbp), %rcx
movsbl -0x3b(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4533b
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq 0x48(%rcx), %rax
movslq -0x20(%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 0x452fa
movq -0x48(%rbp), %rcx
movsbl -0x3b(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x452fa
leaq 0xa6b4(%rip), %rax      # 0x4f9a5
movq %rax, -0xb8(%rbp)
jmp 0x4530a
leaq 0xb979(%rip), %rax      # 0x50c7a
movq %rax, -0xb8(%rbp)
jmp 0x4530a
movsd -0xa8(%rbp), %xmm0
movq -0xb0(%rbp), %rdi
movq -0xb8(%rbp), %rdx
leaq 0xb63c(%rip), %rsi      # 0x50963
movb $0x1, %al
callq 0x5440
movb -0x3b(%rbp), %al
addb $0x1, %al
movb %al, -0x3b(%rbp)
jmp 0x45260
jmp 0x4533d
movb -0x39(%rbp), %al
addb $0x1, %al
movb %al, -0x39(%rbp)
jmp 0x4523e
jmp 0x4534c
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x44f8a
movq -0x18(%rbp), %rdi
callq 0x52c0
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)