// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/hmm.c
// Function: random_hmm
Hmmptr random_hmm(int statecount, HMM_STATE_TYPE statetype, int componentcount, HMM_MODEL_TYPE hmmtype, Instanceptr traindata)
{
 /*!Last Changed 27.03.2007*/
 int i, j;
 Hmmptr result;
 double* myarray, randvalue;
 result = empty_hmm(statecount, statetype, hmmtype);
 myarray = random_normalized_array(statecount);
 for (i = 0; i < statecount; i++)
  {
   result->states[i].pi = myarray[i];
   result->states[i].a_dot_j = safemalloc(sizeof(double) * statecount, "random_hmm", 9);
   switch (hmmtype)
    {
     case    FULL_MODEL:result->states[i].a_i_dot = random_normalized_array(statecount);
                        break;
     case      LR_MODEL:result->states[i].a_i_dot = safecalloc(statecount, sizeof(double), "random_hmm", 14);
                        randvalue = produce_random_value(0.0, 1.0);
                        if (i != statecount - 1)
                         {
                          result->states[i].a_i_dot[i] = randvalue;
                          result->states[i].a_i_dot[i + 1] = 1 - randvalue;
                         } 
                        else
                          result->states[i].a_i_dot[i] = 1.0;
                        break;
     case LR_LOOP_MODEL:result->states[i].a_i_dot = safecalloc(statecount, sizeof(double), "random_hmm", 24);
                        randvalue = produce_random_value(0.0, 1.0);
                        if (i != statecount - 1)
                         {
                          result->states[i].a_i_dot[i] = randvalue;
                          result->states[i].a_i_dot[i + 1] = 1 - randvalue;
                         } 
                        else
                         {
                          result->states[i].a_i_dot[statecount - 1] = randvalue;
                          result->states[i].a_i_dot[0] = 1 - randvalue;
                         }
                        break;
    }
   result->states[i].b = random_state_model(statetype, componentcount, traindata);
  } 
 for (i = 0; i < statecount; i++)
   for (j = 0; j < statecount; j++)
     result->states[j].a_dot_j[i] = result->states[i].a_i_dot[j];
 safe_free(myarray);
 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movq %r8, -0x18(%rbp)
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movl -0x10(%rbp), %edx
callq 0x37fe0
movq %rax, -0x28(%rbp)
movl -0x4(%rbp), %edi
callq 0x54790
movq %rax, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x3834f
movq -0x30(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movq (%rax), %rax
shlq $0x5, %rcx
movsd %xmm0, 0x10(%rax,%rcx)
movslq -0x4(%rbp), %rdi
shlq $0x3, %rdi
leaq 0xacdc4(%rip), %rsi     # 0xe4e9a
movl $0x9, %edx
callq 0x52d70
movq %rax, %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
movq %rdx, (%rax,%rcx)
movl -0x10(%rbp), %eax
movl %eax, -0x3c(%rbp)
testl %eax, %eax
je 0x3811d
jmp 0x38102
movl -0x3c(%rbp), %eax
subl $0x1, %eax
je 0x38143
jmp 0x3810c
movl -0x3c(%rbp), %eax
subl $0x2, %eax
je 0x3821b
jmp 0x38319
movl -0x4(%rbp), %edi
callq 0x54790
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x38319
movslq -0x4(%rbp), %rdi
movl $0x8, %esi
leaq 0xacd47(%rip), %rdx     # 0xe4e9a
movl $0xe, %ecx
callq 0x52f40
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
xorps %xmm0, %xmm0
movsd 0xa9e97(%rip), %xmm1    # 0xe2018
callq 0x545a0
movsd %xmm0, -0x38(%rbp)
movl -0x1c(%rbp), %eax
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x381ef
movsd -0x38(%rbp), %xmm0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0xa9e54(%rip), %xmm0    # 0xe2018
subsd -0x38(%rbp), %xmm0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x38216
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
movsd 0xa9e07(%rip), %xmm0    # 0xe2018
movsd %xmm0, (%rax,%rcx,8)
jmp 0x38319
movslq -0x4(%rbp), %rdi
movl $0x8, %esi
leaq 0xacc6f(%rip), %rdx     # 0xe4e9a
movl $0x18, %ecx
callq 0x52f40
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
xorps %xmm0, %xmm0
movsd 0xa9dbf(%rip), %xmm1    # 0xe2018
callq 0x545a0
movsd %xmm0, -0x38(%rbp)
movl -0x1c(%rbp), %eax
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x382c7
movsd -0x38(%rbp), %xmm0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0xa9d7c(%rip), %xmm0    # 0xe2018
subsd -0x38(%rbp), %xmm0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x38317
movsd -0x38(%rbp), %xmm0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0xa9d20(%rip), %xmm0    # 0xe2018
subsd -0x38(%rbp), %xmm0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movsd %xmm0, (%rax)
jmp 0x38319
movl -0x8(%rbp), %edi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
callq 0x383e0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3809d
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x383c2
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x383b5
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x20(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x38365
jmp 0x383b7
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x38356
movq -0x30(%rbp), %rdi
callq 0x52e80
movq -0x28(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)