// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/hmm.c
// Function: generate_gaussian_mixture_data
void generate_gaussian_mixture_data(Gaussianmixtureptr gm, int* classes, int datacount, char* outfilename)
{
 /*!Last Changed 28.04.2007*/
 FILE* outfile;
 char pst[READLINELENGTH];
 int i, dimension, j, componentindex;
 matrix a, z, result;
 double value;
 set_precision(pst, NULL, " "); 
 dimension = gm->components[0].covariance.row;
 outfile = fopen(outfilename, "w");
 a = matrix_alloc(1, dimension);
 for (i = 0; i < datacount; i++)
  {
   for (j = 0; j < dimension; j++)
     a.values[0][j] = produce_normal_value(0.0, 1.0);
   value = produce_random_value(0, 1);
   componentindex = find_bin(gm->weights, gm->componentcount, value);
   cholesky_decomposition(gm->components[componentindex].covariance, &z);
   result = matrix_multiply(a, z);
   for (j = 0; j < dimension; j++)
     fprintf(outfile, pst, result.values[0][j] + gm->components[componentindex].mean[j]);
   if (gm->componentcount > 1)
     fprintf(outfile, "%d\n", classes[componentindex]);
   else 
     fprintf(outfile, "\n");
   matrix_free(z);
   matrix_free(result);
  }
 matrix_free(a);
 fclose(outfile);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a188, %rsp          # imm = 0x7A188
movq %rcx, %rbx
movl %edx, %ebp
movq %rsi, 0x50(%rsp)
movq %rdi, %r15
leaq 0x7e5e3(%rip), %rdx     # 0xa86e5
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
callq 0x3a535
movq (%r15), %rax
movl 0x8(%rax), %r12d
leaq 0x81851(%rip), %rsi     # 0xab96d
movq %rbx, %rdi
callq 0x40f0
movq %rax, %rbx
movl $0x1, %edi
movl %r12d, %esi
callq 0x3d79d
movq %rax, 0x28(%rsp)
movq %rdx, %r14
movl %ebp, 0x1c(%rsp)
testl %ebp, %ebp
jle 0x2a2b4
movsd 0x7b3d0(%rip), %xmm1    # 0xa5520
xorl %ebp, %ebp
movq %rbx, 0x10(%rsp)
movq %r14, 0x20(%rsp)
movl %ebp, 0xc(%rsp)
testl %r12d, %r12d
jle 0x2a190
xorl %ebx, %ebx
xorpd %xmm0, %xmm0
movsd 0x7b3ad(%rip), %xmm1    # 0xa5520
callq 0x8f4b0
movsd 0x7b3a0(%rip), %xmm1    # 0xa5520
movq (%r14), %rax
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
cmpq %rbx, %r12
jne 0x2a167
xorpd %xmm0, %xmm0
callq 0x3af6a
movq 0x10(%r15), %rdi
movl 0x8(%r15), %esi
callq 0x37fdb
movq (%r15), %rcx
cltq
movq %rax, 0x58(%rsp)
leaq (%rax,%rax,2), %rbx
movq 0x8(%rcx,%rbx,8), %rdi
movq 0x10(%rcx,%rbx,8), %rsi
leaq 0x40(%rsp), %rdx
callq 0x3d7d7
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rcx
movq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x3ee2f
movq %rax, 0x30(%rsp)
testl %r12d, %r12d
movq 0x10(%rsp), %r14
movq %r15, %r13
leaq 0x60(%rsp), %r15
movq %r12, %rbp
movq %rdx, 0x38(%rsp)
jle 0x2a232
xorl %r12d, %r12d
movq (%rdx), %rax
movsd (%rax,%r12,8), %xmm0
movq (%r13), %rax
movq (%rax,%rbx,8), %rax
addsd (%rax,%r12,8), %xmm0
movq %r14, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0x42e0
movq 0x38(%rsp), %rdx
incq %r12
cmpq %r12, %rbp
jne 0x2a201
cmpl $0x2, 0x8(%r13)
movq %r13, %r15
jl 0x2a261
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0x86389(%rip), %rsi     # 0xb05e1
xorl %eax, %eax
callq 0x42e0
jmp 0x2a273
movl $0xa, %edi
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
callq 0x4150
movq 0x20(%rsp), %r14
movq %rbp, %r12
movl 0xc(%rsp), %ebp
movq 0x30(%rsp), %r13
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x3ed51
movq %r13, %rdi
movq 0x38(%rsp), %rsi
callq 0x3ed51
incl %ebp
cmpl 0x1c(%rsp), %ebp
movsd 0x7b272(%rip), %xmm1    # 0xa5520
jne 0x2a15c
movq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x3ed51
movq %rbx, %rdi
callq 0x42a0
addq $0x7a188, %rsp          # imm = 0x7A188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq