// File: /workspace/github_c_makefile_star2_O2/zpole[P]IICV/src/test_gmm.c
// Function: saveResults
void saveResults(const char * dataFileData, const char * dataFileResults, VlGMM * gmm, void * data, vl_size numData)
{
  char *mode = "w";
  FILE * ofp;

  vl_size d, cIdx;
  vl_uindex i_d;

  vl_size dimension = vl_gmm_get_dimension(gmm) ;
  vl_size numClusters = vl_gmm_get_num_clusters(gmm) ;
  vl_type dataType = vl_gmm_get_data_type(gmm) ;
  double const * sigmas = vl_gmm_get_covariances(gmm) ;
  double const * means = vl_gmm_get_means(gmm) ;
  double const * weights = vl_gmm_get_priors(gmm) ;
  double const * posteriors = vl_gmm_get_posteriors(gmm) ;

  ofp = fopen(dataFileData, mode);
  for(i_d = 0; i_d < numData; i_d++) {
    if(vl_gmm_get_data_type(gmm) == VL_TYPE_DOUBLE) {
      for(d = 0; d < vl_gmm_get_dimension(gmm) ; d++) {
        fprintf(ofp, "%f ", ((double*)data)[i_d * vl_gmm_get_dimension(gmm) + d]);
      }
    } else {
      for(d = 0; d < vl_gmm_get_dimension(gmm); d++) {
        fprintf(ofp, "%f ", ((float*) data)[i_d * vl_gmm_get_dimension(gmm) + d]);
      }
    }
    fprintf(ofp, "\n");
  }
  fclose (ofp);

  ofp = fopen(dataFileResults, mode);
  for(cIdx = 0; cIdx < numClusters; cIdx++) {
    if(dataType == VL_TYPE_DOUBLE) {
      for(d = 0; d < vl_gmm_get_dimension(gmm); d++) {
        fprintf(ofp, "%f ", ((double*)means)[cIdx*dimension+d]);
      }
      for(d = 0; d < dimension; d++) {
        fprintf(ofp, "%f ", ((double*)sigmas)[cIdx*dimension+d]);
      }
      fprintf(ofp, "%f ", ((double*)weights)[cIdx]);
      for(i_d = 0; i_d < numData; i_d++) {
        fprintf(ofp, "%f ", ((double*)posteriors)[cIdx*numData + i_d]);
      }
      fprintf(ofp, "\n");
    } else {
      for(d = 0; d < dimension; d++) {
        fprintf(ofp, "%f ", ((float*)means)[cIdx*dimension+d]);
      }
      for(d = 0; d < dimension; d++) {
        fprintf(ofp, "%f ", ((float*)sigmas)[cIdx*dimension+d]);
      }
      fprintf(ofp, "%f ", ((float*)weights)[cIdx]);
      for(i_d = 0; i_d < numData; i_d++) {
        fprintf(ofp, "%f ", ((float*)posteriors)[cIdx*numData + i_d]);

      }
      fprintf(ofp, "\n");
    }
  }
  fclose (ofp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r8, %r15
movq %rcx, %rbp
movq %rdx, %r14
movq %rsi, 0x8(%rsp)
movq %rdi, %r12
movq %rdx, %rdi
callq 0x1040
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq 0x1030
movq %rax, 0x70(%rsp)
movq %r14, %rdi
callq 0x11b0
movl %eax, 0x3c(%rsp)
movq %r14, %rdi
callq 0x1150
movq %rax, 0x30(%rsp)
movq %r14, %rdi
callq 0x1170
movq %rax, 0x28(%rsp)
movq %r14, %rdi
callq 0x1190
movq %rax, 0x40(%rsp)
movq %r14, %rdi
callq 0x10b0
movq %rax, 0x20(%rsp)
leaq 0xa36(%rip), %rsi       # 0x2020
movq %r12, %rdi
callq 0x11a0
movq %rax, %r13
xorl %ebx, %ebx
xorl %r12d, %r12d
xorl %eax, %eax
movq %r15, 0x68(%rsp)
cmpq %r15, %rax
je 0x16b0
movq %rax, (%rsp)
movq %r14, %rdi
callq 0x11b0
xorl %r15d, %r15d
cmpl $0x2, %eax
je 0x167f
movq %r14, %rdi
callq 0x1040
cmpq %rax, %r15
jae 0x168c
movq %r14, %rdi
callq 0x1040
imulq %r12, %rax
addq %rbp, %rax
cvtss2sd (%rax,%r15,4), %xmm0
movq %r13, %rdi
leaq 0x9d8(%rip), %rsi       # 0x2022
movb $0x1, %al
callq 0x10f0
incq %r15
jmp 0x161e
movq %r14, %rdi
callq 0x1040
imulq %rbx, %rax
addq %rbp, %rax
movsd (%rax,%r15,8), %xmm0
movq %r13, %rdi
leaq 0x9ad(%rip), %rsi       # 0x2022
movb $0x1, %al
callq 0x10f0
incq %r15
movq %r14, %rdi
callq 0x1040
cmpq %rax, %r15
jb 0x1656
pushq $0xa
popq %rdi
movq %r13, %rsi
callq 0x10d0
movq (%rsp), %rax
incq %rax
addq $0x4, %r12
addq $0x8, %rbx
movq 0x68(%rsp), %r15
jmp 0x1601
movq %r13, %rdi
callq 0x1070
leaq 0x961(%rip), %rsi       # 0x2020
movq 0x8(%rsp), %rdi
callq 0x11a0
movq %rax, %r13
movq 0x10(%rsp), %rax
leaq (,%rax,4), %rcx
movq %rcx, 0x60(%rsp)
leaq (,%r15,4), %rcx
movq %rcx, 0x58(%rsp)
leaq (,%rax,8), %rax
movq %rax, 0x50(%rsp)
leaq (,%r15,8), %rax
movq %rax, 0x48(%rsp)
xorl %ecx, %ecx
leaq 0x914(%rip), %rbp       # 0x2022
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %r12
cmpq 0x70(%rsp), %rcx
je 0x18a3
movq %rcx, 0x18(%rsp)
cmpl $0x2, 0x3c(%rsp)
jne 0x17d4
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x1040
cmpq %rax, %rbx
jae 0x176c
movq 0x28(%rsp), %rax
movsd (%rax,%rbx,8), %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x10f0
incq %rbx
jmp 0x1743
xorl %ebx, %ebx
cmpq %rbx, 0x10(%rsp)
je 0x1791
movq 0x30(%rsp), %rax
movsd (%rax,%rbx,8), %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x10f0
incq %rbx
jmp 0x176e
movq 0x40(%rsp), %rax
movq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x10f0
xorl %ebx, %ebx
cmpq %rbx, %r15
je 0x1858
movq 0x20(%rsp), %rax
movsd (%rax,%rbx,8), %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x10f0
incq %rbx
jmp 0x17af
xorl %ebx, %ebx
cmpq %rbx, 0x10(%rsp)
je 0x17f5
cvtss2sd (%r12,%rbx,4), %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x10f0
incq %rbx
jmp 0x17d6
xorl %ebx, %ebx
cmpq %rbx, 0x10(%rsp)
je 0x181a
movq 0x8(%rsp), %rax
cvtss2sd (%rax,%rbx,4), %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x10f0
incq %rbx
jmp 0x17f7
movq 0x40(%rsp), %rax
movq 0x18(%rsp), %rcx
cvtss2sd (%rax,%rcx,4), %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x10f0
xorl %ebx, %ebx
cmpq %rbx, %r15
je 0x1858
movq (%rsp), %rax
cvtss2sd (%rax,%rbx,4), %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x10f0
incq %rbx
jmp 0x1838
pushq $0xa
popq %rdi
movq %r13, %rsi
callq 0x10d0
movq 0x18(%rsp), %rcx
incq %rcx
movq 0x60(%rsp), %rax
addq %rax, %r12
addq %rax, 0x8(%rsp)
movq (%rsp), %rax
addq 0x58(%rsp), %rax
movq %rax, (%rsp)
movq 0x50(%rsp), %rax
addq %rax, 0x28(%rsp)
addq %rax, 0x30(%rsp)
movq 0x48(%rsp), %rax
addq %rax, 0x20(%rsp)
jmp 0x1726
movq %r13, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1070