// File: /workspace/github_c_makefile_star2_O1/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 0x27867
movq %rdx, %r14
movl %esi, %ebp
movl %edi, %eax
leaq 0x7dba2(%rip), %rcx     # 0xa5200
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x7df0b(%rip), %r14     # 0xa5579
movl $0x8, %edi
movq %r14, %rsi
movl $0xa, %edx
callq 0x390f5
movq %rax, %rbx
leaq 0xab1e6(%rip), %r15     # 0xd2870
movq (%r15), %rax
movslq 0x1bc(%rax), %rax
leaq -0x8(,%rax,8), %rdi
movq %r14, %rsi
movl $0xb, %edx
callq 0x390f5
movq %rax, (%rbx)
movq (%r15), %rax
cmpl $0x0, 0x1bc(%rax)
jle 0x27869
xorl %r14d, %r14d
movl $0x30f20, %r12d         # imm = 0x30F20
xorl %r13d, %r13d
cmpl $0x1, -0x18(%rax,%r12)
jne 0x276e6
movl (%rax,%r12), %edi
callq 0x3a1d2
movq (%rbx), %rcx
movslq %r13d, %r13
movq %rax, (%rcx,%r13,8)
incl %r13d
incq %r14
movq (%r15), %rax
movslq 0x1bc(%rax), %rcx
addq $0x340, %r12            # imm = 0x340
cmpq %rcx, %r14
jl 0x276c8
jmp 0x27869
leaq 0x7de6e(%rip), %r14     # 0xa5579
movl $0x18, %edi
movq %r14, %rsi
movl $0x29, %edx
callq 0x390f5
movq %rax, %rbx
movl %ebp, 0x8(%rax)
movl %ebp, %edi
callq 0x3a1d2
movq %rax, 0x10(%rbx)
movslq %ebp, %rdi
shlq $0x3, %rdi
movq %r14, %rsi
movl $0x2c, %edx
callq 0x390f5
movq %rax, (%rbx)
cmpl $0x0, 0x8(%rbx)
jle 0x27869
xorl %r14d, %r14d
leaq 0xab117(%rip), %r15     # 0xd2870
movq (%rbx), %r12
movq (%r15), %rax
movl 0x1c0(%rax), %edi
decl %edi
xorps %xmm0, %xmm0
movsd 0x7adae(%rip), %xmm1    # 0xa2520
callq 0x3a083
movq %rax, (%r12,%r14,8)
incq %r14
movslq 0x8(%rbx), %rax
cmpq %rax, %r14
jl 0x27759
jmp 0x27869
leaq 0x7dde6(%rip), %r15     # 0xa5579
movl $0x18, %edi
movq %r15, %rsi
movl $0x1a, %edx
callq 0x390f5
movq %rax, %rbx
movl %ebp, 0x8(%rax)
movl %ebp, %edi
callq 0x3a1d2
movq %rax, 0x10(%rbx)
movslq %ebp, %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdi
movq %r15, %rsi
movl $0x1d, %edx
callq 0x390f5
movq %rax, (%rbx)
cmpl $0x0, 0x8(%rbx)
jle 0x27869
xorl %r15d, %r15d
xorl %r12d, %r12d
movq (%rbx), %rdi
addq %r15, %rdi
movq %r14, %rsi
callq 0x28edb
incq %r12
movslq 0x8(%rbx), %rax
addq $0x18, %r15
cmpq %rax, %r12
jl 0x277e1
jmp 0x27869
leaq 0x7dd71(%rip), %rsi     # 0xa5579
movl $0x8, %edi
movl $0x25, %edx
callq 0x390f5
movq %rax, %rbx
leaq 0xab04f(%rip), %rax     # 0xd2870
movq (%rax), %rax
movl 0x1c0(%rax), %edi
decl %edi
movsd 0x7acec(%rip), %xmm1    # 0xa2520
xorps %xmm0, %xmm0
callq 0x3a083
movq %rax, (%rbx)
jmp 0x27869
leaq 0x7dd31(%rip), %rsi     # 0xa5579
movl $0x18, %edi
movl $0x15, %edx
callq 0x390f5
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x28edb
jmp 0x27869
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq