// File: myudelson[P]hmm-scalable/HMMProblemSlicedAB.cpp
// Function: HMMProblemSlicedAB::readModelBody(_IO_FILE*, param*, int*, bool)
void HMMProblemSlicedAB::readModelBody(FILE *fid, struct param* param, NDAT *line_no,  bool overwrite) {
	NPAR i,j,m,z, slice;
	NCAT k = 0, idxk = 0;
    std::map<std::string,NCAT>::iterator it;
	string s;
    char col[2048];
    //
    readNullObsRatio(fid, param, 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 skills
	//
	for(k=0; k<param->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, "%*[^\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");
        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
        for(z=0; z<param->nZ; z++) {
            fscanf(fid,"A - slice %hhu\t",&slice);
            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][z][i][j] = atof(col);
                    }
                    else {
                        fscanf(fid,"%[^\t]\t", col); // not las one
                        this->A[idxk][z][i][j] = atof(col);
                    }
                }
            (*line_no)++;
        }
        // read B
        for(z=0; z<param->nZ; z++) {
            fscanf(fid,"B - slice %hhu\t",&slice);
            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][z][i][m] = atof(col);
                    }
                    else {
                        fscanf(fid,"%[^\t]\t", col); // not las one
                        this->B[idxk][z][i][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)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x16650
leaq -0x58(%rbp), %rdi
callq 0x5420
movq -0x930(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x26f70
jmp 0x41988
testb $0x1, -0x21(%rbp)
je 0x41ad4
movl $0x30, %edi
callq 0x52d0
movq %rax, -0x938(%rbp)
jmp 0x419a5
movq -0x938(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x6850
movq -0x930(%rbp), %rax
movq -0x938(%rbp), %rcx
movq 0x88(%rax), %rax
movq %rcx, 0x920(%rax)
movl $0x30, %edi
callq 0x52d0
movq %rax, -0x940(%rbp)
jmp 0x419ee
movq -0x940(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x6890
movq -0x930(%rbp), %rax
movq -0x940(%rbp), %rcx
movq 0x88(%rax), %rax
movq %rcx, 0x928(%rax)
movl $0x30, %edi
callq 0x52d0
movq %rax, -0x948(%rbp)
jmp 0x41a37
movq -0x948(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x6850
movq -0x930(%rbp), %rax
movq -0x948(%rbp), %rcx
movq 0x88(%rax), %rax
movq %rcx, 0x940(%rax)
movl $0x30, %edi
callq 0x52d0
movq %rax, -0x950(%rbp)
jmp 0x41a80
movq -0x950(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x5150
movq -0x950(%rbp), %rdi
callq 0x6890
movq -0x930(%rbp), %rax
movq -0x950(%rbp), %rcx
movq 0x88(%rax), %rax
movq %rcx, 0x948(%rax)
jmp 0x41ad4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x868(%rbp)
movl %eax, -0x86c(%rbp)
jmp 0x42212
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8c0(%rcx), %eax
jge 0x42200
movq -0x10(%rbp), %rdi
leaq 0xedb2(%rip), %rsi      # 0x508ab
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x41b09
leaq -0x891(%rbp), %rdi
movq %rdi, -0x958(%rbp)
callq 0x5550
movq -0x958(%rbp), %rdx
leaq -0x890(%rbp), %rdi
leaq -0x860(%rbp), %rsi
callq 0xc470
jmp 0x41b38
leaq -0x58(%rbp), %rdi
leaq -0x890(%rbp), %rsi
callq 0x53a0
leaq -0x890(%rbp), %rdi
callq 0x5170
leaq -0x891(%rbp), %rdi
callq 0x5320
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
testb $0x1, -0x21(%rbp)
je 0x41cf9
movq -0x930(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x940(%rax), %rdi
movq %rdi, -0x960(%rbp)
callq 0x167a0
movl %eax, -0x8c4(%rbp)
leaq -0x8c0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x8c4(%rbp), %rdx
callq 0x16a60
jmp 0x41bb5
movq -0x960(%rbp), %rdi
leaq -0x8c0(%rbp), %rsi
callq 0x16850
movb %dl, -0x969(%rbp)
movq %rax, -0x968(%rbp)
jmp 0x41bd7
movb -0x969(%rbp), %al
movq -0x968(%rbp), %rcx
movq %rcx, -0x8d8(%rbp)
movb %al, -0x8d0(%rbp)
leaq -0x8c0(%rbp), %rdi
callq 0x168d0
movq -0x930(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x948(%rax), %rdi
movq %rdi, -0x978(%rbp)
callq 0x16aa0
movl %eax, -0x904(%rbp)
leaq -0x900(%rbp), %rdi
leaq -0x904(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x16ac0
jmp 0x41c3d
movq -0x978(%rbp), %rdi
leaq -0x900(%rbp), %rsi
callq 0x168f0
movb %dl, -0x981(%rbp)
movq %rax, -0x980(%rbp)
jmp 0x41c5f
movb -0x981(%rbp), %al
movq -0x980(%rbp), %rcx
movq %rcx, -0x918(%rbp)
movb %al, -0x910(%rbp)
leaq -0x900(%rbp), %rdi
callq 0x16970
movl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x41dcd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x868(%rbp)
movl %eax, -0x86c(%rbp)
leaq -0x891(%rbp), %rdi
callq 0x5320
jmp 0x42212
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x868(%rbp)
movl %eax, -0x86c(%rbp)
leaq -0x8c0(%rbp), %rdi
callq 0x168d0
jmp 0x42212
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x868(%rbp)
movl %eax, -0x86c(%rbp)
leaq -0x900(%rbp), %rdi
callq 0x16970
jmp 0x42212
movq -0x930(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x940(%rax), %rdi
leaq -0x58(%rbp), %rsi
callq 0x16710
movq %rax, -0x990(%rbp)
jmp 0x41d20
movq -0x930(%rbp), %rax
movq -0x990(%rbp), %rcx
movq %rcx, -0x920(%rbp)
movq -0x920(%rbp), %rcx
movq %rcx, -0x38(%rbp)
movq 0x88(%rax), %rax
movq 0x940(%rax), %rdi
callq 0x16770
movq %rax, -0x928(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x928(%rbp), %rsi
callq 0x16740
testb $0x1, %al
jne 0x41d70
jmp 0x41dbc
movq -0x10(%rbp), %rdi
leaq 0xeb3b(%rip), %rsi      # 0x508b6
xorl %eax, %eax
callq 0x5580
jmp 0x41d84
movq -0x10(%rbp), %rdi
leaq 0xeb27(%rip), %rsi      # 0x508b6
xorl %eax, %eax
callq 0x5580
jmp 0x41d98
movq -0x10(%rbp), %rdi
leaq 0xeb13(%rip), %rsi      # 0x508b6
xorl %eax, %eax
callq 0x5580
jmp 0x41dac
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x3, %ecx
movl %ecx, (%rax)
jmp 0x421f2
leaq -0x38(%rbp), %rdi
callq 0x16990
movl 0x20(%rax), %eax
movl %eax, -0x30(%rbp)
jmp 0x41dcd
movq -0x10(%rbp), %rdi
leaq 0xe7fa(%rip), %rsi      # 0x505d2
xorl %eax, %eax
callq 0x5580
jmp 0x41de1
movb $0x0, -0x22(%rbp)
movq -0x930(%rbp), %rcx
movsbl -0x22(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x41e53
movq -0x10(%rbp), %rdi
leaq 0xeaae(%rip), %rsi      # 0x508be
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x41e20
leaq -0x860(%rbp), %rdi
callq 0x53c0
movq -0x930(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x22(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movb -0x22(%rbp), %al
addb $0x1, %al
movb %al, -0x22(%rbp)
jmp 0x41de5
movq -0x10(%rbp), %rdi
leaq 0xea51(%rip), %rsi      # 0x508af
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x41e6e
leaq -0x860(%rbp), %rdi
callq 0x53c0
movq -0x930(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x22(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movb $0x0, -0x25(%rbp)
movsbl -0x25(%rbp), %eax
movq -0x18(%rbp), %rcx
movsbl 0x8c8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x42049
movq -0x10(%rbp), %rdi
leaq 0xedd1(%rip), %rsi      # 0x50c99
xorl %eax, %eax
leaq -0x26(%rbp), %rdx
callq 0x5580
jmp 0x41ed5
movb $0x0, -0x22(%rbp)
movq -0x930(%rbp), %rcx
movsbl -0x22(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x42031
movb $0x0, -0x23(%rbp)
movq -0x930(%rbp), %rcx
movsbl -0x23(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x42022
movq -0x930(%rbp), %rcx
movsbl -0x22(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x41fba
movq -0x930(%rbp), %rcx
movsbl -0x23(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x41fba
movq -0x10(%rbp), %rdi
leaq 0xe945(%rip), %rsi      # 0x508af
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x41f7a
leaq -0x860(%rbp), %rdi
callq 0x53c0
movq -0x930(%rbp), %rax
movq 0x90(%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x25(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x22(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x23(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x42013
movq -0x10(%rbp), %rdi
leaq 0xe8f9(%rip), %rsi      # 0x508be
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x41fd5
leaq -0x860(%rbp), %rdi
callq 0x53c0
movq -0x930(%rbp), %rax
movq 0x90(%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x25(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x22(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x23(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x42015
movb -0x23(%rbp), %al
addb $0x1, %al
movb %al, -0x23(%rbp)
jmp 0x41efe
jmp 0x42024
movb -0x22(%rbp), %al
addb $0x1, %al
movb %al, -0x22(%rbp)
jmp 0x41ed9
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movb -0x25(%rbp), %al
addb $0x1, %al
movb %al, -0x25(%rbp)
jmp 0x41ea6
movb $0x0, -0x25(%rbp)
movsbl -0x25(%rbp), %eax
movq -0x18(%rbp), %rcx
movsbl 0x8c8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x421f0
movq -0x10(%rbp), %rdi
leaq 0xec3a(%rip), %rsi      # 0x50ca9
xorl %eax, %eax
leaq -0x26(%rbp), %rdx
callq 0x5580
jmp 0x4207c
movb $0x0, -0x22(%rbp)
movq -0x930(%rbp), %rcx
movsbl -0x22(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x421d8
movb $0x0, -0x24(%rbp)
movq -0x930(%rbp), %rcx
movsbl -0x24(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x421c9
movq -0x930(%rbp), %rcx
movsbl -0x22(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x42161
movq -0x930(%rbp), %rcx
movsbl -0x24(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x42161
movq -0x10(%rbp), %rdi
leaq 0xe79e(%rip), %rsi      # 0x508af
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x42121
leaq -0x860(%rbp), %rdi
callq 0x53c0
movq -0x930(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x25(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x22(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x421ba
movq -0x10(%rbp), %rdi
leaq 0xe752(%rip), %rsi      # 0x508be
xorl %eax, %eax
leaq -0x860(%rbp), %rdx
callq 0x5580
jmp 0x4217c
leaq -0x860(%rbp), %rdi
callq 0x53c0
movq -0x930(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x25(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x22(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x421bc
movb -0x24(%rbp), %al
addb $0x1, %al
movb %al, -0x24(%rbp)
jmp 0x420a5
jmp 0x421cb
movb -0x22(%rbp), %al
addb $0x1, %al
movb %al, -0x22(%rbp)
jmp 0x42080
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movb -0x25(%rbp), %al
addb $0x1, %al
movb %al, -0x25(%rbp)
jmp 0x4204d
jmp 0x421f2
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x41adb
leaq -0x58(%rbp), %rdi
callq 0x5170
addq $0x990, %rsp            # imm = 0x990
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0x5170
movq -0x868(%rbp), %rdi
callq 0x5540
nopw (%rax,%rax)