// File: /workspace/github_cpp_makefile_star2_O1/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, 0x34(%rsp)
movq %rdi, %r13
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rsi, 0x10(%rsp)
movq %rdx, 0x20(%rsp)
movq %rcx, 0x28(%rsp)
callq 0x19276
cmpb $0x0, 0x34(%rsp)
je 0x2ac0f
movl $0x30, %edi
callq 0x4210
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq 0x88(%r13), %rbx
movq %rax, 0x920(%rbx)
movl $0x30, %edi
callq 0x4210
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq %rax, 0x928(%rbx)
movl $0x30, %edi
callq 0x4210
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq %rax, 0x940(%rbx)
movl $0x30, %edi
callq 0x4210
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq %rax, 0x948(%rbx)
movq 0x20(%rsp), %rax
cmpl $0x0, 0x8c0(%rax)
jle 0x2b0ca
leaq 0x48(%rsp), %r12
leaq 0x80(%rsp), %rbp
movl $0x0, 0x1c(%rsp)
movq 0x10(%rsp), %rdi
leaq 0xab95(%rip), %rsi      # 0x357d7
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4460
movq %r12, 0x38(%rsp)
movq %rbp, %rdi
callq 0x4100
leaq (%rsp,%rax), %rdx
addq $0x80, %rdx
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xa7c0
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x42c0
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x2ac98
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x4220
movq 0x28(%rsp), %rax
incl (%rax)
cmpb $0x0, 0x34(%rsp)
je 0x2ad67
movq 0x88(%r13), %rax
movq 0x940(%rax), %r15
movq 0x28(%r15), %rbx
movq %r12, 0x38(%rsp)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %r14
movq %r14, %rdi
callq 0xa6c2
movl %ebx, 0x58(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x10240
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x2ad01
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x4220
movq 0x88(%r13), %rax
movq 0x948(%rax), %r15
movl 0x28(%r15), %eax
movl %eax, 0x38(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0xa6c2
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0x1040a
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x2ad61
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4220
movl 0x1c(%rsp), %ebx
jmp 0x2ad9d
movq 0x88(%r13), %rax
movq 0x940(%rax), %rdi
leaq 0x60(%rsp), %rsi
callq 0x10148
movq 0x88(%r13), %rcx
movq 0x940(%rcx), %rcx
addq $0x8, %rcx
cmpq %rcx, %rax
je 0x2b06e
movl 0x40(%rax), %ebx
movq 0x10(%rsp), %rdi
leaq 0xa755(%rip), %rsi      # 0x354fe
xorl %eax, %eax
callq 0x4460
movq 0x88(%r13), %rax
cmpb $0x2, 0x8b8(%rax)
movslq %ebx, %r15
jl 0x2ae13
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
leaq 0xaa19(%rip), %rsi      # 0x357ea
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4460
movq %rbp, %rdi
callq 0x42d0
movq 0x38(%r13), %rax
movq (%rax,%r15,8), %rax
movsbq %bl, %rbx
movsd %xmm0, (%rax,%rbx,8)
incb %bl
movsbl %bl, %eax
movq 0x88(%r13), %rcx
movsbl 0x8b8(%rcx), %ecx
decl %ecx
cmpl %eax, %ecx
jg 0x2adc5
movsbq %bl, %rbx
jmp 0x2ae15
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
leaq 0xa9ba(%rip), %rsi      # 0x357db
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4460
movq %rbp, %rdi
callq 0x42d0
movq 0x38(%r13), %rax
movq (%rax,%r15,8), %rax
movsd %xmm0, (%rax,%rbx,8)
movq 0x28(%rsp), %rax
incl (%rax)
movq 0x20(%rsp), %rax
cmpb $0x0, 0x8c8(%rax)
jle 0x2af54
xorl %r14d, %r14d
movq 0x10(%rsp), %rdi
leaq 0xad5d(%rip), %rsi      # 0x35bc5
leaq 0xf(%rsp), %rdx
xorl %eax, %eax
callq 0x4460
movq 0x88(%r13), %rax
cmpb $0x0, 0x8b8(%rax)
jle 0x2af2f
xorl %ebx, %ebx
movq 0x88(%r13), %rax
movb 0x8b8(%rax), %al
testb %al, %al
jle 0x2af14
xorl %r12d, %r12d
movsbl %al, %eax
decl %eax
movl %r12d, %ecx
xorl %eax, %ecx
xorl %ebx, %eax
orl %ecx, %eax
jne 0x2aec6
movq 0x10(%rsp), %rdi
leaq 0xa921(%rip), %rsi      # 0x357db
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4460
jmp 0x2aedc
movq 0x10(%rsp), %rdi
leaq 0xa918(%rip), %rsi      # 0x357ea
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4460
movq %rbp, %rdi
callq 0x42d0
movq 0x90(%r13), %rax
movq (%rax,%r15,8), %rax
movq (%rax,%r14,8), %rax
movq (%rax,%rbx,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
movq 0x88(%r13), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %r12
jl 0x2ae9e
incq %rbx
movq 0x88(%r13), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %rbx
jl 0x2ae8a
movq 0x28(%rsp), %rax
incl (%rax)
incq %r14
movq 0x20(%rsp), %rax
movsbq 0x8c8(%rax), %rax
cmpq %rax, %r14
leaq 0x48(%rsp), %r12
jl 0x2ae5c
movq 0x20(%rsp), %rax
cmpb $0x0, 0x8c8(%rax)
jle 0x2b0af
xorl %r14d, %r14d
movq 0x10(%rsp), %rdi
leaq 0xac60(%rip), %rsi      # 0x35bd5
leaq 0xf(%rsp), %rdx
xorl %eax, %eax
callq 0x4460
movq 0x88(%r13), %rax
cmpb $0x0, 0x8b8(%rax)
jle 0x2b047
xorl %ebx, %ebx
movq 0x88(%r13), %rcx
movb 0x8b9(%rcx), %al
testb %al, %al
jle 0x2b02c
xorl %r12d, %r12d
movsbl 0x8b8(%rcx), %ecx
decl %ecx
cmpl %ebx, %ecx
jne 0x2afde
movsbl %al, %eax
decl %eax
cmpl %eax, %r12d
jne 0x2afde
movq 0x10(%rsp), %rdi
leaq 0xa809(%rip), %rsi      # 0x357db
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4460
jmp 0x2aff4
movq 0x10(%rsp), %rdi
leaq 0xa800(%rip), %rsi      # 0x357ea
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4460
movq %rbp, %rdi
callq 0x42d0
movq 0x98(%r13), %rax
movq (%rax,%r15,8), %rax
movq (%rax,%r14,8), %rax
movq (%rax,%rbx,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
movq 0x88(%r13), %rcx
movsbq 0x8b9(%rcx), %rax
cmpq %rax, %r12
jl 0x2afaf
incq %rbx
movq 0x88(%r13), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %rbx
jl 0x2af97
movq 0x28(%rsp), %rax
incl (%rax)
incq %r14
movq 0x20(%rsp), %rax
movsbq 0x8c8(%rax), %rax
cmpq %rax, %r14
leaq 0x48(%rsp), %r12
jl 0x2af69
jmp 0x2b0af
movq 0x10(%rsp), %rdi
leaq 0xa768(%rip), %rsi      # 0x357e2
xorl %eax, %eax
callq 0x4460
movq 0x10(%rsp), %rdi
leaq 0xa755(%rip), %rsi      # 0x357e2
xorl %eax, %eax
callq 0x4460
movq 0x10(%rsp), %rdi
leaq 0xa742(%rip), %rsi      # 0x357e2
xorl %eax, %eax
callq 0x4460
movq 0x28(%rsp), %rax
addl $0x3, (%rax)
movl 0x1c(%rsp), %ecx
incl %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x1c(%rsp)
cmpl 0x8c0(%rax), %ecx
jl 0x2ac36
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x2b0e6
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4220
addq $0x888, %rsp            # imm = 0x888
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b141
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x2b144
movq 0x48(%rsp), %rsi
jmp 0x2b127
jmp 0x2b141
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x2b144
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4220
jmp 0x2b144
jmp 0x2b141
jmp 0x2b141
jmp 0x2b141
jmp 0x2b141
jmp 0x2b141
jmp 0x2b141
jmp 0x2b141
jmp 0x2b141
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x2b160
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4220
movq %rbx, %rdi
callq 0x4430