// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/savemodel.c
// Function: save_model_hmm
void save_model_hmm(FILE* modelfile, Datasetptr d, Hmmptr* hmmarray)
{
 /*Last Changed 02.04.2007*/
 /*Last Changed 26.02.2007*/
 int i, j, k;
 char pst[READLINELENGTH];
 Multinomialptr m;
 Hmmptr h;
 Gaussianptr g;
 Gaussianmixtureptr gm;
 Dirichletptr di;
 Dirichletmixtureptr dm;
 set_precision(pst, NULL, "\n");
 for (k = 0; k < d->classno; k++)
  {
   h = hmmarray[k];
   fprintf(modelfile, "%d %d\n", h->statecount, h->statetype);
   for (i = 0; i < h->statecount; i++)
    {
     save_array(modelfile, h->states[i].a_dot_j, h->statecount);
     save_array(modelfile, h->states[i].a_i_dot, h->statecount);
     fprintf(modelfile, pst, h->states[i].pi);
     switch (h->statetype)
      {
       case          STATE_DISCRETE:m = (Multinomialptr) (h->states[i].b);
                                    for (j = 0; j < d->featurecount; j++)
                                      if (d->features[j].type == STRING)
                                        save_array(modelfile, m->prob[j], d->features[j].valuecount);
                                    break;
       case          STATE_GAUSSIAN:g = (Gaussianptr) (h->states[i].b);
                                    save_array(modelfile, g->mean, d->multifeaturecount - 1);
                                    save_matrix(modelfile, g->covariance);
                                    break;
       case  STATE_GAUSSIAN_MIXTURE:gm = (Gaussianmixtureptr) (h->states[i].b);
                                    fprintf(modelfile, "%d\n", gm->componentcount);
                                    save_array(modelfile, gm->weights, gm->componentcount);
                                    for (j = 0; j < gm->componentcount; j++)
                                     {
                                      save_array(modelfile, gm->components[j].mean, d->multifeaturecount - 1);
                                      save_matrix(modelfile, gm->components[j].covariance); 
                                     }
                                    break;
       case         STATE_DIRICHLET:di = (Dirichletptr) (h->states[i].b);
                                    save_array(modelfile, di->alpha, d->multifeaturecount - 1);
                                    break;
       case STATE_DIRICHLET_MIXTURE:dm = (Dirichletmixtureptr) (h->states[i].b);
                                    fprintf(modelfile, "%d\n", dm->componentcount);
                                    save_array(modelfile, dm->weights, dm->componentcount);
                                    for (j = 0; j < dm->componentcount; j++)
                                      save_array(modelfile, dm->components[j].alpha, d->multifeaturecount - 1);
                                    break;
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x7a190, %rsp          # imm = 0x7A190
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x7a150(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
leaq 0x2a1d2(%rip), %rdx     # 0xe5d3b
callq 0x53310
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0xbbf4f
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x7a160(%rbp)
movq -0x8(%rbp), %rdi
movq -0x7a160(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x7a160(%rbp), %rax
movl 0xc(%rax), %ecx
leaq 0x26f0d(%rip), %rsi     # 0xe2ac4
movb $0x0, %al
callq 0x4280
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x7a160(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xbbf3f
movq -0x8(%rbp), %rdi
movq -0x7a160(%rbp), %rax
movq (%rax), %rcx
movslq -0x1c(%rbp), %rdx
shlq $0x5, %rdx
movq (%rcx,%rdx), %rsi
movl 0x8(%rax), %edx
callq 0xb9b80
movq -0x8(%rbp), %rdi
movq -0x7a160(%rbp), %rax
movq (%rax), %rcx
movslq -0x1c(%rbp), %rdx
shlq $0x5, %rdx
movq 0x8(%rcx,%rdx), %rsi
movl 0x8(%rax), %edx
callq 0xb9b80
movq -0x8(%rbp), %rdi
movq -0x7a160(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
movsd 0x10(%rax,%rcx), %xmm0
leaq -0x7a150(%rbp), %rsi
movb $0x1, %al
callq 0x4280
movq -0x7a160(%rbp), %rax
movl 0xc(%rax), %eax
movq %rax, -0x7a188(%rbp)
subq $0x4, %rax
ja 0xbbf2f
movq -0x7a188(%rbp), %rax
leaq 0x317f8(%rip), %rcx     # 0xed468
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x7a160(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x7a158(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0xbbd0f
movq -0x10(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x20(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x1, (%rax)
jne 0xbbd02
movq -0x8(%rbp), %rdi
movq -0x7a158(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x10(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x20(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movl 0x18(%rax), %edx
callq 0xb9b80
jmp 0xbbd04
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xbbca0
jmp 0xbbf2f
movq -0x7a160(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x7a168(%rbp)
movq -0x8(%rbp), %rdi
movq -0x7a168(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x1c0(%rax), %edx
subl $0x1, %edx
callq 0xb9b80
movq -0x8(%rbp), %rdi
movq -0x7a168(%rbp), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
callq 0xb9ad0
jmp 0xbbf2f
movq -0x7a160(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x7a170(%rbp)
movq -0x8(%rbp), %rdi
movq -0x7a170(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x30eab(%rip), %rsi     # 0xecc51
movb $0x0, %al
callq 0x4280
movq -0x8(%rbp), %rdi
movq -0x7a170(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x7a170(%rbp), %rax
movl 0x8(%rax), %edx
callq 0xb9b80
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x7a170(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xbbe40
movq -0x8(%rbp), %rdi
movq -0x7a170(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x1c0(%rax), %edx
subl $0x1, %edx
callq 0xb9b80
movq -0x8(%rbp), %rdi
movq -0x7a170(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
callq 0xb9ad0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xbbdd2
jmp 0xbbf2f
movq -0x7a160(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x7a178(%rbp)
movq -0x8(%rbp), %rdi
movq -0x7a178(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x1c0(%rax), %edx
subl $0x1, %edx
callq 0xb9b80
jmp 0xbbf2f
movq -0x7a160(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x7a180(%rbp)
movq -0x8(%rbp), %rdi
movq -0x7a180(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x30d92(%rip), %rsi     # 0xecc51
movb $0x0, %al
callq 0x4280
movq -0x8(%rbp), %rdi
movq -0x7a180(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x7a180(%rbp), %rax
movl 0x8(%rax), %edx
callq 0xb9b80
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x7a180(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xbbf2d
movq -0x8(%rbp), %rdi
movq -0x7a180(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x10(%rbp), %rax
movl 0x1c0(%rax), %edx
subl $0x1, %edx
callq 0xb9b80
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xbbeeb
jmp 0xbbf2f
jmp 0xbbf31
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xbbbc5
jmp 0xbbf41
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xbbb75
addq $0x7a190, %rsp          # imm = 0x7A190
popq %rbp
retq
nopl (%rax,%rax)