// File: /workspace/github_c_makefile_star2_O3/zpole[P]IICV/vl/kdtree.c
// Function: vl_kdforest_query_with_array
vl_size
vl_kdforest_query_with_array (VlKDForest * self,
                              vl_uint32 * indexes,
                              vl_size numNeighbors,
                              vl_size numQueries,
                              void * distances,
                              void const * queries)
{
  vl_size numComparisons = 0;
  vl_type dataType = vl_kdforest_get_data_type(self) ;
  vl_size dimension = vl_kdforest_get_data_dimension(self) ;

#ifdef _OPENMP
#pragma omp parallel default(shared) num_threads(vl_get_max_threads())
#endif
  {
    vl_index qi ;
    vl_size thisNumComparisons = 0 ;
    VlKDForestSearcher * searcher ;
    VlKDForestNeighbor * neighbors ;

#ifdef _OPENMP
#pragma omp critical
#endif
    {
      searcher = vl_kdforest_new_searcher(self) ;
      neighbors = vl_calloc (sizeof(VlKDForestNeighbor), numNeighbors) ;
    }

#ifdef _OPENMP
#pragma omp for
#endif
    for(qi = 0 ; qi < (signed)numQueries; ++ qi) {
      switch (dataType) {
        case VL_TYPE_FLOAT: {
          vl_size ni;
          thisNumComparisons += vl_kdforestsearcher_query (searcher, neighbors, numNeighbors,
                                                           (float const *) (queries) + qi * dimension) ;
          for (ni = 0 ; ni < numNeighbors ; ++ni) {
            indexes [qi*numNeighbors + ni] = (vl_uint32) neighbors[ni].index ;
            if (distances){
              *((float*)distances + qi*numNeighbors + ni) = neighbors[ni].distance ;
            }
          }
          break ;
        }
        case VL_TYPE_DOUBLE: {
          vl_size ni;
          thisNumComparisons += vl_kdforestsearcher_query (searcher, neighbors, numNeighbors,
                                                           (double const *) (queries) + qi * dimension) ;
          for (ni = 0 ; ni < numNeighbors ; ++ni) {
            indexes [qi*numNeighbors + ni] = (vl_uint32) neighbors[ni].index ;
            if (distances){
              *((double*)distances + qi*numNeighbors + ni) = neighbors[ni].distance ;
            }
          }
          break ;
        }
        default:
          abort() ;
      }
    }

#ifdef _OPENMP
#pragma omp critical
#endif
    {
      numComparisons += thisNumComparisons ;
      vl_kdforestsearcher_delete (searcher) ;
      vl_free (neighbors) ;
    }
  }
  return numComparisons ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, 0x28(%rsp)
movq %r8, %r14
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r13
movl 0x10(%rdi), %r12d
movq (%rdi), %rax
movq %rax, 0x50(%rsp)
callq 0x9130
movq %rax, 0x18(%rsp)
movl $0x10, %edi
movq %r15, %rsi
callq 0x98f0
movq %rax, 0x8(%rsp)
movslq %ebx, %rax
movq %rax, 0x48(%rsp)
testq %rax, %rax
jle 0x1e2fd
movq %r12, 0x40(%rsp)
leal -0x1(%r12), %eax
cmpl $0x1, %eax
ja 0x1e32e
leaq (,%r15,8), %rax
movq %rax, 0x38(%rsp)
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
leaq (,%r15,4), %rax
movq %rax, 0x30(%rsp)
xorl %r12d, %r12d
movq %r14, %rbp
movq %r14, %rbx
movq $0x0, 0x10(%rsp)
movq %r12, %rax
imulq 0x50(%rsp), %rax
cmpl $0x1, 0x40(%rsp)
jne 0x1e28f
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,4), %rcx
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x92e0
testq %r15, %r15
je 0x1e2d8
movq 0x20(%rsp), %rcx
xorl %edx, %edx
movl (%rcx), %esi
movl %esi, (%r13,%rdx,4)
testq %r14, %r14
je 0x1e281
xorps %xmm0, %xmm0
cvtsd2ss -0x8(%rcx), %xmm0
movss %xmm0, (%rbp,%rdx,4)
incq %rdx
addq $0x10, %rcx
cmpq %rdx, %r15
jne 0x1e267
jmp 0x1e2d8
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,8), %rcx
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x92e0
testq %r15, %r15
je 0x1e2d8
movq 0x20(%rsp), %rcx
xorl %edx, %edx
movl (%rcx), %esi
movl %esi, (%r13,%rdx,4)
testq %r14, %r14
je 0x1e2cc
movsd -0x8(%rcx), %xmm0
movsd %xmm0, (%rbx,%rdx,8)
incq %rdx
addq $0x10, %rcx
cmpq %rdx, %r15
jne 0x1e2b6
addq %rax, 0x10(%rsp)
incq %r12
addq 0x38(%rsp), %rbx
movq 0x30(%rsp), %rax
addq %rax, %r13
addq %rax, %rbp
cmpq 0x48(%rsp), %r12
jne 0x1e230
jmp 0x1e306
movq $0x0, 0x10(%rsp)
movq 0x18(%rsp), %rdi
callq 0x91d0
movq 0x8(%rsp), %rdi
callq 0x9580
movq 0x10(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x90b0