// File: /workspace/github_cpp_makefile_star2_O2/myudelson[P]hmm-scalable/HMMProblemSlicedAB.cpp
// Function: HMMProblemSlicedAB::readModelBody(_IO_FILE*, param*, int*, bool)
void HMMProblemSlicedAB::readModelBody(FILE *fid, struct param* param, NDAT *line_no,  bool overwrite) {
	NPAR i,j,m,z, slice;
	NCAT k = 0, idxk = 0;
    std::map<std::string,NCAT>::iterator it;
	string s;
    char col[2048];
    //
    readNullObsRatio(fid, param, line_no);
    //
    // init param
    //
    if(overwrite) {
        this->p->map_group_fwd = new map<string,NCAT>();
        this->p->map_group_bwd = new map<NCAT,string>();
        this->p->map_skill_fwd = new map<string,NCAT>();
        this->p->map_skill_bwd = new map<NCAT,string>();
    }
	//
	// read skills
	//
	for(k=0; k<param->nK; k++) {
		// read skill label
        fscanf(fid,"%*s\t%[^\n]\n",col);
        s = string( col );
        (*line_no)++;
        if(overwrite) {
            this->p->map_skill_fwd->insert(pair<string,NCAT>(s, (NCAT)this->p->map_skill_fwd->size()));
            this->p->map_skill_bwd->insert(pair<NCAT,string>((NCAT)this->p->map_skill_bwd->size(), s));
            idxk = k;
        } else {
            it = this->p->map_skill_fwd->find(s);
            if( it==this->p->map_skill_fwd->end() ) { // not found, skip 3 lines and continue
                fscanf(fid, "%*[^\n]\n");
                fscanf(fid, "%*[^\n]\n");
                fscanf(fid, "%*[^\n]\n");
                (*line_no)+=3;
                continue; // skip this iteration
            }
            else
                idxk =it->second;
        }
        // read PI
        fscanf(fid,"PI\t");
        for(i=0; i<(this->p->nS-1); i++) { // read 1 less then necessary
            fscanf(fid,"%[^\t]\t",col);
            this->pi[idxk][i] = atof(col);
        }
        fscanf(fid,"%[^\n]\n",col);// read last one
        this->pi[idxk][i] = atof(col);
        (*line_no)++;
        // read A
        for(z=0; z<param->nZ; z++) {
            fscanf(fid,"A - slice %hhu\t",&slice);
            for(i=0; i<this->p->nS; i++)
                for(j=0; j<this->p->nS; j++) {
                    if(i==(this->p->nS-1) && j==(this->p->nS-1)) {
                        fscanf(fid,"%[^\n]\n", col); // last one;
                        this->A[idxk][z][i][j] = atof(col);
                    }
                    else {
                        fscanf(fid,"%[^\t]\t", col); // not las one
                        this->A[idxk][z][i][j] = atof(col);
                    }
                }
            (*line_no)++;
        }
        // read B
        for(z=0; z<param->nZ; z++) {
            fscanf(fid,"B - slice %hhu\t",&slice);
            for(i=0; i<this->p->nS; i++)
                for(m=0; m<this->p->nO; m++) {
                    if(i==(this->p->nS-1) && m==(this->p->nO-1)) {
                        fscanf(fid,"%[^\n]\n", col); // last one;
                        this->B[idxk][z][i][m] = atof(col);
                    }
                    else {
                        fscanf(fid,"%[^\t]\t", col); // not las one
                        this->B[idxk][z][i][m] = atof(col);
                    }
                }
            (*line_no)++;
        }
	} // for all k
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x888, %rsp            # imm = 0x888
movl %r8d, 0x28(%rsp)
movq %rdi, %r13
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rsi, 0x10(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x20(%rsp)
callq 0x15374
cmpb $0x0, 0x28(%rsp)
je 0x246c0
pushq $0x30
popq %rdi
callq 0x4220
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
andq $0x0, 0x28(%rax)
movq 0x88(%r13), %rbx
movq %rax, 0x920(%rbx)
pushq $0x30
popq %rdi
callq 0x4220
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
andq $0x0, 0x28(%rax)
movq %rax, 0x928(%rbx)
pushq $0x30
popq %rdi
callq 0x4220
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
andq $0x0, 0x28(%rax)
movq %rax, 0x940(%rbx)
pushq $0x30
popq %rdi
callq 0x4220
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
andq $0x0, 0x28(%rax)
movq %rax, 0x948(%rbx)
leaq 0x80(%rsp), %rbp
leaq 0x38(%rsp), %r15
leaq 0x60(%rsp), %r12
xorl %ecx, %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x2c(%rsp)
cmpl 0x8c0(%rax), %ecx
jge 0x24a58
movq 0x10(%rsp), %rdi
leaq 0x9172(%rip), %rsi      # 0x2d867
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4480
movq %r15, %rdi
movq %rbp, %rsi
leaq 0x1f(%rsp), %rdx
callq 0x7dea
movq %r12, %rdi
movq %r15, %rsi
callq 0x42b0
movq %r15, %rdi
callq 0x40f0
movq 0x20(%rsp), %rax
incl (%rax)
movq 0x88(%r13), %rax
movq 0x940(%rax), %r14
cmpb $0x0, 0x28(%rsp)
je 0x247a1
movq 0x28(%r14), %rbx
movq %r15, %rdi
movq %r12, %rsi
callq 0x4320
movl %ebx, 0x58(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xcf7e
movq %r15, %rdi
callq 0x40f0
movq 0x88(%r13), %rax
movq 0x948(%rax), %rbx
movl 0x28(%rbx), %eax
movl %eax, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x4320
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd16a
leaq 0x40(%rsp), %rdi
callq 0x40f0
movl 0x2c(%rsp), %ebx
jmp 0x247ca
movq %r14, %rdi
movq %r12, %rsi
callq 0xce76
movq 0x88(%r13), %rcx
movq 0x940(%rcx), %rcx
addq $0x8, %rcx
cmpq %rcx, %rax
je 0x24a0c
movl 0x40(%rax), %ebx
movq 0x10(%rsp), %rdi
leaq 0x8db8(%rip), %rsi      # 0x2d58e
xorl %eax, %eax
callq 0x4480
movslq %ebx, %r14
xorl %ebx, %ebx
movq 0x88(%r13), %rax
movsbl 0x8b8(%rax), %eax
decl %eax
cmpl %ebx, %eax
jle 0x24826
movq 0x10(%rsp), %rdi
leaq 0x9078(%rip), %rsi      # 0x2d87a
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4480
movq %rbp, %rdi
callq 0x42c0
movq 0x38(%r13), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
jmp 0x247e2
movq 0x10(%rsp), %rdi
leaq 0x9039(%rip), %rsi      # 0x2d86b
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4480
movq %rbp, %rdi
callq 0x42c0
movq 0x38(%r13), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%rbx,8)
movq 0x20(%rsp), %rax
incl (%rax)
xorl %ebx, %ebx
movq 0x30(%rsp), %rax
movsbq 0x8c8(%rax), %rax
cmpq %rax, %rbx
jge 0x24931
movq 0x10(%rsp), %rdi
leaq 0x93e9(%rip), %rsi      # 0x2dc65
leaq 0xf(%rsp), %rdx
xorl %eax, %eax
callq 0x4480
movq 0x88(%r13), %rax
movb 0x8b8(%rax), %al
xorl %r15d, %r15d
movsbq %al, %rcx
cmpq %rcx, %r15
jge 0x2491d
xorl %r12d, %r12d
movsbq %al, %rcx
cmpq %rcx, %r12
jge 0x24910
movsbl %al, %eax
decl %eax
movl %r12d, %ecx
xorl %eax, %ecx
xorl %r15d, %eax
orl %ecx, %eax
leaq 0x8fb7(%rip), %rsi      # 0x2d87a
leaq 0x8fa1(%rip), %rax      # 0x2d86b
cmoveq %rax, %rsi
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4480
movq %rbp, %rdi
callq 0x42c0
movq 0x90(%r13), %rax
movq (%rax,%r14,8), %rax
movq (%rax,%rbx,8), %rax
movq (%rax,%r15,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
movq 0x88(%r13), %rax
movb 0x8b8(%rax), %al
jmp 0x248a4
incq %r15
leaq 0x60(%rsp), %r12
jmp 0x24898
movq 0x20(%rsp), %rax
incl (%rax)
incq %rbx
leaq 0x38(%rsp), %r15
jmp 0x2485a
xorl %ebx, %ebx
movsbq %al, %rax
cmpq %rax, %rbx
jge 0x24a4d
movq 0x10(%rsp), %rdi
leaq 0x9329(%rip), %rsi      # 0x2dc75
leaq 0xf(%rsp), %rdx
xorl %eax, %eax
callq 0x4480
movq 0x88(%r13), %rax
xorl %r15d, %r15d
movsbq 0x8b8(%rax), %rcx
cmpq %rcx, %r15
jge 0x249ed
xorl %r12d, %r12d
movsbq 0x8b9(%rax), %rcx
cmpq %rcx, %r12
jge 0x249e0
movsbl 0x8b8(%rax), %eax
decl %eax
xorl %r15d, %eax
decl %ecx
xorl %r12d, %ecx
orl %eax, %ecx
leaq 0x8ee1(%rip), %rsi      # 0x2d87a
leaq 0x8ecb(%rip), %rax      # 0x2d86b
cmoveq %rax, %rsi
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4480
movq %rbp, %rdi
callq 0x42c0
movq 0x98(%r13), %rax
movq (%rax,%r14,8), %rax
movq (%rax,%rbx,8), %rax
movq (%rax,%r15,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
movq 0x88(%r13), %rax
jmp 0x24972
incq %r15
leaq 0x60(%rsp), %r12
jmp 0x24962
movq 0x20(%rsp), %rax
incl (%rax)
incq %rbx
movq 0x30(%rsp), %rax
movb 0x8c8(%rax), %al
leaq 0x38(%rsp), %r15
jmp 0x24933
movq 0x10(%rsp), %rdi
leaq 0x8e5a(%rip), %rsi      # 0x2d872
xorl %eax, %eax
callq 0x4480
movq 0x10(%rsp), %rdi
leaq 0x8e47(%rip), %rsi      # 0x2d872
xorl %eax, %eax
callq 0x4480
movq 0x10(%rsp), %rdi
leaq 0x8e34(%rip), %rsi      # 0x2d872
xorl %eax, %eax
callq 0x4480
movq 0x20(%rsp), %rax
addl $0x3, (%rax)
movl 0x2c(%rsp), %ecx
incl %ecx
jmp 0x246d4
leaq 0x60(%rsp), %rdi
callq 0x40f0
addq $0x888, %rsp            # imm = 0x888
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x24aa1
jmp 0x24aa1
jmp 0x24aa1
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x24a8e
jmp 0x24aa1
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x40f0
jmp 0x24aa4
jmp 0x24aa1
jmp 0x24aa1
jmp 0x24aa1
jmp 0x24aa1
jmp 0x24aa1
jmp 0x24aa1
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x40f0
movq %rbx, %rdi
callq 0x4450