// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/hmm.c
// Function: update_state_model
void update_state_model(void *model, double accum, double *accumMix, HMM_STATE_TYPE statetype)
{
 /*!Last Changed 27.03.2007*/
 Gaussianptr g;
 Gaussianmixtureptr gm;
 Multinomialptr m;
 Dirichletptr d;
 Dirichletmixtureptr dm;
 int i, j;
 double mul = (1.0 / accum);
 int numrealfeatures = current_dataset->multifeaturecount - 1;
 matrix covprior;
 switch (statetype)
  {
   case          STATE_DISCRETE:m = (Multinomialptr) model;
                                j = 0;
                                for (i = 0; i < current_dataset->featurecount; i++)
                                  if (current_dataset->features[i].type == STRING)
                                   {
                                    multiply_array(m->prob[j], mul, current_dataset->features[i].valuecount);
                                    j++;
                                   }
                                break;
   case          STATE_GAUSSIAN:g = (Gaussianptr) model;
                                multiply_array(g->mean, mul, numrealfeatures);
                                matrix_multiply_constant(&(g->covariance), mul);
                                covprior = identity(g->covariance.row);
                                matrix_multiply_constant(&(covprior), PRIOR);
                                matrix_add(&(g->covariance), covprior);
                                matrix_free(covprior);
                                break;
   case  STATE_GAUSSIAN_MIXTURE:gm = (Gaussianmixtureptr) model;
                                multiply_array(gm->weights, mul, gm->componentcount);
                                for (i = 0; i < gm->componentcount; i++)
                                 {
                                  multiply_array(gm->components[i].mean, (1.0 / accumMix[i]), numrealfeatures);
                                  matrix_multiply_constant(&(gm->components[i].covariance), (1.0 / accumMix[i]));
                                  covprior = identity(gm->components[i].covariance.row);
                                  matrix_multiply_constant(&(covprior), PRIOR);
                                  matrix_add(&(gm->components[i].covariance), covprior);
                                  matrix_free(covprior);
                                 }
                                break;
   case         STATE_DIRICHLET:d = (Dirichletptr) model;
                                multiply_array(d->alpha, mul, numrealfeatures);
                                break;
   case STATE_DIRICHLET_MIXTURE:dm = (Dirichletmixtureptr) model;
                                multiply_array(dm->weights, mul, dm->componentcount);
                                for (i = 0; i < dm->componentcount; i++)
                                  multiply_array(dm->components[i].alpha, (1.0 / accumMix[i]), numrealfeatures);
                                break;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpl $0x4, %edx
ja 0x2a06e
movq %rsi, %r14
movq %rdi, %rbx
movsd 0x7b6c4(%rip), %xmm2    # 0xa5520
divsd %xmm0, %xmm2
leaq 0xaba09(%rip), %r15     # 0xd5870
movq (%r15), %rax
movl 0x1c0(%rax), %ebp
decl %ebp
movl %edx, %ecx
leaq 0x7e491(%rip), %rdx     # 0xa830c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x0, 0x1bc(%rax)
jle 0x2a06e
xorl %r14d, %r14d
movl $0x30f20, %r12d         # imm = 0x30F20
xorl %r13d, %r13d
movsd %xmm2, (%rsp)
cmpl $0x1, -0x18(%rax,%r12)
jne 0x29ecc
movq (%rbx), %rcx
movslq %r13d, %r13
movq (%rcx,%r13,8), %rdi
movl (%rax,%r12), %esi
movapd %xmm2, %xmm0
callq 0x383f7
movsd (%rsp), %xmm2
incl %r13d
movq (%r15), %rax
incq %r14
movslq 0x1bc(%rax), %rcx
addq $0x340, %r12            # imm = 0x340
cmpq %rcx, %r14
jl 0x29ea2
jmp 0x2a06e
movq 0x10(%rbx), %rdi
movl 0x8(%rbx), %esi
movapd %xmm2, %xmm0
callq 0x383f7
cmpl $0x0, 0x8(%rbx)
jle 0x2a06e
xorl %r15d, %r15d
movq (%rbx), %rax
movq (%rax,%r15,8), %rdi
movsd 0x7b60d(%rip), %xmm0    # 0xa5520
divsd (%r14,%r15,8), %xmm0
movl %ebp, %esi
callq 0x383f7
incq %r15
movslq 0x8(%rbx), %rax
cmpq %rax, %r15
jl 0x29f04
jmp 0x2a06e
movq 0x10(%rbx), %rdi
movl 0x8(%rbx), %esi
movapd %xmm2, %xmm0
callq 0x383f7
cmpl $0x0, 0x8(%rbx)
jle 0x2a06e
movl $0x8, %r12d
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
movq (%rbx), %rax
movq -0x8(%rax,%r12), %rdi
movsd 0x7b5b7(%rip), %xmm0    # 0xa5520
divsd (%r14,%r13,8), %xmm0
movl %ebp, %esi
callq 0x383f7
movq (%rbx), %rdi
addq %r12, %rdi
movsd 0x7b59c(%rip), %xmm0    # 0xa5520
divsd (%r14,%r13,8), %xmm0
callq 0x3f7c2
movq (%rbx), %rax
movl (%rax,%r12), %edi
callq 0x3eddb
movq %rax, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %r15, %rdi
movsd 0x7be10(%rip), %xmm0    # 0xa5dc0
callq 0x3f7c2
movq (%rbx), %rdi
addq %r12, %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0x3f993
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x3ed51
incq %r13
movslq 0x8(%rbx), %rax
addq $0x18, %r12
cmpq %rax, %r13
jl 0x29f59
jmp 0x2a06e
movq (%rbx), %rdi
movapd %xmm2, %xmm0
movl %ebp, %esi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x383f7
movq (%rbx), %rdi
movapd %xmm2, %xmm0
movl %ebp, %esi
movsd %xmm2, (%rsp)
callq 0x383f7
leaq 0x8(%rbx), %r14
movq %r14, %rdi
movsd (%rsp), %xmm0
callq 0x3f7c2
movl 0x8(%rbx), %edi
callq 0x3eddb
leaq 0x8(%rsp), %rbx
movq %rax, (%rbx)
movq %rdx, 0x8(%rbx)
movsd 0x7bd75(%rip), %xmm0    # 0xa5dc0
movq %rbx, %rdi
callq 0x3f7c2
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x3f993
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq 0x3ed51
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq