// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movq %rsi, 0xc8(%rsp)
movq %rdx, 0xc0(%rsp)
movq %rcx, 0xb8(%rsp)
movq %r8, 0xb0(%rsp)
leaq 0x136a(%rip), %rax      # 0x3020
movq %rax, 0xa8(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x1060
movq %rax, 0x80(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x1040
movq %rax, 0x78(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x11f0
movl %eax, 0x74(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x1170
movq %rax, 0x68(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x1190
movq %rax, 0x60(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x11b0
movq %rax, 0x58(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x10d0
movq %rax, 0x50(%rsp)
movq 0xd0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0x11e0
movq %rax, 0xa0(%rsp)
movq $0x0, 0x88(%rsp)
movq 0x88(%rsp), %rax
cmpq 0xb0(%rsp), %rax
jae 0x1f33
movq 0xc0(%rsp), %rdi
callq 0x11f0
cmpl $0x2, %eax
jne 0x1e49
movq $0x0, 0x98(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x1060
movq %rax, %rcx
movq 0x48(%rsp), %rax
cmpq %rcx, %rax
jae 0x1e44
movq 0xa0(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x1060
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rdi
movq %rax, %rdx
movq 0x40(%rsp), %rax
imulq %rdx, %rcx
addq 0x98(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0x11fe(%rip), %rsi      # 0x3022
movb $0x1, %al
callq 0x1100
movq 0x98(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x98(%rsp)
jmp 0x1d9f
jmp 0x1f04
movq $0x0, 0x98(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x1060
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x1f02
movq 0xa0(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x1060
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rdi
movq %rax, %rdx
movq 0x20(%rsp), %rax
imulq %rdx, %rcx
addq 0x98(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1140(%rip), %rsi      # 0x3022
movb $0x1, %al
callq 0x1100
movq 0x98(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x98(%rsp)
jmp 0x1e55
jmp 0x1f04
movq 0xa0(%rsp), %rdi
leaq 0x1113(%rip), %rsi      # 0x3026
movb $0x0, %al
callq 0x1100
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x1d67
movq 0xa0(%rsp), %rdi
callq 0x1090
movq 0xc8(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0x11e0
movq %rax, 0xa0(%rsp)
movq $0x0, 0x90(%rsp)
movq 0x90(%rsp), %rax
cmpq 0x78(%rsp), %rax
jae 0x22d6
cmpl $0x2, 0x74(%rsp)
jne 0x2126
movq $0x0, 0x98(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x1060
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x2009
movq 0xa0(%rsp), %rdi
movq 0x60(%rsp), %rax
movq 0x90(%rsp), %rcx
imulq 0x80(%rsp), %rcx
addq 0x98(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0x1036(%rip), %rsi      # 0x3022
movb $0x1, %al
callq 0x1100
movq 0x98(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x98(%rsp)
jmp 0x1f93
movq $0x0, 0x98(%rsp)
movq 0x98(%rsp), %rax
cmpq 0x80(%rsp), %rax
jae 0x2076
movq 0xa0(%rsp), %rdi
movq 0x68(%rsp), %rax
movq 0x90(%rsp), %rcx
imulq 0x80(%rsp), %rcx
addq 0x98(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0xfc9(%rip), %rsi       # 0x3022
movb $0x1, %al
callq 0x1100
movq 0x98(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x98(%rsp)
jmp 0x2015
movq 0xa0(%rsp), %rdi
movq 0x58(%rsp), %rax
movq 0x90(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0xf8b(%rip), %rsi       # 0x3022
movb $0x1, %al
callq 0x1100
movq $0x0, 0x88(%rsp)
movq 0x88(%rsp), %rax
cmpq 0xb0(%rsp), %rax
jae 0x210b
movq 0xa0(%rsp), %rdi
movq 0x50(%rsp), %rax
movq 0x90(%rsp), %rcx
imulq 0xb0(%rsp), %rcx
addq 0x88(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0xf34(%rip), %rsi       # 0x3022
movb $0x1, %al
callq 0x1100
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x20aa
movq 0xa0(%rsp), %rdi
leaq 0xf0c(%rip), %rsi       # 0x3026
movb $0x0, %al
callq 0x1100
jmp 0x22bb
movq $0x0, 0x98(%rsp)
movq 0x98(%rsp), %rax
cmpq 0x80(%rsp), %rax
jae 0x2197
movq 0xa0(%rsp), %rdi
movq 0x60(%rsp), %rax
movq 0x90(%rsp), %rcx
imulq 0x80(%rsp), %rcx
addq 0x98(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0xea8(%rip), %rsi       # 0x3022
movb $0x1, %al
callq 0x1100
movq 0x98(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x98(%rsp)
jmp 0x2132
movq $0x0, 0x98(%rsp)
movq 0x98(%rsp), %rax
cmpq 0x80(%rsp), %rax
jae 0x2208
movq 0xa0(%rsp), %rdi
movq 0x68(%rsp), %rax
movq 0x90(%rsp), %rcx
imulq 0x80(%rsp), %rcx
addq 0x98(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0xe37(%rip), %rsi       # 0x3022
movb $0x1, %al
callq 0x1100
movq 0x98(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x98(%rsp)
jmp 0x21a3
movq 0xa0(%rsp), %rdi
movq 0x58(%rsp), %rax
movq 0x90(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0xdf5(%rip), %rsi       # 0x3022
movb $0x1, %al
callq 0x1100
movq $0x0, 0x88(%rsp)
movq 0x88(%rsp), %rax
cmpq 0xb0(%rsp), %rax
jae 0x22a5
movq 0xa0(%rsp), %rdi
movq 0x50(%rsp), %rax
movq 0x90(%rsp), %rcx
imulq 0xb0(%rsp), %rcx
addq 0x88(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0xd9a(%rip), %rsi       # 0x3022
movb $0x1, %al
callq 0x1100
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x2240
movq 0xa0(%rsp), %rdi
leaq 0xd72(%rip), %rsi       # 0x3026
movb $0x0, %al
callq 0x1100
jmp 0x22bd
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x90(%rsp)
jmp 0x1f69
movq 0xa0(%rsp), %rdi
callq 0x1090
addq $0xd8, %rsp
retq