// File: /workspace/github_c_makefile_star2_O0/zpole[P]IICV/vl/kmeans.c
// Function: vl_kmeans_quantize_f
static void
VL_XCAT(_vl_kmeans_quantize_, SFX)
(VlKMeans * self,
 vl_uint32 * assignments,
 TYPE * distances,
 TYPE const * data,
 vl_size numData)
{
  vl_index i ;

#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

#ifdef _OPENMP
#pragma omp parallel default(none) \
            shared(self, distances, assignments, numData, distFn, data) \
            num_threads(vl_get_max_threads())
#endif
  {
    /* vl_malloc cannot be used here if mapped to MATLAB malloc */
    TYPE * distanceToCenters = malloc(sizeof(TYPE) * self->numCenters) ;

#ifdef _OPENMP
#pragma omp for
#endif
    for (i = 0 ; i < (signed)numData ; ++i) {
      vl_uindex k ;
      TYPE bestDistance = (TYPE) VL_INFINITY_D ;
      VL_XCAT(vl_eval_vector_comparison_on_all_pairs_, SFX)(distanceToCenters,
                                                            self->dimension,
                                                            data + self->dimension * i, 1,
                                                            (TYPE*)self->centers, self->numCenters,
                                                            distFn) ;
      for (k = 0 ; k < self->numCenters ; ++k) {
        if (distanceToCenters[k] < bestDistance) {
          bestDistance = distanceToCenters[k] ;
          assignments[i] = (vl_uint32)k ;
        }
      }
      if (distances) distances[i] = bestDistance ;
    }

    free(distanceToCenters) ;
  }
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x30(%rsp)
movq 0x50(%rsp), %rax
movl 0x30(%rax), %edi
callq 0x9940
movq %rax, 0x20(%rsp)
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rdi
shlq $0x2, %rdi
callq 0x9c78
movq %rax, 0x18(%rsp)
movq $0x0, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x2fc85
movsd 0x29e93(%rip), %xmm0    # 0x59a20
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x18(%rsp), %rdi
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x38(%rsp), %rdx
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
imulq 0x28(%rsp), %rax
shlq $0x2, %rax
addq %rax, %rdx
movq 0x50(%rsp), %rax
movq 0x58(%rax), %r8
movq 0x50(%rsp), %rax
movq 0x10(%rax), %r9
movq 0x20(%rsp), %rax
movl $0x1, %ecx
movq %rax, (%rsp)
callq 0x9c20
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq 0x50(%rsp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x2fc53
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
movss (%rax,%rcx,4), %xmm1
movss 0xc(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2fc41
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x10(%rsp), %rax
movl %eax, %edx
movq 0x48(%rsp), %rax
movq 0x28(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x2fc43
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0x2fbee
cmpq $0x0, 0x40(%rsp)
je 0x2fc70
movss 0xc(%rsp), %xmm0
movq 0x40(%rsp), %rax
movq 0x28(%rsp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x2fc72
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x2fb6f
movq 0x18(%rsp), %rdi
callq 0x9c70
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)