// File: myudelson[P]hmm-scalable/HMMProblem.cpp
// Function: HMMProblem::readModelBody(_IO_FILE*, param*, int*, bool)
void HMMProblem::readModelBody(FILE *fid, struct param* param, NDAT *line_no,  bool overwrite) {
	NPAR i,j,m;
	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
        fscanf(fid,"A\t");
		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][i][j] = atof(col);
                }
                else {
                    fscanf(fid,"%[^\t]\t", col); // not las one
                    this->A[idxk][i][j] = atof(col);
                }
			}
        (*line_no)++;
		// read B
        fscanf(fid,"B\t");
		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][i][m] = atof(col);
                }
                else {
                    fscanf(fid,"%[^\t]\t", col); // not last one
                    this->B[idxk][i][m] = atof(col);
                }
			}
        (*line_no)++;
	} // for all k
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x990, %rsp            # imm = 0x990
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x930(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x16650
leaq -0x58(%rbp), %rdi
callq 0x5420
movq -0x930(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x26f70
jmp 0x27128
testb $0x1, -0x21(%rbp)
je 0x27274
movl $0x30, %edi
callq 0x52d0
movq %rax, -0x938(%rbp)
jmp 0x27145
movq -0x938(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x6850
movq -0x930(%rbp), %rax
movq -0x938(%rbp), %rcx
movq 0x88(%rax), %rax
movq %rcx, 0x920(%rax)
movl $0x30, %edi
callq 0x52d0
movq %rax, -0x940(%rbp)
jmp 0x2718e
movq -0x940(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x6890
movq -0x930(%rbp), %rax
movq -0x940(%rbp), %rcx
movq 0x88(%rax), %rax
movq %rcx, 0x928(%rax)
movl $0x30, %edi
callq 0x52d0
movq %rax, -0x948(%rbp)
jmp 0x271d7
movq -0x948(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x6850
movq -0x930(%rbp), %rax
movq -0x948(%rbp), %rcx
movq 0x88(%rax), %rax
movq %rcx, 0x940(%rax)
movl $0x30, %edi
callq 0x52d0
movq %rax, -0x950(%rbp)
jmp 0x27220
movq -0x950(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x5150
movq -0x950(%rbp), %rdi
callq 0x6890
movq -0x930(%rbp), %rax
movq -0x950(%rbp), %rcx
movq 0x88(%rax), %rax
movq %rcx, 0x948(%rax)
jmp 0x27274
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x868(%rbp)
movl %eax, -0x86c(%rbp)
jmp 0x27926
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8c0(%rcx), %eax
jge 0x27914
movq -0x10(%rbp), %rdi
leaq 0x29612(%rip), %rsi     # 0x508ab
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x272a9
leaq -0x891(%rbp), %rdi
movq %rdi, -0x958(%rbp)
callq 0x5550
movq -0x958(%rbp), %rdx
leaq -0x890(%rbp), %rdi
leaq -0x860(%rbp), %rsi
callq 0xc470
jmp 0x272d8
leaq -0x58(%rbp), %rdi
leaq -0x890(%rbp), %rsi
callq 0x53a0
leaq -0x890(%rbp), %rdi
callq 0x5170
leaq -0x891(%rbp), %rdi
callq 0x5320
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
testb $0x1, -0x21(%rbp)
je 0x27499
movq -0x930(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x940(%rax), %rdi
movq %rdi, -0x960(%rbp)
callq 0x167a0
movl %eax, -0x8c4(%rbp)
leaq -0x8c0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x8c4(%rbp), %rdx
callq 0x16a60
jmp 0x27355
movq -0x960(%rbp), %rdi
leaq -0x8c0(%rbp), %rsi
callq 0x16850
movb %dl, -0x969(%rbp)
movq %rax, -0x968(%rbp)
jmp 0x27377
movb -0x969(%rbp), %al
movq -0x968(%rbp), %rcx
movq %rcx, -0x8d8(%rbp)
movb %al, -0x8d0(%rbp)
leaq -0x8c0(%rbp), %rdi
callq 0x168d0
movq -0x930(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x948(%rax), %rdi
movq %rdi, -0x978(%rbp)
callq 0x16aa0
movl %eax, -0x904(%rbp)
leaq -0x900(%rbp), %rdi
leaq -0x904(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x16ac0
jmp 0x273dd
movq -0x978(%rbp), %rdi
leaq -0x900(%rbp), %rsi
callq 0x168f0
movb %dl, -0x981(%rbp)
movq %rax, -0x980(%rbp)
jmp 0x273ff
movb -0x981(%rbp), %al
movq -0x980(%rbp), %rcx
movq %rcx, -0x918(%rbp)
movb %al, -0x910(%rbp)
leaq -0x900(%rbp), %rdi
callq 0x16970
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x2756d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x868(%rbp)
movl %eax, -0x86c(%rbp)
leaq -0x891(%rbp), %rdi
callq 0x5320
jmp 0x27926
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x868(%rbp)
movl %eax, -0x86c(%rbp)
leaq -0x8c0(%rbp), %rdi
callq 0x168d0
jmp 0x27926
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x868(%rbp)
movl %eax, -0x86c(%rbp)
leaq -0x900(%rbp), %rdi
callq 0x16970
jmp 0x27926
movq -0x930(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x940(%rax), %rdi
leaq -0x58(%rbp), %rsi
callq 0x16710
movq %rax, -0x990(%rbp)
jmp 0x274c0
movq -0x930(%rbp), %rax
movq -0x990(%rbp), %rcx
movq %rcx, -0x920(%rbp)
movq -0x920(%rbp), %rcx
movq %rcx, -0x38(%rbp)
movq 0x88(%rax), %rax
movq 0x940(%rax), %rdi
callq 0x16770
movq %rax, -0x928(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x928(%rbp), %rsi
callq 0x16740
testb $0x1, %al
jne 0x27510
jmp 0x2755c
movq -0x10(%rbp), %rdi
leaq 0x2939b(%rip), %rsi     # 0x508b6
xorl %eax, %eax
callq 0x5580
jmp 0x27524
movq -0x10(%rbp), %rdi
leaq 0x29387(%rip), %rsi     # 0x508b6
xorl %eax, %eax
callq 0x5580
jmp 0x27538
movq -0x10(%rbp), %rdi
leaq 0x29373(%rip), %rsi     # 0x508b6
xorl %eax, %eax
callq 0x5580
jmp 0x2754c
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x3, %ecx
movl %ecx, (%rax)
jmp 0x27906
leaq -0x38(%rbp), %rdi
callq 0x16990
movl 0x20(%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x2756d
movq -0x10(%rbp), %rdi
leaq 0x2905a(%rip), %rsi     # 0x505d2
xorl %eax, %eax
callq 0x5580
jmp 0x27581
movb $0x0, -0x22(%rbp)
movq -0x930(%rbp), %rcx
movsbl -0x22(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x275f3
movq -0x10(%rbp), %rdi
leaq 0x2930e(%rip), %rsi     # 0x508be
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x275c0
leaq -0x860(%rbp), %rdi
callq 0x53c0
movq -0x930(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x22(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movb -0x22(%rbp), %al
addb $0x1, %al
movb %al, -0x22(%rbp)
jmp 0x27585
movq -0x10(%rbp), %rdi
leaq 0x292b1(%rip), %rsi     # 0x508af
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x2760e
leaq -0x860(%rbp), %rdi
callq 0x53c0
movq -0x930(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x22(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
leaq 0x28f8a(%rip), %rsi     # 0x505d6
xorl %eax, %eax
callq 0x5580
jmp 0x27655
movb $0x0, -0x22(%rbp)
movq -0x930(%rbp), %rcx
movsbl -0x22(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x27799
movb $0x0, -0x23(%rbp)
movq -0x930(%rbp), %rcx
movsbl -0x23(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x2778a
movq -0x930(%rbp), %rcx
movsbl -0x22(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2772e
movq -0x930(%rbp), %rcx
movsbl -0x23(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2772e
movq -0x10(%rbp), %rdi
leaq 0x291c5(%rip), %rsi     # 0x508af
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x276fa
leaq -0x860(%rbp), %rdi
callq 0x53c0
movq -0x930(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x22(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x23(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x2777b
movq -0x10(%rbp), %rdi
leaq 0x29185(%rip), %rsi     # 0x508be
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x27749
leaq -0x860(%rbp), %rdi
callq 0x53c0
movq -0x930(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x22(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x23(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x2777d
movb -0x23(%rbp), %al
addb $0x1, %al
movb %al, -0x23(%rbp)
jmp 0x2767e
jmp 0x2778c
movb -0x22(%rbp), %al
addb $0x1, %al
movb %al, -0x22(%rbp)
jmp 0x27659
movq -0x20(%rbp), %rax
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
leaq 0x28e2b(%rip), %rsi     # 0x505d9
xorl %eax, %eax
callq 0x5580
jmp 0x277b7
movb $0x0, -0x22(%rbp)
movq -0x930(%rbp), %rcx
movsbl -0x22(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x278fb
movb $0x0, -0x24(%rbp)
movq -0x930(%rbp), %rcx
movsbl -0x24(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x278ec
movq -0x930(%rbp), %rcx
movsbl -0x22(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x27890
movq -0x930(%rbp), %rcx
movsbl -0x24(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x27890
movq -0x10(%rbp), %rdi
leaq 0x29063(%rip), %rsi     # 0x508af
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x2785c
leaq -0x860(%rbp), %rdi
callq 0x53c0
movq -0x930(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x22(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x278dd
movq -0x10(%rbp), %rdi
leaq 0x29023(%rip), %rsi     # 0x508be
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x278ab
leaq -0x860(%rbp), %rdi
callq 0x53c0
movq -0x930(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x22(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x278df
movb -0x24(%rbp), %al
addb $0x1, %al
movb %al, -0x24(%rbp)
jmp 0x277e0
jmp 0x278ee
movb -0x22(%rbp), %al
addb $0x1, %al
movb %al, -0x22(%rbp)
jmp 0x277bb
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2727b
leaq -0x58(%rbp), %rdi
callq 0x5170
addq $0x990, %rsp            # imm = 0x990
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0x5170
movq -0x868(%rbp), %rdi
callq 0x5540
nopl (%rax,%rax)