// File: /workspace/github_c_makefile_star2_O0/zpole[P]IICV/vl/gmm.c
// Function: vl_gmm_init_with_kmeans_f
static void
VL_XCAT(_vl_gmm_init_with_kmeans_, SFX)
(VlGMM * self,
 TYPE const * data,
 vl_size numData,
 VlKMeans * kmeansInit)
{
  vl_size i_d ;
  vl_uint32 * assignments = vl_malloc(sizeof(vl_uint32) * numData);

  _vl_gmm_prepare_for_data (self, numData) ;

  memset(self->means,0,sizeof(TYPE) * self->numClusters * self->dimension) ;
  memset(self->priors,0,sizeof(TYPE) * self->numClusters) ;
  memset(self->covariances,0,sizeof(TYPE) * self->numClusters * self->dimension) ;
  memset(self->posteriors,0,sizeof(TYPE) * self->numClusters * numData) ;

  /* setup speified KMeans initialization object if any */
  if (kmeansInit) { vl_gmm_set_kmeans_init_object (self, kmeansInit) ; }

  /* if a KMeans initalization object is still unavailable, create one */
  if(self->kmeansInit == NULL) {
    vl_size ncomparisons = VL_MAX(numData / 4, 10) ;
    vl_size niter = 5 ;
    vl_size ntrees = 1 ;
    vl_size nrepetitions = 1 ;
    VlKMeansAlgorithm algorithm = VlKMeansANN ;
    VlKMeansInitialization initialization = VlKMeansRandomSelection ;

    VlKMeans * kmeansInitDefault = vl_kmeans_new(self->dataType,VlDistanceL2) ;
    vl_kmeans_set_initialization(kmeansInitDefault, initialization);
    vl_kmeans_set_max_num_iterations (kmeansInitDefault, niter) ;
    vl_kmeans_set_max_num_comparisons (kmeansInitDefault, ncomparisons) ;
    vl_kmeans_set_num_trees (kmeansInitDefault, ntrees);
    vl_kmeans_set_algorithm (kmeansInitDefault, algorithm);
    vl_kmeans_set_num_repetitions(kmeansInitDefault, nrepetitions);
    vl_kmeans_set_verbosity (kmeansInitDefault, self->verbosity);

    self->kmeansInit = kmeansInitDefault;
    self->kmeansInitIsOwner = VL_TRUE ;
  }

  /* Use k-means to assign data to clusters */
  vl_kmeans_cluster (self->kmeansInit, data, self->dimension, numData, self->numClusters);
  vl_kmeans_quantize (self->kmeansInit, assignments, NULL, data, numData) ;

  /* Transform the k-means assignments in posteriors and estimates the mode parameters */
  for(i_d = 0; i_d < numData; i_d++) {
    ((TYPE*)self->posteriors)[assignments[i_d] + i_d * self->numClusters] = (TYPE) 1.0 ;
  }

  /* Update cluster parameters */
  VL_XCAT(_vl_gmm_maximization_, SFX)
    (self,self->posteriors,self->priors,self->covariances,self->means,data,numData);
  vl_free(assignments) ;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq 0x60(%rsp), %rdi
shlq $0x2, %rdi
callq 0x9660
movq %rax, 0x48(%rsp)
movq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x1a6e0
movq 0x70(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rdx
shlq $0x2, %rdx
movq 0x70(%rsp), %rax
imulq 0x8(%rax), %rdx
xorl %esi, %esi
callq 0x9480
movq 0x70(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x9480
movq 0x70(%rsp), %rax
movq 0x40(%rax), %rdi
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rdx
shlq $0x2, %rdx
movq 0x70(%rsp), %rax
imulq 0x8(%rax), %rdx
xorl %esi, %esi
callq 0x9480
movq 0x70(%rsp), %rax
movq 0x50(%rax), %rdi
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rdx
shlq $0x2, %rdx
imulq 0x60(%rsp), %rdx
xorl %esi, %esi
callq 0x9480
cmpq $0x0, 0x58(%rsp)
je 0x1963f
movq 0x70(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x99d0
movq 0x70(%rsp), %rax
cmpq $0x0, 0x68(%rax)
jne 0x19749
movq 0x60(%rsp), %rax
shrq $0x2, %rax
cmpq $0xa, %rax
jbe 0x1966e
movq 0x60(%rsp), %rax
shrq $0x2, %rax
movq %rax, 0x10(%rsp)
jmp 0x1967a
movl $0xa, %eax
movq %rax, 0x10(%rsp)
jmp 0x1967a
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
movq $0x5, 0x38(%rsp)
movq $0x1, 0x30(%rsp)
movq $0x1, 0x28(%rsp)
movl $0x2, 0x24(%rsp)
movl $0x0, 0x20(%rsp)
movq 0x70(%rsp), %rax
movl (%rax), %edi
movl $0x1, %esi
callq 0x91d0
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
movl 0x20(%rsp), %esi
callq 0x1abf0
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x1ac10
movq 0x18(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x1ac30
movq 0x18(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x1ac50
movq 0x18(%rsp), %rdi
movl 0x24(%rsp), %esi
callq 0x1ac70
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x1ac90
movq 0x18(%rsp), %rdi
movq 0x70(%rsp), %rax
movl 0x30(%rax), %esi
callq 0x1acb0
movq 0x18(%rsp), %rcx
movq 0x70(%rsp), %rax
movq %rcx, 0x68(%rax)
movq 0x70(%rsp), %rax
movl $0x1, 0x78(%rax)
movq 0x70(%rsp), %rax
movq 0x68(%rax), %rdi
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x60(%rsp), %rcx
movq 0x70(%rsp), %rax
movq 0x10(%rax), %r8
callq 0x95a0
movq 0x70(%rsp), %rax
movq 0x68(%rax), %rdi
movq 0x48(%rsp), %rsi
movq 0x68(%rsp), %rcx
movq 0x60(%rsp), %r8
xorl %eax, %eax
movl %eax, %edx
callq 0x9c50
movq $0x0, 0x50(%rsp)
movq 0x50(%rsp), %rax
cmpq 0x60(%rsp), %rax
jae 0x197ee
movq 0x70(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
movq 0x50(%rsp), %rdx
movq 0x70(%rsp), %rsi
imulq 0x10(%rsi), %rdx
addq %rdx, %rcx
movss 0x3f9b7(%rip), %xmm0    # 0x59190
movss %xmm0, (%rax,%rcx,4)
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x1979d
movq 0x70(%rsp), %rdi
movq 0x70(%rsp), %rax
movq 0x50(%rax), %rsi
movq 0x70(%rsp), %rax
movq 0x48(%rax), %rdx
movq 0x70(%rsp), %rax
movq 0x40(%rax), %rcx
movq 0x70(%rsp), %rax
movq 0x38(%rax), %r8
movq 0x68(%rsp), %r9
movq 0x60(%rsp), %rax
movq %rax, (%rsp)
callq 0x1acd0
movq 0x48(%rsp), %rdi
callq 0x9620
addq $0x78, %rsp
retq
nopl (%rax)