// File: /workspace/github_c_makefile_star2_O0/zpole[P]IICV/vl/kmeans.c
// Function: vl_kmeans_init_centers_with_rand_data_f
static void
VL_XCAT(_vl_kmeans_init_centers_with_rand_data_, SFX)
(VlKMeans * self,
 TYPE const * data,
 vl_size dimension,
 vl_size numData,
 vl_size numCenters)
{
  vl_uindex i, j, k ;
  VlRand * rand = vl_get_rand () ;

  self->dimension = dimension ;
  self->numCenters = numCenters ;
  self->centers = vl_malloc (sizeof(TYPE) * dimension * numCenters) ;

  {
    vl_uindex * perm = vl_malloc (sizeof(vl_uindex) * numData) ;
#if (FLT == VL_TYPE_FLOAT)
    VlFloatVectorComparisonFunction distFn = vl_get_vector_comparison_function_f(self->distance) ;
#else
    VlDoubleVectorComparisonFunction distFn = vl_get_vector_comparison_function_d(self->distance) ;
#endif
    TYPE * distances = vl_malloc (sizeof(TYPE) * numCenters) ;

    /* get a random permutation of the data point */
    for (i = 0 ; i < numData ; ++i) perm[i] = i ;
    _vl_kmeans_shuffle (perm, numData, rand) ;

    for (k = 0, i = 0 ; k < numCenters ; ++ i) {

      /* compare the next data point to all centers collected so far
       to detect duplicates (if there are enough left)
       */
      if (numCenters - k < numData - i) {
        vl_bool duplicateDetected = VL_FALSE ;
        VL_XCAT(vl_eval_vector_comparison_on_all_pairs_, SFX)(distances,
            dimension,
            data + dimension * perm[i], 1,
            (TYPE*)self->centers, k,
            distFn) ;
        for (j = 0 ; j < k ; ++j) {
          duplicateDetected |= (distances[j] == 0) ;
        }
        if (duplicateDetected) continue ;
      }

      /* ok, it is not a duplicate so we can accept it! */
      memcpy ((TYPE*)self->centers + dimension * k,
              data + dimension * perm[i],
              sizeof(TYPE) * dimension) ;
      k ++ ;
    }
    vl_free(distances) ;
    vl_free(perm) ;
  }
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq %r8, 0x50(%rsp)
callq 0x9a20
movq %rax, 0x30(%rsp)
movq 0x60(%rsp), %rcx
movq 0x70(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x50(%rsp), %rcx
movq 0x70(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x60(%rsp), %rdi
shlq $0x2, %rdi
imulq 0x50(%rsp), %rdi
callq 0x9660
movq %rax, %rcx
movq 0x70(%rsp), %rax
movq %rcx, 0x58(%rax)
movq 0x58(%rsp), %rdi
shlq $0x3, %rdi
callq 0x9660
movq %rax, 0x28(%rsp)
movq 0x70(%rsp), %rax
movl 0x30(%rax), %edi
callq 0x9940
movq %rax, 0x20(%rsp)
movq 0x50(%rsp), %rdi
shlq $0x2, %rdi
callq 0x9660
movq %rax, 0x18(%rsp)
movq $0x0, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x58(%rsp), %rax
jae 0x2f013
movq 0x48(%rsp), %rdx
movq 0x28(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x2efe4
movq 0x28(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x30710
movq $0x0, 0x38(%rsp)
movq $0x0, 0x48(%rsp)
movq 0x38(%rsp), %rax
cmpq 0x50(%rsp), %rax
jae 0x2f17d
movq 0x50(%rsp), %rax
subq 0x38(%rsp), %rax
movq 0x58(%rsp), %rcx
subq 0x48(%rsp), %rcx
cmpq %rcx, %rax
jae 0x2f113
movl $0x0, 0x14(%rsp)
movq 0x18(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq 0x60(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x48(%rsp), %r8
imulq (%rcx,%r8,8), %rax
shlq $0x2, %rax
addq %rax, %rdx
movq 0x70(%rsp), %rax
movq 0x58(%rax), %r8
movq 0x38(%rsp), %r9
movq 0x20(%rsp), %rax
movl $0x1, %ecx
movq %rax, (%rsp)
callq 0x9c20
movq $0x0, 0x40(%rsp)
movq 0x40(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x2f108
movq 0x18(%rsp), %rax
movq 0x40(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
sete %al
setnp %cl
andb %cl, %al
andb $0x1, %al
movzbl %al, %eax
orl 0x14(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x2f0c2
cmpl $0x0, 0x14(%rsp)
je 0x2f111
jmp 0x2f16a
jmp 0x2f113
movq 0x70(%rsp), %rax
movq 0x58(%rax), %rdi
movq 0x60(%rsp), %rax
imulq 0x38(%rsp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq 0x68(%rsp), %rsi
movq 0x60(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x48(%rsp), %rdx
imulq (%rcx,%rdx,8), %rax
shlq $0x2, %rax
addq %rax, %rsi
movq 0x60(%rsp), %rdx
shlq $0x2, %rdx
callq 0x9640
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x2f039
movq 0x18(%rsp), %rdi
callq 0x9620
movq 0x28(%rsp), %rdi
callq 0x9620
addq $0x78, %rsp
retq
nopw %cs:(%rax,%rax)