// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/hmm.c
// Function: copy_state_model
void copy_state_model(void *destmodel, void* srcmodel, 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) destmodel;
                                m1 = (Multinomialptr) srcmodel;
                                j = 0;
                                for (i = 0; i < current_dataset->featurecount; i++)
                                  if (current_dataset->features[i].type == STRING)
                                   {
                                    memcpy(m->prob[j], m1->prob[j], current_dataset->features[i].valuecount * sizeof(double));
                                    j++;
                                   }
                                break;
   case          STATE_GAUSSIAN:g = (Gaussianptr) destmodel;
                                g1 = (Gaussianptr) srcmodel;
                                memcpy(g->mean, g1->mean, numrealfeatures * sizeof(double));
                                matrix_identical(&(g->covariance), g1->covariance);
                                break;
   case  STATE_GAUSSIAN_MIXTURE:gm = (Gaussianmixtureptr) destmodel;
                                gm1 = (Gaussianmixtureptr) srcmodel;
                                memcpy(gm->weights, gm1->weights, gm->componentcount * sizeof(double));
                                for (i = 0; i < gm->componentcount; i++)
                                 {
                                  memcpy(gm->components[i].mean, gm1->components[i].mean, numrealfeatures * sizeof(double));
                                  matrix_identical(&(gm->components[i].covariance), gm1->components[i].covariance);
                                 }
                                break;
   case         STATE_DIRICHLET:d = (Dirichletptr) destmodel;
                                d1 = (Dirichletptr) srcmodel;
                                memcpy(d->alpha, d1->alpha, numrealfeatures * sizeof(double));
                                break;
   case STATE_DIRICHLET_MIXTURE:dm = (Dirichletmixtureptr) destmodel;
                                dm1 = (Dirichletmixtureptr) srcmodel;
                                memcpy(dm->weights, dm1->weights, dm->componentcount * sizeof(double));
                                for (i = 0; i < dm->componentcount; i++)
                                  memcpy(dm->components[i].alpha, dm1->components[i].alpha, numrealfeatures * sizeof(double));
                                break;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x4, %edx
ja 0x28e01
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xacba7(%rip), %r12     # 0xd5870
movq (%r12), %rax
movslq 0x1c0(%rax), %r15
decq %r15
movl %edx, %ecx
leaq 0x7f5f0(%rip), %rdx     # 0xa82d0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x0, 0x1bc(%rax)
jle 0x28e01
xorl %r15d, %r15d
movl $0x30f20, %r13d         # imm = 0x30F20
xorl %ebp, %ebp
cmpl $0x1, -0x18(%rax,%r13)
jne 0x28d2d
movq (%r14), %rcx
movslq %ebp, %rbp
movq (%rcx,%rbp,8), %rdi
movq (%rbx), %rcx
movq (%rcx,%rbp,8), %rsi
movslq (%rax,%r13), %rdx
shlq $0x3, %rdx
callq 0x4310
incl %ebp
movq (%r12), %rax
incq %r15
movslq 0x1bc(%rax), %rcx
addq $0x340, %r13            # imm = 0x340
cmpq %rcx, %r15
jl 0x28d01
jmp 0x28e01
movq 0x10(%r14), %rdi
movq 0x10(%rbx), %rsi
movslq 0x8(%r14), %rdx
shlq $0x3, %rdx
callq 0x4310
cmpl $0x0, 0x8(%r14)
jle 0x28e01
movslq %r15d, %r15
shlq $0x3, %r15
xorl %r12d, %r12d
movq (%r14), %rax
movq (%rax,%r12,8), %rdi
movq (%rbx), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdx
callq 0x4310
incq %r12
movslq 0x8(%r14), %rax
cmpq %rax, %r12
jl 0x28d72
jmp 0x28e01
movq 0x10(%r14), %rdi
movq 0x10(%rbx), %rsi
movslq 0x8(%r14), %rdx
shlq $0x3, %rdx
callq 0x4310
cmpl $0x0, 0x8(%r14)
jle 0x28e01
movslq %r15d, %r15
shlq $0x3, %r15
movl $0x8, %r12d
xorl %r13d, %r13d
movq (%r14), %rax
movq -0x8(%rax,%r12), %rdi
movq (%rbx), %rax
movq -0x8(%rax,%r12), %rsi
movq %r15, %rdx
callq 0x4310
movq (%r14), %rdi
addq %r12, %rdi
movq (%rbx), %rax
movq (%rax,%r12), %rsi
movq 0x8(%rax,%r12), %rdx
callq 0x406d5
incq %r13
movslq 0x8(%r14), %rax
addq $0x18, %r12
cmpq %rax, %r13
jl 0x28dc2
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
movq (%rbx), %rsi
movslq %r15d, %rdx
shlq $0x3, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4310
movq (%r14), %rdi
movq (%rbx), %rsi
shlq $0x3, %r15
movq %r15, %rdx
callq 0x4310
addq $0x8, %r14
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x406d5