// File: /workspace/github_c_makefile_star2_O3/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 0x27f76
movq %rdx, %r14
movl %esi, %ebp
movl %edi, %eax
leaq 0x804eb(%rip), %rcx     # 0xa8258
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x80854(%rip), %r14     # 0xa85d1
movl $0x8, %edi
movq %r14, %rsi
movl $0xa, %edx
callq 0x3a0e1
movq %rax, %rbx
leaq 0xadad7(%rip), %r15     # 0xd5870
movq (%r15), %rax
movslq 0x1bc(%rax), %rax
leaq -0x8(,%rax,8), %rdi
movq %r14, %rsi
movl $0xb, %edx
callq 0x3a0e1
movq %rax, (%rbx)
movq (%r15), %rax
cmpl $0x0, 0x1bc(%rax)
jle 0x27f78
xorl %r14d, %r14d
movl $0x30f20, %r12d         # imm = 0x30F20
xorl %r13d, %r13d
cmpl $0x1, -0x18(%rax,%r12)
jne 0x27df8
movl (%rax,%r12), %edi
callq 0x3b25f
movq (%rbx), %rcx
movslq %r13d, %r13
movq %rax, (%rcx,%r13,8)
incl %r13d
movq (%r15), %rax
incq %r14
movslq 0x1bc(%rax), %rcx
addq $0x340, %r12            # imm = 0x340
cmpq %rcx, %r14
jl 0x27dd7
jmp 0x27f78
leaq 0x807b7(%rip), %r14     # 0xa85d1
movl $0x18, %edi
movq %r14, %rsi
movl $0x29, %edx
callq 0x3a0e1
movq %rax, %rbx
movl %ebp, 0x8(%rax)
movl %ebp, %edi
callq 0x3b25f
movq %rax, 0x10(%rbx)
movslq %ebp, %rdi
shlq $0x3, %rdi
movq %r14, %rsi
movl $0x2c, %edx
callq 0x3a0e1
movq %rax, (%rbx)
cmpl $0x0, 0x8(%rbx)
jle 0x27f78
xorl %r14d, %r14d
leaq 0xada08(%rip), %r15     # 0xd5870
movq (%rbx), %r12
movq (%r15), %rax
movl 0x1c0(%rax), %edi
decl %edi
xorps %xmm0, %xmm0
movsd 0x7d69f(%rip), %xmm1    # 0xa5520
callq 0x3b110
movq %rax, (%r12,%r14,8)
incq %r14
movslq 0x8(%rbx), %rax
cmpq %rax, %r14
jl 0x27e68
jmp 0x27f78
leaq 0x8072f(%rip), %r15     # 0xa85d1
movl $0x18, %edi
movq %r15, %rsi
movl $0x1a, %edx
callq 0x3a0e1
movq %rax, %rbx
movl %ebp, 0x8(%rax)
movl %ebp, %edi
callq 0x3b25f
movq %rax, 0x10(%rbx)
movslq %ebp, %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdi
movq %r15, %rsi
movl $0x1d, %edx
callq 0x3a0e1
movq %rax, (%rbx)
cmpl $0x0, 0x8(%rbx)
jle 0x27f78
xorl %r15d, %r15d
xorl %r12d, %r12d
movq (%rbx), %rdi
addq %r15, %rdi
movq %r14, %rsi
callq 0x2966f
incq %r12
movslq 0x8(%rbx), %rax
addq $0x18, %r15
cmpq %rax, %r12
jl 0x27ef0
jmp 0x27f78
leaq 0x806ba(%rip), %rsi     # 0xa85d1
movl $0x8, %edi
movl $0x25, %edx
callq 0x3a0e1
movq %rax, %rbx
leaq 0xad940(%rip), %rax     # 0xd5870
movq (%rax), %rax
movl 0x1c0(%rax), %edi
decl %edi
movsd 0x7d5dd(%rip), %xmm1    # 0xa5520
xorps %xmm0, %xmm0
callq 0x3b110
movq %rax, (%rbx)
jmp 0x27f78
leaq 0x8067a(%rip), %rsi     # 0xa85d1
movl $0x18, %edi
movl $0x15, %edx
callq 0x3a0e1
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2966f
jmp 0x27f78
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq