// File: /workspace/github_cpp_makefile_star2_O1/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, 0x34(%rsp)
movq %rcx, %r12
movq 0x68(%rdi), %rax
movsbl 0x900(%rax), %ecx
movl %ecx, 0x2c(%rsp)
movsbq 0x901(%rax), %rax
movq %rax, 0x88(%rsp)
movl 0x908(%rdx), %eax
movl %eax, 0x30(%rsp)
leaq 0x78(%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 0xfc3c
cmpb $0x0, 0x34(%rsp)
je 0xfe76
movl $0x30, %edi
callq 0x21c0
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 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, 0x20(%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, 0x20(%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, 0x20(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq %rax, 0x950(%rbx)
cmpl $0x0, 0x30(%rsp)
jle 0x102e9
movslq 0x2c(%rsp), %rcx
leal -0x1(%rcx), %r14d
leal 0x1(%rcx), %eax
imull %ecx, %eax
movl %eax, 0x64(%rsp)
movq 0x88(%rsp), %rax
leal -0x1(%rax), %edx
movq %rdx, 0xa8(%rsp)
movl $0xff, %edx
movq %rcx, 0x20(%rsp)
andl %edx, %ecx
movzbl %al, %esi
movq %rsi, 0xb0(%rsp)
movq %rcx, 0xb8(%rsp)
shll $0x3, %ecx
movq %rcx, 0xa0(%rsp)
andl %eax, %edx
shll $0x3, %edx
movq %rdx, 0x98(%rsp)
leaq 0xc0(%rsp), %r13
movl $0x0, 0x1c(%rsp)
movq %r12, 0x90(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x2558(%rip), %rsi      # 0x1245a
movq %r13, %rdx
xorl %eax, %eax
callq 0x23a0
leaq 0x48(%rsp), %rbx
movq %rbx, 0x38(%rsp)
movq %r13, %rdi
callq 0x20e0
leaq (%rsp,%rax), %rdx
addq $0xc0, %rdx
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x7956
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x2260
movq 0x38(%rsp), %rdi
cmpq %rbx, %rdi
je 0xff5d
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21d0
incl (%r12)
movq 0x10(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x948(%rax), %rbp
cmpb $0x0, 0x34(%rsp)
je 0x10036
movq 0x28(%rbp), %rbx
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0x7858
movl %ebx, 0x58(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
callq 0xa922
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xffcf
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x10(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x950(%rax), %rbx
movl 0x28(%rbx), %eax
movl %eax, 0x38(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0x7858
movq %rbx, %rdi
leaq 0x38(%rsp), %rsi
callq 0xaaec
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x10030
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21d0
movl 0x1c(%rsp), %eax
jmp 0x10063
movq %rbp, %rdi
leaq 0x68(%rsp), %rsi
callq 0xa82a
movq 0x10(%rsp), %rcx
movq 0x68(%rcx), %rcx
movq 0x948(%rcx), %rcx
addq $0x8, %rcx
cmpq %rcx, %rax
je 0x10293
movl 0x40(%rax), %eax
movl %eax, 0x18(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x2213(%rip), %rsi      # 0x12286
xorl %eax, %eax
callq 0x23a0
movq 0x10(%rsp), %rax
movl 0x38(%rax), %ebp
imull 0x18(%rsp), %ebp
xorl %ebx, %ebx
cmpb $0x2, 0x20(%rsp)
jl 0x100d3
xorl %ebx, %ebx
movb $0x1, %r15b
movq 0x8(%rsp), %rdi
leaq 0x23cc(%rip), %rsi      # 0x1246d
movq %r13, %rdx
xorl %eax, %eax
callq 0x23a0
movq %r13, %rdi
callq 0x2270
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
addl %ebp, %ebx
movslq %ebx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsbl %r15b, %ebx
leal 0x1(%rbx), %r15d
cmpl %ebx, %r14d
jg 0x10095
movq 0x8(%rsp), %rdi
leaq 0x237f(%rip), %rsi      # 0x1245e
movq %r13, %rdx
xorl %eax, %eax
callq 0x23a0
movq %r13, %rdi
callq 0x2270
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
addl %ebp, %ebx
movslq %ebx, %rcx
movsd %xmm0, (%rax,%rcx,8)
incl (%r12)
movq 0x8(%rsp), %rdi
leaq 0x2180(%rip), %rsi      # 0x12294
xorl %eax, %eax
callq 0x23a0
cmpb $0x0, 0x20(%rsp)
jle 0x101bc
movq 0x10(%rsp), %rax
movl 0x38(%rax), %eax
imull 0x18(%rsp), %eax
addl 0x2c(%rsp), %eax
movslq %eax, %rbp
shlq $0x3, %rbp
xorl %r15d, %r15d
movq %r15, %rbx
xorq %r14, %rbx
xorl %r12d, %r12d
movq %r14, %rax
xorq %r12, %rax
orq %rbx, %rax
jne 0x1016d
movq 0x8(%rsp), %rdi
leaq 0x22fd(%rip), %rsi      # 0x1245e
movq %r13, %rdx
xorl %eax, %eax
callq 0x23a0
jmp 0x10183
movq 0x8(%rsp), %rdi
leaq 0x22f4(%rip), %rsi      # 0x1246d
movq %r13, %rdx
xorl %eax, %eax
callq 0x23a0
movq %r13, %rdi
callq 0x2270
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
addq %rbp, %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
cmpq %r12, 0xb8(%rsp)
jne 0x1014a
incq %r15
addq 0xa0(%rsp), %rbp
cmpq 0x20(%rsp), %r15
jne 0x10141
movq 0x90(%rsp), %r12
incl (%r12)
movq 0x8(%rsp), %rdi
leaq 0x20c3(%rip), %rsi      # 0x12297
xorl %eax, %eax
callq 0x23a0
movl $0x1, %ebx
cmpb $0x0, 0x20(%rsp)
jle 0x102d1
movq 0x10(%rsp), %rax
movl 0x18(%rsp), %ecx
imull 0x38(%rax), %ecx
addl 0x64(%rsp), %ecx
movslq %ecx, %rbp
shlq $0x3, %rbp
xorl %ebx, %ebx
cmpb $0x0, 0x88(%rsp)
jle 0x10276
xorl %r15d, %r15d
cmpq %r14, %rbx
jne 0x10239
cmpq %r15, 0xa8(%rsp)
jne 0x10239
movq 0x8(%rsp), %rdi
leaq 0x2231(%rip), %rsi      # 0x1245e
movq %r13, %rdx
xorl %eax, %eax
callq 0x23a0
jmp 0x1024f
movq 0x8(%rsp), %rdi
leaq 0x2228(%rip), %rsi      # 0x1246d
movq %r13, %rdx
xorl %eax, %eax
callq 0x23a0
movq %r13, %rdi
callq 0x2270
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
addq %rbp, %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
cmpq %r15, 0xb0(%rsp)
jne 0x10212
incq %rbx
addq 0x98(%rsp), %rbp
cmpq 0x20(%rsp), %rbx
jne 0x10205
movl $0x1, %ebx
jmp 0x102d1
movq 0x8(%rsp), %rdi
leaq 0x21c6(%rip), %rsi      # 0x12465
xorl %eax, %eax
callq 0x23a0
movq 0x8(%rsp), %rdi
leaq 0x21b3(%rip), %rsi      # 0x12465
xorl %eax, %eax
callq 0x23a0
movl $0x3, %ebx
movq 0x8(%rsp), %rdi
leaq 0x219b(%rip), %rsi      # 0x12465
xorl %eax, %eax
callq 0x23a0
addl %ebx, (%r12)
movl 0x1c(%rsp), %eax
incl %eax
movl %eax, 0x1c(%rsp)
cmpl 0x30(%rsp), %eax
jne 0xfef6
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x10305
movq 0x78(%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 0x10361
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x10364
movq 0x48(%rsp), %rsi
jmp 0x10349
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x10364
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x10364
jmp 0x10361
jmp 0x10361
jmp 0x10361
jmp 0x10361
jmp 0x10361
jmp 0x10361
jmp 0x10361
movq %rax, %rbx
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x10380
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x2370