// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/HMMProblemPiGKww.cpp
// Function: HMMProblemPiGKww::readModelBody(_IO_FILE*, param*, int*, bool)
void HMMProblemPiGKww::readModelBody(FILE *fid, struct param* param, NDAT *line_no, bool overwrite) {
	NPAR i,j,m;
	NCAT k = 0, g = 0, idxk = 0, idxg = 0;
	string s;
    std::map<std::string,NCAT>::iterator it;
    char col[2048];
    // null skill ratios
    readNullObsRatio(fid, param, line_no);
    // ww weights
    fscanf(fid, "Student and skill component ratios\t");
    this->ww[0] = 0.5;//1;
    this->ww[1] = 0.5;//1;
    this->ww[2] = 0;//0;
    fscanf(fid,"%lf\t",&this->ww[0] );
    fscanf(fid,"%lf\t",&this->ww[1] );
    fscanf(fid,"%lf\n",&this->ww[2] );
    (*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 grouped PIg
	//
    for(g=0; g<this->p->nG; g++) {
		// read group label
        fscanf(fid,"%*s\t%[^\n]\n",col);
        s = string( col );
        (*line_no)++;        
        if(overwrite) {
            this->p->map_group_fwd->insert(pair<string,NCAT>(s, (NCAT)this->p->map_group_fwd->size()));
            this->p->map_group_bwd->insert(pair<NCAT,string>((NCAT)this->p->map_group_bwd->size(), s));
            idxg = g;
        } else {
            it = this->p->map_group_fwd->find(s);
            if( it==this->p->map_group_fwd->end() ) { // not found, skip 3 lines and continue
                fscanf(fid,"%*s\n");
                fscanf(fid,"%*s\n");
                fscanf(fid,"%*s\n");
                continue; // skip this iteration
            }
            else
                idxg =it->second;
        }

        // read PIg
        fscanf(fid,"PIg\t");
        for(i=0; i<(this->p->nS-1); i++) { // read 1 less then necessary
            fscanf(fid,"%[^\t]\t",col);
            this->PIg[idxg][i] = atof(col);
        }
        fscanf(fid,"%[^\n]\n",col);// read last one
        this->PIg[idxg][i] = atof(col);
        (*line_no)++;
    }
    //
    // read skills
    //
	for(k=0; k<this->p->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,"%*s\n");
                fscanf(fid,"%*s\n");
                fscanf(fid,"%*s\n");
                continue; // skip this iteration
            }
            else
                idxk =it->second;
        }
        
        // read PI
        fscanf(fid,"PIk\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 las one
                    this->B[idxk][i][m] = atof(col);
                }
			}
        (*line_no)++;
	} // for all k
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x868, %rsp            # imm = 0x868
movl %r8d, 0x3c(%rsp)
movq %rsi, %r15
movq %rdi, %r12
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rcx, 0x30(%rsp)
callq 0x19276
leaq 0x1865b(%rip), %rsi     # 0x359b8
movq %r15, %rdi
xorl %eax, %eax
callq 0x4460
movq 0x98(%r12), %rdx
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, (%rdx)
movq %rax, 0x8(%rdx)
movq $0x0, 0x10(%rdx)
leaq 0x18443(%rip), %rsi     # 0x357d2
movq %r15, %rdi
xorl %eax, %eax
callq 0x4460
movq 0x98(%r12), %rdx
addq $0x8, %rdx
leaq 0x18426(%rip), %rsi     # 0x357d2
movq %r15, %rdi
xorl %eax, %eax
callq 0x4460
movq 0x98(%r12), %rdx
addq $0x10, %rdx
leaq 0x18404(%rip), %rsi     # 0x357cd
movq %r15, %rdi
xorl %eax, %eax
callq 0x4460
movq 0x30(%rsp), %rax
incl (%rax)
cmpb $0x0, 0x3c(%rsp)
je 0x1d4c5
movl $0x30, %edi
callq 0x4210
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 0x88(%r12), %rbx
movq %rax, 0x920(%rbx)
movl $0x30, %edi
callq 0x4210
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, 0x928(%rbx)
movl $0x30, %edi
callq 0x4210
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, 0x940(%rbx)
movl $0x30, %edi
callq 0x4210
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)
movq 0x88(%r12), %rax
cmpl $0x0, 0x8bc(%rax)
jle 0x1d766
leaq 0x60(%rsp), %rbp
movl $0x0, 0x4(%rsp)
movq %r15, %rdi
leaq 0x182e6(%rip), %rsi     # 0x357d7
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4460
leaq 0x18(%rsp), %r14
movq %r14, 0x8(%rsp)
movq %rbp, %rdi
callq 0x4100
leaq (%rsp,%rax), %rdx
addq $0x60, %rdx
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xa7c0
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x42c0
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x1d549
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4220
movq 0x30(%rsp), %rax
incl (%rax)
movq 0x88(%r12), %rax
movq 0x920(%rax), %r14
cmpb $0x0, 0x3c(%rsp)
je 0x1d62d
movq 0x28(%r14), %r13
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa6c2
movl %r13d, 0x28(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x10240
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
leaq 0x18234(%rip), %rbx     # 0x357ea
je 0x1d5c5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4220
movq 0x88(%r12), %rax
movq 0x928(%rax), %r14
movl 0x28(%r14), %eax
movl %eax, 0x8(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0xa6c2
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
callq 0x1040a
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1d626
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4220
movl 0x4(%rsp), %r14d
jmp 0x1d661
movq %r14, %rdi
leaq 0x40(%rsp), %rsi
callq 0x10148
leaq 0x181a9(%rip), %rbx     # 0x357ea
movq 0x88(%r12), %rcx
movq 0x920(%rcx), %rcx
addq $0x8, %rcx
cmpq %rcx, %rax
je 0x1d731
movl 0x40(%rax), %r14d
movq %r15, %rdi
leaq 0x1822e(%rip), %rsi     # 0x35899
xorl %eax, %eax
callq 0x4460
movq 0x88(%r12), %rax
cmpb $0x2, 0x8b8(%rax)
movslq %r14d, %r14
jl 0x1d6d9
xorl %r13d, %r13d
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4460
movq %rbp, %rdi
callq 0x42d0
movq 0x90(%r12), %rax
movq (%rax,%r14,8), %rax
movsbq %r13b, %r13
movsd %xmm0, (%rax,%r13,8)
incb %r13b
movsbl %r13b, %eax
movq 0x88(%r12), %rcx
movsbl 0x8b8(%rcx), %ecx
decl %ecx
cmpl %eax, %ecx
jg 0x1d689
movsbq %r13b, %r13
jmp 0x1d6dc
xorl %r13d, %r13d
movq %r15, %rdi
leaq 0x180f5(%rip), %rsi     # 0x357db
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4460
movq %rbp, %rdi
callq 0x42d0
movq 0x90(%r12), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%r13,8)
movq 0x30(%rsp), %rax
incl (%rax)
movl 0x4(%rsp), %ecx
incl %ecx
movq 0x88(%r12), %rax
movl %ecx, 0x4(%rsp)
cmpl 0x8bc(%rax), %ecx
jl 0x1d4e7
jmp 0x1d766
movq %r15, %rdi
leaq 0x1823d(%rip), %rsi     # 0x35978
xorl %eax, %eax
callq 0x4460
movq %r15, %rdi
leaq 0x1822c(%rip), %rsi     # 0x35978
xorl %eax, %eax
callq 0x4460
movq %r15, %rdi
leaq 0x1821b(%rip), %rsi     # 0x35978
xorl %eax, %eax
callq 0x4460
jmp 0x1d711
movq 0x88(%r12), %rax
cmpl $0x0, 0x8c0(%rax)
jle 0x1db87
leaq 0x60(%rsp), %r13
leaq 0x8(%rsp), %rbp
movl $0x0, 0x4(%rsp)
movq %r15, %rdi
leaq 0x18040(%rip), %rsi     # 0x357d7
movq %r13, %rdx
xorl %eax, %eax
callq 0x4460
leaq 0x18(%rsp), %rbx
movq %rbx, 0x8(%rsp)
movq %r13, %rdi
callq 0x4100
leaq (%rsp,%rax), %rdx
addq $0x60, %rdx
movq %rbp, %rdi
movq %r13, %rsi
callq 0xa7c0
leaq 0x40(%rsp), %rdi
movq %rbp, %rsi
callq 0x42c0
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1d7ea
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4220
movq 0x30(%rsp), %rax
incl (%rax)
movq 0x88(%r12), %rax
movq 0x940(%rax), %r14
cmpb $0x0, 0x3c(%rsp)
je 0x1d8be
movq 0x28(%r14), %rbx
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0xa6c2
movl %ebx, 0x28(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x10240
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1d859
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4220
movq 0x88(%r12), %rax
movq 0x948(%rax), %r14
movl 0x28(%r14), %eax
movl %eax, 0x8(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0xa6c2
movq %r14, %rdi
movq %rbp, %rsi
callq 0x1040a
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1d8b8
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4220
movl 0x4(%rsp), %ebx
jmp 0x1d8ea
movq %r14, %rdi
leaq 0x40(%rsp), %rsi
callq 0x10148
movq 0x88(%r12), %rcx
movq 0x940(%rcx), %rcx
addq $0x8, %rcx
cmpq %rcx, %rax
je 0x1db52
movl 0x40(%rax), %ebx
movq %r15, %rdi
leaq 0x17faa(%rip), %rsi     # 0x3589e
xorl %eax, %eax
callq 0x4460
movq 0x88(%r12), %rax
cmpb $0x2, 0x8b8(%rax)
movslq %ebx, %r14
jl 0x1d95f
xorl %ebx, %ebx
movq %r15, %rdi
leaq 0x17ecf(%rip), %rsi     # 0x357ea
movq %r13, %rdx
xorl %eax, %eax
callq 0x4460
movq %r13, %rdi
callq 0x42d0
movq 0x38(%r12), %rax
movq (%rax,%r14,8), %rax
movsbq %bl, %rbx
movsd %xmm0, (%rax,%rbx,8)
incb %bl
movsbl %bl, %eax
movq 0x88(%r12), %rcx
movsbl 0x8b8(%rcx), %ecx
decl %ecx
cmpl %eax, %ecx
jg 0x1d911
movsbq %bl, %rbx
jmp 0x1d961
xorl %ebx, %ebx
movq %r15, %rdi
leaq 0x17e70(%rip), %rsi     # 0x357db
movq %r13, %rdx
xorl %eax, %eax
callq 0x4460
movq %r13, %rdi
callq 0x42d0
movq 0x38(%r12), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%rbx,8)
movq 0x30(%rsp), %rax
incl (%rax)
movq %r15, %rdi
leaq 0x17b66(%rip), %rsi     # 0x35502
xorl %eax, %eax
callq 0x4460
movq 0x88(%r12), %rax
cmpb $0x0, 0x8b8(%rax)
jle 0x1da55
xorl %ebp, %ebp
movq 0x88(%r12), %rax
movb 0x8b8(%rax), %al
testb %al, %al
jle 0x1da39
xorl %ebx, %ebx
movsbl %al, %eax
decl %eax
movl %ebx, %ecx
xorl %eax, %ecx
xorl %ebp, %eax
orl %ecx, %eax
jne 0x1d9f3
movq %r15, %rdi
leaq 0x17df4(%rip), %rsi     # 0x357db
movq %r13, %rdx
xorl %eax, %eax
callq 0x4460
jmp 0x1da07
movq %r15, %rdi
leaq 0x17ded(%rip), %rsi     # 0x357ea
movq %r13, %rdx
xorl %eax, %eax
callq 0x4460
movq %r13, %rdi
callq 0x42d0
movq 0x40(%r12), %rax
movq (%rax,%r14,8), %rax
movq (%rax,%rbp,8), %rax
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
movq 0x88(%r12), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %rbx
jl 0x1d9ce
incq %rbp
movq 0x88(%r12), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %rbp
jl 0x1d9ba
movq 0x30(%rsp), %rax
incl (%rax)
movq %r15, %rdi
leaq 0x17a9f(%rip), %rsi     # 0x35505
xorl %eax, %eax
callq 0x4460
movq 0x88(%r12), %rax
cmpb $0x0, 0x8b8(%rax)
jle 0x1db26
xorl %ebp, %ebp
movq 0x88(%r12), %rcx
movb 0x8b9(%rcx), %al
testb %al, %al
jle 0x1db0a
xorl %ebx, %ebx
movsbl 0x8b8(%rcx), %ecx
decl %ecx
cmpl %ebp, %ecx
jne 0x1dac4
movsbl %al, %eax
decl %eax
cmpl %eax, %ebx
jne 0x1dac4
movq %r15, %rdi
leaq 0x17d23(%rip), %rsi     # 0x357db
movq %r13, %rdx
xorl %eax, %eax
callq 0x4460
jmp 0x1dad8
movq %r15, %rdi
leaq 0x17d1c(%rip), %rsi     # 0x357ea
movq %r13, %rdx
xorl %eax, %eax
callq 0x4460
movq %r13, %rdi
callq 0x42d0
movq 0x48(%r12), %rax
movq (%rax,%r14,8), %rax
movq (%rax,%rbp,8), %rax
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
movq 0x88(%r12), %rcx
movsbq 0x8b9(%rcx), %rax
cmpq %rax, %rbx
jl 0x1da98
incq %rbp
movq 0x88(%r12), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %rbp
jl 0x1da84
movq 0x30(%rsp), %rax
incl (%rax)
leaq 0x8(%rsp), %rbp
movl 0x4(%rsp), %ecx
incl %ecx
movq 0x88(%r12), %rax
movl %ecx, 0x4(%rsp)
cmpl 0x8c0(%rax), %ecx
jl 0x1d78d
jmp 0x1db87
movq %r15, %rdi
leaq 0x17e1c(%rip), %rsi     # 0x35978
xorl %eax, %eax
callq 0x4460
movq %r15, %rdi
leaq 0x17e0b(%rip), %rsi     # 0x35978
xorl %eax, %eax
callq 0x4460
movq %r15, %rdi
leaq 0x17dfa(%rip), %rsi     # 0x35978
xorl %eax, %eax
callq 0x4460
jmp 0x1db32
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1dba3
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4220
addq $0x868, %rsp            # imm = 0x868
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1dc0f
jmp 0x1dc0f
jmp 0x1dc0f
jmp 0x1dc0f
jmp 0x1dbc7
jmp 0x1dbe0
jmp 0x1dc0f
jmp 0x1dc0f
jmp 0x1dc0f
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1dc12
movq 0x18(%rsp), %rsi
jmp 0x1dbf7
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1dc12
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4220
jmp 0x1dc12
jmp 0x1dc0f
jmp 0x1dc0f
jmp 0x1dc0f
jmp 0x1dc0f
jmp 0x1dc0f
jmp 0x1dc0f
jmp 0x1dc0f
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1dc2e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4220
movq %rbx, %rdi
callq 0x4430
nop