// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8c8, %rsp            # imm = 0x8C8
movl %r8d, 0x30(%rsp)
movq %rcx, %r12
movq 0x68(%rdi), %rax
movsbl 0x900(%rax), %ecx
movq %rcx, 0x90(%rsp)
movsbq 0x901(%rax), %rax
movq %rax, 0xa0(%rsp)
movl 0x908(%rdx), %eax
movl %eax, 0x2c(%rsp)
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq %r12, %rcx
callq 0xff9a
cmpb $0x0, 0x30(%rsp)
je 0x101c9
movl $0x30, %edi
callq 0x21c0
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq 0x10(%rsp), %rcx
movq 0x68(%rcx), %rbx
movq %rax, 0x928(%rbx)
movl $0x30, %edi
callq 0x21c0
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq %rax, 0x930(%rbx)
movl $0x30, %edi
callq 0x21c0
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq %rax, 0x948(%rbx)
movl $0x30, %edi
callq 0x21c0
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq %rax, 0x950(%rbx)
cmpl $0x0, 0x2c(%rsp)
jle 0x10671
movq 0x90(%rsp), %rax
movzbl %al, %ecx
movq %rcx, 0x20(%rsp)
movq 0xa0(%rsp), %rcx
movzbl %cl, %edx
movq %rdx, 0xa8(%rsp)
leal -0x1(%rax), %edx
movq %rdx, 0x60(%rsp)
leal 0x1(%rax), %edx
imull %eax, %edx
movl %edx, 0x6c(%rsp)
decl %ecx
movq %rcx, 0xb0(%rsp)
cltq
movq %rax, 0xb8(%rsp)
leaq 0xc0(%rsp), %rbx
movl $0x0, 0x1c(%rsp)
movq %r12, 0x98(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x3305(%rip), %rsi      # 0x13546
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23a0
movq %rbx, %r14
leaq 0x48(%rsp), %rbx
movq %rbx, 0x38(%rsp)
movq %r14, %rdi
callq 0x20e0
leaq (%rsp,%rax), %rdx
addq $0xc0, %rdx
leaq 0x38(%rsp), %r13
movq %r13, %rdi
movq %r14, %r15
movq %r14, %rsi
callq 0x79e8
leaq 0x70(%rsp), %rdi
movq %r13, %rsi
callq 0x2260
movq 0x38(%rsp), %rdi
cmpq %rbx, %rdi
je 0x102a2
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21d0
incl (%r12)
movq 0x10(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x948(%rax), %r13
cmpb $0x0, 0x30(%rsp)
movq %r15, %rbx
je 0x10381
movq 0x28(%r13), %r14
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0x78e6
movl %r14d, 0x58(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0xa90c
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x10318
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x10(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x950(%rax), %r14
movl 0x28(%r14), %eax
movl %eax, 0x38(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0x78e6
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
callq 0xaad6
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1037a
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21d0
movl 0x1c(%rsp), %r13d
jmp 0x103af
movq %r13, %rdi
leaq 0x70(%rsp), %rsi
callq 0xa814
movq 0x10(%rsp), %rcx
movq 0x68(%rcx), %rcx
movq 0x948(%rcx), %rcx
addq $0x8, %rcx
cmpq %rcx, %rax
je 0x1061b
movl 0x40(%rax), %r13d
movq 0x8(%rsp), %rdi
leaq 0x2fb7(%rip), %rsi      # 0x13372
xorl %eax, %eax
callq 0x23a0
movq 0x10(%rsp), %rax
movl 0x38(%rax), %ebp
imull %r13d, %ebp
xorl %r14d, %r14d
cmpb $0x2, 0x20(%rsp)
jl 0x1041f
xorl %r14d, %r14d
movb $0x1, %r15b
movq 0x8(%rsp), %rdi
leaq 0x316f(%rip), %rsi      # 0x13559
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23a0
movq %rbx, %rdi
callq 0x2270
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
addl %ebp, %r14d
movslq %r14d, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsbl %r15b, %r14d
leal 0x1(%r14), %r15d
cmpl %r14d, 0x60(%rsp)
jg 0x103de
movq 0x8(%rsp), %rdi
leaq 0x311f(%rip), %rsi      # 0x1354a
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23a0
movq %rbx, %rdi
callq 0x2270
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
addl %ebp, %r14d
movslq %r14d, %rcx
movsd %xmm0, (%rax,%rcx,8)
incl (%r12)
movq 0x8(%rsp), %rdi
leaq 0x2f1f(%rip), %rsi      # 0x13380
xorl %eax, %eax
callq 0x23a0
movl %r13d, 0x34(%rsp)
cmpb $0x0, 0x20(%rsp)
jle 0x10522
movq 0x10(%rsp), %rax
movl 0x38(%rax), %eax
imull 0x34(%rsp), %eax
addl 0x90(%rsp), %eax
movslq %eax, %r14
xorl %r15d, %r15d
movq %r15, %rbp
imulq 0xb8(%rsp), %rbp
shlq $0x3, %rbp
xorl %r12d, %r12d
movq %r15, %rax
movq 0x60(%rsp), %r13
xorq %r13, %rax
movq %r13, %rcx
xorq %r12, %rcx
orq %rax, %rcx
jne 0x104d3
movq 0x8(%rsp), %rdi
leaq 0x3083(%rip), %rsi      # 0x1354a
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23a0
jmp 0x104ec
movq 0x8(%rsp), %rdi
leaq 0x307a(%rip), %rsi      # 0x13559
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23a0
movq %r12, %r13
movq %rbx, %rdi
callq 0x2270
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
addq %rbp, %rax
leaq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r12
cmpq %r12, 0x20(%rsp)
jne 0x104a5
incq %r15
cmpq 0x20(%rsp), %r15
jne 0x10492
movq 0x98(%rsp), %r12
incl (%r12)
movq 0x8(%rsp), %rdi
leaq 0x2e49(%rip), %rsi      # 0x13383
xorl %eax, %eax
callq 0x23a0
movl 0x34(%rsp), %ecx
movl $0x1, %ebp
cmpb $0x0, 0x20(%rsp)
jle 0x10659
movq 0x10(%rsp), %rax
imull 0x38(%rax), %ecx
addl 0x6c(%rsp), %ecx
movslq %ecx, %rbp
xorl %r14d, %r14d
cmpb $0x0, 0xa8(%rsp)
jle 0x105fe
movq %r14, %r15
imulq 0xa0(%rsp), %r15
shlq $0x3, %r15
xorl %r12d, %r12d
cmpq 0x60(%rsp), %r14
jne 0x105ba
cmpq %r12, 0xb0(%rsp)
jne 0x105ba
movq 0x8(%rsp), %rdi
leaq 0x2fa4(%rip), %rsi      # 0x1354a
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23a0
movq 0xb0(%rsp), %r13
jmp 0x105d3
movq 0x8(%rsp), %rdi
leaq 0x2f93(%rip), %rsi      # 0x13559
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23a0
movq %r12, %r13
movq %rbx, %rdi
callq 0x2270
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
addq %r15, %rax
leaq (%rax,%rbp,8), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r12
cmpq %r12, 0xa8(%rsp)
jne 0x10589
incq %r14
cmpq 0x20(%rsp), %r14
jne 0x10568
movq 0x98(%rsp), %r12
movl $0x1, %ebp
jmp 0x10659
movq 0x8(%rsp), %rdi
leaq 0x2f2a(%rip), %rsi      # 0x13551
xorl %eax, %eax
callq 0x23a0
movq 0x8(%rsp), %rdi
leaq 0x2f17(%rip), %rsi      # 0x13551
xorl %eax, %eax
callq 0x23a0
movl $0x3, %ebp
movq 0x8(%rsp), %rdi
leaq 0x2eff(%rip), %rsi      # 0x13551
xorl %eax, %eax
callq 0x23a0
addl %ebp, (%r12)
movl 0x1c(%rsp), %eax
incl %eax
movl %eax, 0x1c(%rsp)
cmpl 0x2c(%rsp), %eax
jne 0x10235
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x10693
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21d0
addq $0x8c8, %rsp            # imm = 0x8C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x106ef
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x106f2
movq 0x48(%rsp), %rsi
jmp 0x106d7
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x106f2
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x106f2
jmp 0x106ef
jmp 0x106ef
jmp 0x106ef
jmp 0x106ef
jmp 0x106ef
jmp 0x106ef
jmp 0x106ef
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x10714
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x2370