// File: myudelson[P]hmm-scalable/HMMProblemSt.cpp
// Function: HMMProblemSt::readModelBody(_IO_FILE*, task*, int*, bool)
void HMMProblemSt::readModelBody(FILE *fid, struct task* task, NDAT *line_no,  bool overwrite) {
    NPAR i,j,m, nS=this->task->nS, nO=this->task->nO;
    NCAT nK=task->nK;
	NCAT k = 0, idxk = 0, offset;
    std::map<std::string,NCAT>::iterator it;
	string s;
    char col[2048];
    //
    readNullObsRatio(fid, task, line_no);
    //
    // init param
    //
    if(overwrite) {
        this->task->map_group_fwd = new map<string,NCAT>();
        this->task->map_group_bwd = new map<NCAT,string>();
        this->task->map_skill_fwd = new map<string,NCAT>();
        this->task->map_skill_bwd = new map<NCAT,string>();
    }
	//
	// read skills
	//
	for(k=0; k<nK; k++) {
		// read skill label
        fscanf(fid,"%*s\t%[^\n]\n",col);
        s = string( col );
        (*line_no)++;
        if(overwrite) {
            this->task->map_skill_fwd->insert(pair<string,NCAT>(s, (NCAT)this->task->map_skill_fwd->size()));
            this->task->map_skill_bwd->insert(pair<NCAT,string>((NCAT)this->task->map_skill_bwd->size(), s));
            idxk = k;
        } else {
            it = this->task->map_skill_fwd->find(s);
            if( it==this->task->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");
        offset = idxk*this->skill1_n;
        for(i=0; i<(nS-1); i++) { // read 1 less then necessary
            fscanf(fid,"%[^\t]\t",col);
            // this->pi[idxk][i] = atof(col);
            this->param_skill[offset+i] = atof(col);
        }
        fscanf(fid,"%[^\n]\n",col);// read last one
        // this->pi[idxk][i] = atof(col);
        this->param_skill[offset+i] = atof(col);
        (*line_no)++;
		// read A
        fscanf(fid,"A\t");
        offset = idxk*this->skill1_n + nS;
		for(i=0; i<nS; i++)
			for(j=0; j<nS; j++) {
                if(i==(nS-1) && j==(nS-1)) {
                    fscanf(fid,"%[^\n]\n", col); // last one;
                    // this->A[idxk][i][j] = atof(col);
                    this->param_skill[offset+i*nS + j] = atof(col);
                }
                else {
                    fscanf(fid,"%[^\t]\t", col); // not las one
                    // this->A[idxk][i][j] = atof(col);
                    this->param_skill[offset+i*nS + j] = atof(col);
                }
			}
        (*line_no)++;
		// read B
        fscanf(fid,"B\t");
        offset = idxk*this->skill1_n + (1+nS)*nS;
		for(i=0; i<nS; i++)
			for(m=0; m<nO; m++) {
                if(i==(nS-1) && m==(nO-1)) {
                    fscanf(fid,"%[^\n]\n", col); // last one;
                    // this->B[idxk][i][m] = atof(col);
                    this->param_skill[offset+i*nO + m] = atof(col);
                }
                else {
                    fscanf(fid,"%[^\t]\t", col); // not last one
                    // this->B[idxk][i][m] = atof(col);
                    this->param_skill[offset+i*nO + 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)
movq 0x68(%rax), %rcx
movb 0x900(%rcx), %cl
movb %cl, -0x25(%rbp)
movq 0x68(%rax), %rax
movb 0x901(%rax), %al
movb %al, -0x26(%rbp)
movq -0x18(%rbp), %rax
movl 0x908(%rax), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xed60
leaq -0x60(%rbp), %rdi
callq 0x33b0
movq -0x930(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x184c0
jmp 0x1869f
testb $0x1, -0x21(%rbp)
je 0x187df
movl $0x30, %edi
callq 0x3270
movq %rax, -0x938(%rbp)
jmp 0x186bc
movq -0x938(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x4430
movq -0x930(%rbp), %rax
movq -0x938(%rbp), %rcx
movq 0x68(%rax), %rax
movq %rcx, 0x928(%rax)
movl $0x30, %edi
callq 0x3270
movq %rax, -0x940(%rbp)
jmp 0x18702
movq -0x940(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x4470
movq -0x930(%rbp), %rax
movq -0x940(%rbp), %rcx
movq 0x68(%rax), %rax
movq %rcx, 0x930(%rax)
movl $0x30, %edi
callq 0x3270
movq %rax, -0x948(%rbp)
jmp 0x18748
movq -0x948(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x4430
movq -0x930(%rbp), %rax
movq -0x948(%rbp), %rcx
movq 0x68(%rax), %rax
movq %rcx, 0x948(%rax)
movl $0x30, %edi
callq 0x3270
movq %rax, -0x950(%rbp)
jmp 0x1878e
movq -0x950(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x3140
movq -0x950(%rbp), %rdi
callq 0x4470
movq -0x930(%rbp), %rax
movq -0x950(%rbp), %rcx
movq 0x68(%rax), %rax
movq %rcx, 0x950(%rax)
jmp 0x187df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x868(%rbp)
movl %eax, -0x86c(%rbp)
jmp 0x18e38
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x18e26
movq -0x10(%rbp), %rdi
leaq 0x3d51(%rip), %rsi      # 0x1c54e
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x34e0
jmp 0x1880d
leaq -0x891(%rbp), %rdi
movq %rdi, -0x958(%rbp)
callq 0x34a0
movq -0x958(%rbp), %rdx
leaq -0x890(%rbp), %rdi
leaq -0x860(%rbp), %rsi
callq 0x9e00
jmp 0x1883c
leaq -0x60(%rbp), %rdi
leaq -0x890(%rbp), %rsi
callq 0x3340
leaq -0x890(%rbp), %rdi
callq 0x3160
leaq -0x891(%rbp), %rdi
callq 0x32c0
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
testb $0x1, -0x21(%rbp)
je 0x189f7
movq -0x930(%rbp), %rax
movq 0x68(%rax), %rax
movq 0x948(%rax), %rdi
movq %rdi, -0x960(%rbp)
callq 0xeeb0
movl %eax, -0x8c4(%rbp)
leaq -0x8c0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x8c4(%rbp), %rdx
callq 0xf170
jmp 0x188b6
movq -0x960(%rbp), %rdi
leaq -0x8c0(%rbp), %rsi
callq 0xef60
movb %dl, -0x969(%rbp)
movq %rax, -0x968(%rbp)
jmp 0x188d8
movb -0x969(%rbp), %al
movq -0x968(%rbp), %rcx
movq %rcx, -0x8d8(%rbp)
movb %al, -0x8d0(%rbp)
leaq -0x8c0(%rbp), %rdi
callq 0xefe0
movq -0x930(%rbp), %rax
movq 0x68(%rax), %rax
movq 0x950(%rax), %rdi
movq %rdi, -0x978(%rbp)
callq 0xf1b0
movl %eax, -0x904(%rbp)
leaq -0x900(%rbp), %rdi
leaq -0x904(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0xf1d0
jmp 0x1893b
movq -0x978(%rbp), %rdi
leaq -0x900(%rbp), %rsi
callq 0xf000
movb %dl, -0x981(%rbp)
movq %rax, -0x980(%rbp)
jmp 0x1895d
movb -0x981(%rbp), %al
movq -0x980(%rbp), %rcx
movq %rcx, -0x918(%rbp)
movb %al, -0x910(%rbp)
leaq -0x900(%rbp), %rdi
callq 0xf080
movl -0x30(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x18ac5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x868(%rbp)
movl %eax, -0x86c(%rbp)
leaq -0x891(%rbp), %rdi
callq 0x32c0
jmp 0x18e38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x868(%rbp)
movl %eax, -0x86c(%rbp)
leaq -0x8c0(%rbp), %rdi
callq 0xefe0
jmp 0x18e38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x868(%rbp)
movl %eax, -0x86c(%rbp)
leaq -0x900(%rbp), %rdi
callq 0xf080
jmp 0x18e38
movq -0x930(%rbp), %rax
movq 0x68(%rax), %rax
movq 0x948(%rax), %rdi
leaq -0x60(%rbp), %rsi
callq 0xee20
movq %rax, -0x990(%rbp)
jmp 0x18a1b
movq -0x930(%rbp), %rax
movq -0x990(%rbp), %rcx
movq %rcx, -0x920(%rbp)
movq -0x920(%rbp), %rcx
movq %rcx, -0x40(%rbp)
movq 0x68(%rax), %rax
movq 0x948(%rax), %rdi
callq 0xee80
movq %rax, -0x928(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x928(%rbp), %rsi
callq 0xee50
testb $0x1, %al
jne 0x18a68
jmp 0x18ab4
movq -0x10(%rbp), %rdi
leaq 0x3ae6(%rip), %rsi      # 0x1c559
xorl %eax, %eax
callq 0x34e0
jmp 0x18a7c
movq -0x10(%rbp), %rdi
leaq 0x3ad2(%rip), %rsi      # 0x1c559
xorl %eax, %eax
callq 0x34e0
jmp 0x18a90
movq -0x10(%rbp), %rdi
leaq 0x3abe(%rip), %rsi      # 0x1c559
xorl %eax, %eax
callq 0x34e0
jmp 0x18aa4
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x3, %ecx
movl %ecx, (%rax)
jmp 0x18e18
leaq -0x40(%rbp), %rdi
callq 0xf0a0
movl 0x20(%rax), %eax
movl %eax, -0x34(%rbp)
jmp 0x18ac5
movq -0x10(%rbp), %rdi
leaq 0x38aa(%rip), %rsi      # 0x1c37a
xorl %eax, %eax
callq 0x34e0
jmp 0x18ad9
movq -0x930(%rbp), %rcx
movl -0x34(%rbp), %eax
imull 0x38(%rcx), %eax
movl %eax, -0x38(%rbp)
movb $0x0, -0x22(%rbp)
movsbl -0x22(%rbp), %eax
movsbl -0x25(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x18b4a
movq -0x10(%rbp), %rdi
leaq 0x3a59(%rip), %rsi      # 0x1c561
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x34e0
jmp 0x18b18
leaq -0x860(%rbp), %rdi
callq 0x3360
movq -0x930(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x38(%rbp), %ecx
movsbl -0x22(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movb -0x22(%rbp), %al
addb $0x1, %al
movb %al, -0x22(%rbp)
jmp 0x18aee
movq -0x10(%rbp), %rdi
leaq 0x39fd(%rip), %rsi      # 0x1c552
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x34e0
jmp 0x18b65
leaq -0x860(%rbp), %rdi
callq 0x3360
movq -0x930(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x38(%rbp), %ecx
movsbl -0x22(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
leaq 0x37e6(%rip), %rsi      # 0x1c388
xorl %eax, %eax
callq 0x34e0
jmp 0x18bab
movq -0x930(%rbp), %rcx
movl -0x34(%rbp), %eax
imull 0x38(%rcx), %eax
movsbl -0x25(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x38(%rbp)
movb $0x0, -0x22(%rbp)
movsbl -0x22(%rbp), %eax
movsbl -0x25(%rbp), %ecx
cmpl %ecx, %eax
jge 0x18cc8
movb $0x0, -0x23(%rbp)
movsbl -0x23(%rbp), %eax
movsbl -0x25(%rbp), %ecx
cmpl %ecx, %eax
jge 0x18cb9
movsbl -0x22(%rbp), %eax
movsbl -0x25(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x18c5a
movsbl -0x23(%rbp), %eax
movsbl -0x25(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x18c5a
movq -0x10(%rbp), %rdi
leaq 0x393f(%rip), %rsi      # 0x1c552
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x34e0
jmp 0x18c23
leaq -0x860(%rbp), %rdi
callq 0x3360
movq -0x930(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x38(%rbp), %ecx
movsbl -0x22(%rbp), %edx
movsbl -0x25(%rbp), %esi
imull %esi, %edx
addl %edx, %ecx
movsbl -0x23(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18caa
movq -0x10(%rbp), %rdi
leaq 0x38fc(%rip), %rsi      # 0x1c561
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x34e0
jmp 0x18c75
leaq -0x860(%rbp), %rdi
callq 0x3360
movq -0x930(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x38(%rbp), %ecx
movsbl -0x22(%rbp), %edx
movsbl -0x25(%rbp), %esi
imull %esi, %edx
addl %edx, %ecx
movsbl -0x23(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18cac
movb -0x23(%rbp), %al
addb $0x1, %al
movb %al, -0x23(%rbp)
jmp 0x18bda
jmp 0x18cbb
movb -0x22(%rbp), %al
addb $0x1, %al
movb %al, -0x22(%rbp)
jmp 0x18bc6
movq -0x20(%rbp), %rax
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
leaq 0x36ae(%rip), %rsi      # 0x1c38b
xorl %eax, %eax
callq 0x34e0
jmp 0x18ce6
movq -0x930(%rbp), %rcx
movl -0x34(%rbp), %eax
imull 0x38(%rcx), %eax
movsbl -0x25(%rbp), %ecx
addl $0x1, %ecx
movsbl -0x25(%rbp), %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x38(%rbp)
movb $0x0, -0x22(%rbp)
movsbl -0x22(%rbp), %eax
movsbl -0x25(%rbp), %ecx
cmpl %ecx, %eax
jge 0x18e0d
movb $0x0, -0x24(%rbp)
movsbl -0x24(%rbp), %eax
movsbl -0x26(%rbp), %ecx
cmpl %ecx, %eax
jge 0x18dfe
movsbl -0x22(%rbp), %eax
movsbl -0x25(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x18d9f
movsbl -0x24(%rbp), %eax
movsbl -0x26(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x18d9f
movq -0x10(%rbp), %rdi
leaq 0x37fa(%rip), %rsi      # 0x1c552
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x34e0
jmp 0x18d68
leaq -0x860(%rbp), %rdi
callq 0x3360
movq -0x930(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x38(%rbp), %ecx
movsbl -0x22(%rbp), %edx
movsbl -0x26(%rbp), %esi
imull %esi, %edx
addl %edx, %ecx
movsbl -0x24(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18def
movq -0x10(%rbp), %rdi
leaq 0x37b7(%rip), %rsi      # 0x1c561
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x34e0
jmp 0x18dba
leaq -0x860(%rbp), %rdi
callq 0x3360
movq -0x930(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x38(%rbp), %ecx
movsbl -0x22(%rbp), %edx
movsbl -0x26(%rbp), %esi
imull %esi, %edx
addl %edx, %ecx
movsbl -0x24(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18df1
movb -0x24(%rbp), %al
addb $0x1, %al
movb %al, -0x24(%rbp)
jmp 0x18d1f
jmp 0x18e00
movb -0x22(%rbp), %al
addb $0x1, %al
movb %al, -0x22(%rbp)
jmp 0x18d0b
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x187e6
leaq -0x60(%rbp), %rdi
callq 0x3160
addq $0x990, %rsp            # imm = 0x990
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0x3160
movq -0x868(%rbp), %rdi
callq 0x3490
nopl (%rax)