// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/hmm.c
// Function: random_state_model
void* random_state_model(HMM_STATE_TYPE statetype, int componentcount, Instanceptr traindata)
{
 /*!Last Changed 27.03.2007*/
 Gaussianptr g;
 Gaussianmixtureptr gm;
 Multinomialptr m;
 Dirichletptr d;
 Dirichletmixtureptr dm;
 int i, j;
 switch (statetype)
  {
   case          STATE_DISCRETE:m = safemalloc(sizeof(Multinomial), "random_state_model", 10);
                                m->prob = safemalloc(sizeof(double*) * (current_dataset->featurecount - 1), "random_state_model", 11);
                                j = 0;
                                for (i = 0; i < current_dataset->featurecount; i++)
                                  if (current_dataset->features[i].type == STRING)
                                   {
                                    m->prob[j] = random_normalized_array(current_dataset->features[i].valuecount);
                                    j++;
                                   }
                                return m;
                                break;
   case          STATE_GAUSSIAN:g = safemalloc(sizeof(Gaussian), "random_state_model", 21);
                                random_gaussian(g, traindata);
                                return g;
                                break;
   case  STATE_GAUSSIAN_MIXTURE:gm = safemalloc(sizeof(Gaussianmixture), "random_state_model", 26);
                                gm->componentcount = componentcount;
                                gm->weights = random_normalized_array(gm->componentcount);
                                gm->components = safemalloc(componentcount * sizeof(Gaussian), "random_state_model", 29);
                                for (i = 0; i < gm->componentcount; i++)
                                  random_gaussian(&(gm->components[i]), traindata);
                                return gm;
                                break;
   case         STATE_DIRICHLET:d = safemalloc(sizeof(Dirichlet), "random_state_model", 37);
                                random_dirichlet(d, traindata);
                                return d;
                                break;
   case STATE_DIRICHLET_MIXTURE:dm = safemalloc(sizeof(Dirichletmixture), "random_state_model", 41);
                                dm->componentcount = componentcount;
                                dm->weights = random_normalized_array(dm->componentcount);
                                dm->components = safemalloc(componentcount * sizeof(Dirichlet), "random_state_model", 44);
                                for (i = 0; i < dm->componentcount; i++)
                                  random_dirichlet(&(dm->components[i]), traindata);
                                return dm;
                                break;
   default                     :return NULL;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x4, %edi
ja 0x24a1e
movq %rdx, %r14
movl %esi, %ebp
movl %edi, %eax
leaq 0x73952(%rip), %rcx     # 0x981d8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x73cbb(%rip), %r14     # 0x98551
pushq $0x8
popq %rdi
pushq $0xa
popq %rdx
movq %r14, %rsi
callq 0x34f59
movq %rax, %rbx
leaq 0xa8fc2(%rip), %r15     # 0xcd870
movq (%r15), %rax
movslq 0x1bc(%rax), %rax
leaq -0x8(,%rax,8), %rdi
pushq $0xb
popq %rdx
movq %r14, %rsi
callq 0x34f59
movq %rax, (%rbx)
movq (%r15), %rax
xorl %r14d, %r14d
movl $0x30f20, %r12d         # imm = 0x30F20
xorl %r13d, %r13d
movslq 0x1bc(%rax), %rcx
cmpq %rcx, %r14
jge 0x24a20
cmpl $0x1, -0x18(%rax,%r12)
jne 0x2490e
movl (%rax,%r12), %edi
callq 0x35e36
movq (%rbx), %rcx
movslq %r13d, %r13
movq %rax, (%rcx,%r13,8)
incl %r13d
movq (%r15), %rax
incq %r14
addq $0x340, %r12            # imm = 0x340
jmp 0x248dd
leaq 0x73c30(%rip), %r14     # 0x98551
pushq $0x18
popq %rdi
pushq $0x29
popq %rdx
movq %r14, %rsi
callq 0x34f59
movq %rax, %rbx
movl %ebp, 0x8(%rax)
movl %ebp, %edi
callq 0x35e36
movq %rax, 0x10(%rbx)
movslq %ebp, %rdi
shlq $0x3, %rdi
pushq $0x2c
popq %rdx
movq %r14, %rsi
callq 0x34f59
movq %rax, (%rbx)
xorl %r14d, %r14d
xorl %r15d, %r15d
movslq 0x8(%rbx), %rax
cmpq %rax, %r15
jge 0x24a20
movq (%rbx), %rdi
addq %r14, %rdi
callq 0x25f0b
incq %r15
addq $0x8, %r14
jmp 0x2495b
leaq 0x73bce(%rip), %r15     # 0x98551
pushq $0x18
popq %rdi
pushq $0x1a
popq %rdx
movq %r15, %rsi
callq 0x34f59
movq %rax, %rbx
movl %ebp, 0x8(%rax)
movl %ebp, %edi
callq 0x35e36
movq %rax, 0x10(%rbx)
movslq %ebp, %rax
imulq $0x18, %rax, %rdi
pushq $0x1d
popq %rdx
movq %r15, %rsi
callq 0x34f59
movq %rax, (%rbx)
xorl %r15d, %r15d
xorl %r12d, %r12d
movslq 0x8(%rbx), %rax
cmpq %rax, %r12
jge 0x24a20
movq (%rbx), %rdi
addq %r15, %rdi
movq %r14, %rsi
callq 0x25e19
incq %r12
addq $0x18, %r15
jmp 0x249bd
leaq 0x73b6d(%rip), %rsi     # 0x98551
pushq $0x8
popq %rdi
pushq $0x25
popq %rdx
callq 0x34f59
movq %rax, %rbx
movq %rax, %rdi
callq 0x25f0b
jmp 0x24a20
leaq 0x73b4e(%rip), %rsi     # 0x98551
pushq $0x18
popq %rdi
pushq $0x15
popq %rdx
callq 0x34f59
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x25e19
jmp 0x24a20
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq