// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/hmm.c
// Function: clone_state_model
void* clone_state_model(void* model, HMM_STATE_TYPE statetype)
{
 /*!Last Changed 15.03.2007*/
 Gaussianptr g, g1;
 Gaussianmixtureptr gm, gm1;
 Multinomialptr m, m1;
 Dirichletptr d, d1;
 Dirichletmixtureptr dm, dm1;
 int i, j;
 int numrealfeatures = current_dataset->multifeaturecount - 1;
 switch (statetype)
  {
   case          STATE_DISCRETE:m = (Multinomialptr) model;
                                m1 = safemalloc(sizeof(Multinomial), "clone_state_model", 11);
                                m1->prob = safemalloc(sizeof(double*) * (current_dataset->featurecount - 1), "clone_state_model", 11);
                                j = 0;
                                for (i = 0; i < current_dataset->featurecount; i++)
                                  if (current_dataset->features[i].type == STRING)
                                   {
                                    m1->prob[j] = clone_array(m->prob[j],  current_dataset->features[i].valuecount);
                                    j++;
                                   }
                                return m1;
                                break;
   case          STATE_GAUSSIAN:g = (Gaussianptr) model;
                                g1 = safemalloc(sizeof(Gaussian), "clone_state_model", 23);
                                g1->mean = clone_array(g->mean, numrealfeatures);
                                g1->covariance = matrix_copy(g->covariance);
                                return g1;
                                break;
   case  STATE_GAUSSIAN_MIXTURE:gm = (Gaussianmixtureptr) model;
                                gm1 = safemalloc(sizeof(Gaussianmixture), "clone_state_model", 29);
                                gm1->componentcount = gm->componentcount;
                                gm1->weights = clone_array(gm->weights, gm->componentcount);
                                gm1->components = safemalloc(gm->componentcount * sizeof(Gaussian), "clone_state_model", 32);
                                for (i = 0; i < gm->componentcount; i++)
                                 {
                                  gm1->components[i].mean = clone_array(gm->components[i].mean, numrealfeatures);
                                  gm1->components[i].covariance = matrix_copy(gm->components[i].covariance);
                                 }
                                return gm1;
                                break;
   case         STATE_DIRICHLET:d = (Dirichletptr) model;
                                d1 = safemalloc(sizeof(Dirichlet), "clone_state_model", 40);
                                d1->alpha = clone_array(d->alpha, numrealfeatures);
                                return d1;
                                break;
   case STATE_DIRICHLET_MIXTURE:dm = (Dirichletmixtureptr) model;
                                dm1 = safemalloc(sizeof(Dirichletmixture), "clone_state_model", 45);
                                dm1->componentcount = dm->componentcount;
                                dm1->weights = clone_array(dm->weights, dm->componentcount);
                                dm1->components = safemalloc(dm->componentcount * sizeof(Dirichlet), "clone_state_model", 48);
                                for (i = 0; i < dm->componentcount; i++)
                                  dm1->components[i].alpha = clone_array(dm->components[i].alpha, numrealfeatures);
                                return dm1;
                                break;
      default                  :return NULL;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x4, %esi
ja 0x28338
movq %rdi, %rbx
leaq 0xaa77a(%rip), %r12     # 0xd2870
movq (%r12), %rax
movl 0x1c0(%rax), %ebp
decl %ebp
movl %esi, %eax
leaq 0x7d145(%rip), %rcx     # 0xa5250
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x7d484(%rip), %r15     # 0xa559f
movl $0x8, %edi
movq %r15, %rsi
movl $0xb, %edx
callq 0x390f5
movq %rax, %r14
movq (%r12), %rax
movslq 0x1bc(%rax), %rax
leaq -0x8(,%rax,8), %rdi
movq %r15, %rsi
movl $0xb, %edx
callq 0x390f5
movq %rax, (%r14)
movq (%r12), %rax
cmpl $0x0, 0x1bc(%rax)
jle 0x2833b
xorl %r15d, %r15d
movl $0x30f20, %r13d         # imm = 0x30F20
xorl %ebp, %ebp
cmpl $0x1, -0x18(%rax,%r13)
jne 0x28193
movq (%rbx), %rcx
movslq %ebp, %rbp
movq (%rcx,%rbp,8), %rdi
movl (%rax,%r13), %esi
callq 0x37088
movq (%r14), %rcx
movq %rax, (%rcx,%rbp,8)
incl %ebp
incq %r15
movq (%r12), %rax
movslq 0x1bc(%rax), %rcx
addq $0x340, %r13            # imm = 0x340
cmpq %rcx, %r15
jl 0x2816f
jmp 0x2833b
leaq 0x7d3e6(%rip), %r15     # 0xa559f
movl $0x18, %edi
movq %r15, %rsi
movl $0x2d, %edx
callq 0x390f5
movq %rax, %r14
movl 0x8(%rbx), %eax
movl %eax, 0x8(%r14)
movq 0x10(%rbx), %rdi
movl 0x8(%rbx), %esi
callq 0x37088
movq %rax, 0x10(%r14)
movslq 0x8(%rbx), %rdi
shlq $0x3, %rdi
movq %r15, %rsi
movl $0x30, %edx
callq 0x390f5
movq %rax, (%r14)
cmpl $0x0, 0x8(%rbx)
jle 0x2833b
xorl %r15d, %r15d
movq (%rbx), %rax
movq (%rax,%r15,8), %rdi
movl %ebp, %esi
callq 0x37088
movq (%r14), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
movslq 0x8(%rbx), %rax
cmpq %rax, %r15
jl 0x2820a
jmp 0x2833b
leaq 0x7d368(%rip), %r15     # 0xa559f
movl $0x18, %edi
movq %r15, %rsi
movl $0x1d, %edx
callq 0x390f5
movq %rax, %r14
movl 0x8(%rbx), %eax
movl %eax, 0x8(%r14)
movq 0x10(%rbx), %rdi
movl 0x8(%rbx), %esi
callq 0x37088
movq %rax, 0x10(%r14)
movslq 0x8(%rbx), %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdi
movq %r15, %rsi
movl $0x20, %edx
callq 0x390f5
movq %rax, (%r14)
cmpl $0x0, 0x8(%rbx)
jle 0x2833b
xorl %r15d, %r15d
xorl %r12d, %r12d
movq (%rbx), %rax
movq (%rax,%r15), %rdi
movl %ebp, %esi
callq 0x37088
movq (%r14), %r13
movq %rax, (%r13,%r15)
movq (%rbx), %rax
movq 0x8(%rax,%r15), %rdi
movq 0x10(%rax,%r15), %rsi
callq 0x3ca3c
movq %rax, 0x8(%r13,%r15)
movq %rdx, 0x10(%r13,%r15)
incq %r12
movslq 0x8(%rbx), %rax
addq $0x18, %r15
cmpq %rax, %r12
jl 0x2828f
jmp 0x2833b
leaq 0x7d2c5(%rip), %rsi     # 0xa559f
movl $0x8, %edi
movl $0x28, %edx
callq 0x390f5
movq %rax, %r14
movq (%rbx), %rdi
movl %ebp, %esi
callq 0x37088
movq %rax, (%r14)
jmp 0x2833b
leaq 0x7d29d(%rip), %rsi     # 0xa559f
movl $0x18, %edi
movl $0x17, %edx
callq 0x390f5
movq %rax, %r14
movq (%rbx), %rdi
movl %ebp, %esi
callq 0x37088
movq %rax, (%r14)
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
callq 0x3ca3c
movq %rax, 0x8(%r14)
movq %rdx, 0x10(%r14)
jmp 0x2833b
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq