// File: /workspace/github_cpp_makefile_star2_O2/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, 0x18(%rsp)
movq 0x68(%rdi), %rax
movsbl 0x900(%rax), %r8d
movq %r8, 0x40(%rsp)
movsbq 0x901(%rax), %rax
movq %rax, 0x48(%rsp)
movl 0x908(%rdx), %ebp
leaq 0xb0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rdi, 0x8(%rsp)
movq %rsi, (%rsp)
movq %rcx, 0x20(%rsp)
callq 0xe402
cmpb $0x0, 0x18(%rsp)
je 0xe5fd
pushq $0x30
popq %rdi
callq 0x31c0
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
andq $0x0, 0x28(%rax)
movq 0x8(%rsp), %rcx
movq 0x68(%rcx), %rbx
movq %rax, 0x928(%rbx)
pushq $0x30
popq %rdi
callq 0x31c0
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
andq $0x0, 0x28(%rax)
movq %rax, 0x930(%rbx)
pushq $0x30
popq %rdi
callq 0x31c0
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
andq $0x0, 0x28(%rax)
movq %rax, 0x948(%rbx)
pushq $0x30
popq %rdi
callq 0x31c0
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
andq $0x0, 0x28(%rax)
movq %rax, 0x950(%rbx)
movq 0x40(%rsp), %rdx
movzbl %dl, %ecx
leal -0x1(%rdx), %r12d
leal 0x1(%rdx), %eax
imull %edx, %eax
movl %eax, 0x38(%rsp)
xorl %eax, %eax
testb %cl, %cl
movl $0x0, %esi
movq %rcx, 0x70(%rsp)
cmovgl %ecx, %esi
movq %rsi, 0x50(%rsp)
movq 0x48(%rsp), %rsi
testb %sil, %sil
movl $0x0, %ecx
cmovgl %esi, %ecx
decl %esi
movq %rsi, 0x58(%rsp)
testl %ebp, %ebp
cmovlel %eax, %ebp
movl %ebp, 0x3c(%rsp)
movslq %edx, %rax
movq %rax, 0x60(%rsp)
movzbl %cl, %eax
movq %rax, 0x68(%rsp)
leaq 0xc0(%rsp), %r15
xorl %eax, %eax
movq %r12, 0x28(%rsp)
movl %eax, 0x1c(%rsp)
cmpl 0x3c(%rsp), %eax
je 0xea0a
movq (%rsp), %rdi
leaq 0x2e79(%rip), %rsi      # 0x114fa
movq %r15, %rdx
xorl %eax, %eax
callq 0x33c0
leaq 0x78(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
leaq 0x17(%rsp), %rdx
callq 0x6a62
leaq 0xa0(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x3250
movq %r14, %rdi
callq 0x30e0
movq 0x20(%rsp), %rax
incl (%rax)
movq 0x8(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x948(%rax), %rbp
cmpb $0x0, 0x18(%rsp)
je 0xe74c
movq 0x28(%rbp), %rbx
movq %r14, %rdi
movq %r13, %rsi
callq 0x32b0
movl %ebx, 0x98(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x9756
movq %r14, %rdi
callq 0x30e0
movq 0x8(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x950(%rax), %rbx
movl 0x28(%rbx), %eax
movl %eax, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x32b0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9942
leaq 0x80(%rsp), %rdi
callq 0x30e0
movl 0x1c(%rsp), %eax
jmp 0xe777
movq %rbp, %rdi
movq %r13, %rsi
callq 0x964e
movq 0x8(%rsp), %rcx
movq 0x68(%rcx), %rcx
movq 0x948(%rcx), %rcx
addq $0x8, %rcx
cmpq %rcx, %rax
je 0xe9cf
movl 0x40(%rax), %eax
movl %eax, 0x10(%rsp)
movq (%rsp), %rdi
leaq 0x2ba0(%rip), %rsi      # 0x11326
xorl %eax, %eax
callq 0x33c0
movq 0x8(%rsp), %rax
movl 0x38(%rax), %ebx
imull 0x10(%rsp), %ebx
xorl %r14d, %r14d
cmpl %r14d, %r12d
jle 0xe7d9
movq (%rsp), %rdi
leaq 0x2d60(%rip), %rsi      # 0x1150d
movq %r15, %rdx
xorl %eax, %eax
callq 0x33c0
movq %r15, %rdi
callq 0x3260
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rax
leal (%rbx,%r14), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
incl %r14d
jmp 0xe79d
movq (%rsp), %rdi
leaq 0x2d1a(%rip), %rsi      # 0x114fe
movq %r15, %rdx
xorl %eax, %eax
callq 0x33c0
movq %r15, %rdi
callq 0x3260
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rax
addl %r14d, %ebx
movslq %ebx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x20(%rsp), %rax
incl (%rax)
movq (%rsp), %rdi
leaq 0x2b18(%rip), %rsi      # 0x11334
xorl %eax, %eax
callq 0x33c0
movq %r15, %r14
movq 0x8(%rsp), %rax
movl 0x38(%rax), %eax
imull 0x10(%rsp), %eax
addl 0x40(%rsp), %eax
cltq
movq %rax, 0x30(%rsp)
xorl %r15d, %r15d
cmpq 0x50(%rsp), %r15
je 0xe8e2
movq %r15, %rbx
imulq 0x60(%rsp), %rbx
shlq $0x3, %rbx
xorl %r12d, %r12d
cmpq %r12, 0x70(%rsp)
je 0xe8d5
movq %r15, %rax
movq 0x28(%rsp), %rbp
xorq %rbp, %rax
movq %rbp, %rcx
xorq %r12, %rcx
orq %rax, %rcx
jne 0xe893
movq (%rsp), %rdi
leaq 0x2c7a(%rip), %rsi      # 0x114fe
movq %r14, %r13
movq %r14, %rdx
xorl %eax, %eax
callq 0x33c0
jmp 0xe8ae
movq (%rsp), %rdi
leaq 0x2c6f(%rip), %rsi      # 0x1150d
movq %r14, %r13
movq %r14, %rdx
xorl %eax, %eax
callq 0x33c0
movq %r12, %rbp
movq %r13, %rdi
callq 0x3260
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rax
addq %rbx, %rax
movq 0x30(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
movsd %xmm0, (%rax,%rbp,8)
incq %r12
jmp 0xe85c
incq %r15
movq 0x28(%rsp), %r12
jmp 0xe841
movq 0x20(%rsp), %rax
incl (%rax)
movq (%rsp), %rdi
leaq 0x2a43(%rip), %rsi      # 0x11337
xorl %eax, %eax
callq 0x33c0
movq %r14, %r15
movq 0x8(%rsp), %rax
movl 0x10(%rsp), %ecx
imull 0x38(%rax), %ecx
addl 0x38(%rsp), %ecx
movslq %ecx, %rax
movq %rax, 0x30(%rsp)
xorl %ebx, %ebx
cmpq 0x50(%rsp), %rbx
je 0xe9ba
movq %rbx, %r15
imulq 0x48(%rsp), %r15
shlq $0x3, %r15
xorl %r12d, %r12d
cmpq %r12, 0x68(%rsp)
je 0xe9aa
cmpq 0x28(%rsp), %rbx
jne 0xe968
cmpq %r12, 0x58(%rsp)
jne 0xe968
movq (%rsp), %rdi
leaq 0x2baa(%rip), %rsi      # 0x114fe
movq %r14, %r13
movq %r14, %rdx
xorl %eax, %eax
callq 0x33c0
movq 0x58(%rsp), %rbp
jmp 0xe983
movq (%rsp), %rdi
leaq 0x2b9a(%rip), %rsi      # 0x1150d
movq %r14, %r13
movq %r14, %rdx
xorl %eax, %eax
callq 0x33c0
movq %r12, %rbp
movq %r13, %rdi
callq 0x3260
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rax
addq %r15, %rax
movq 0x30(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
movsd %xmm0, (%rax,%rbp,8)
incq %r12
jmp 0xe934
incq %rbx
movq %r14, %r15
movq 0x28(%rsp), %r12
jmp 0xe919
pushq $0x1
popq %rax
movq 0x20(%rsp), %rcx
addl %eax, (%rcx)
movl 0x1c(%rsp), %eax
incl %eax
jmp 0xe668
movq (%rsp), %rdi
leaq 0x2b2b(%rip), %rsi      # 0x11505
xorl %eax, %eax
callq 0x33c0
movq (%rsp), %rdi
leaq 0x2b19(%rip), %rsi      # 0x11505
xorl %eax, %eax
callq 0x33c0
movq (%rsp), %rdi
leaq 0x2b07(%rip), %rsi      # 0x11505
xorl %eax, %eax
callq 0x33c0
pushq $0x3
popq %rax
jmp 0xe9bd
leaq 0xa0(%rsp), %rdi
callq 0x30e0
addq $0x8c8, %rsp            # imm = 0x8C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xea55
jmp 0xea55
jmp 0xea55
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
jmp 0xea44
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x30e0
jmp 0xea58
jmp 0xea55
jmp 0xea55
jmp 0xea55
jmp 0xea55
jmp 0xea55
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x30e0
movq %rbx, %rdi
callq 0x3390
nop