// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0xc(%rbp)
movl %esi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0x50(%rbp)
subq $0x4, %rax
ja 0x386b7
movq -0x50(%rbp), %rax
leaq 0xac992(%rip), %rcx     # 0xe4da0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x8, %edi
leaq 0xacd4e(%rip), %rsi     # 0xe5171
movl $0xa, %edx
callq 0x52d70
movq %rax, -0x30(%rbp)
leaq 0xcd408(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x1bc(%rax), %eax
subl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
leaq 0xacd1f(%rip), %rsi     # 0xe5171
movl $0xb, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
leaq 0xcd3c2(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x384fd
leaq 0xcd3b0(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x44(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x1, (%rax)
jne 0x384ed
leaq 0xcd38d(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x44(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movl 0x18(%rax), %edi
callq 0x54790
movq %rax, %rdx
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x48(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x384ef
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x38474
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x386bf
movl $0x18, %edi
leaq 0xacc5b(%rip), %rsi     # 0xe5171
movl $0x15, %edx
callq 0x52d70
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3a980
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x386bf
movl $0x18, %edi
leaq 0xacc27(%rip), %rsi     # 0xe5171
movl $0x1a, %edx
callq 0x52d70
movq %rax, -0x28(%rbp)
movl -0x10(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x54790
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movslq -0x10(%rbp), %rax
imulq $0x18, %rax, %rdi
leaq 0xacbe9(%rip), %rsi     # 0xe5171
movl $0x1d, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x385d5
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movslq -0x44(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x3a980
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x385a3
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x386bf
movl $0x8, %edi
leaq 0xacb83(%rip), %rsi     # 0xe5171
movl $0x25, %edx
callq 0x52d70
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3aae0
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x386bf
movl $0x18, %edi
leaq 0xacb4f(%rip), %rsi     # 0xe5171
movl $0x29, %edx
callq 0x52d70
movq %rax, -0x40(%rbp)
movl -0x10(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x40(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x54790
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movslq -0x10(%rbp), %rdi
shlq $0x3, %rdi
leaq 0xacb11(%rip), %rsi     # 0xe5171
movl $0x2c, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x386ad
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movslq -0x44(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x3aae0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x3867b
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x386bf
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)