// File: /workspace/github_c_makefile_star2_O2/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, 0x30(%rsp)
movq %r8, %r14
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r12
movl 0x10(%rdi), %eax
movl %eax, 0x1c(%rsp)
movq (%rdi), %rax
movq %rax, 0x28(%rsp)
callq 0x9130
movq %rax, 0x10(%rsp)
pushq $0x10
popq %rdi
movq %r15, %rsi
callq 0x9960
movslq %ebx, %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
cmovleq %rcx, %rdx
movq %rdx, 0x48(%rsp)
leaq (,%r15,4), %rdx
movq %rdx, 0x40(%rsp)
movq %rax, 0x8(%rsp)
addq $0x8, %rax
movq %rax, 0x20(%rsp)
leaq (,%r15,8), %rax
movq %rax, 0x38(%rsp)
movq %r14, %r13
movq %r14, %rbp
xorl %ebx, %ebx
cmpq 0x48(%rsp), %rbx
je 0x1b059
movl 0x1c(%rsp), %eax
cmpl $0x2, %eax
movq %rcx, 0x50(%rsp)
je 0x1afea
cmpl $0x1, %eax
jne 0x1b082
movq %rbx, %rax
imulq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
leaq (%rcx,%rax,4), %rcx
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x92f0
movq 0x20(%rsp), %rcx
xorl %edx, %edx
cmpq %rdx, %r15
je 0x1b039
movl (%rcx), %esi
movl %esi, (%r12,%rdx,4)
testq %r14, %r14
je 0x1afe1
cvtsd2ss -0x8(%rcx), %xmm0
movss %xmm0, (%r13,%rdx,4)
incq %rdx
addq $0x10, %rcx
jmp 0x1afc5
movq %rbx, %rax
imulq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
leaq (%rcx,%rax,8), %rcx
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x92f0
movq 0x20(%rsp), %rcx
xorl %edx, %edx
cmpq %rdx, %r15
je 0x1b039
movl (%rcx), %esi
movl %esi, (%r12,%rdx,4)
testq %r14, %r14
je 0x1b030
movsd -0x8(%rcx), %xmm0
movsd %xmm0, (%rbp,%rdx,8)
incq %rdx
addq $0x10, %rcx
jmp 0x1b015
movq 0x50(%rsp), %rcx
addq %rax, %rcx
incq %rbx
movq 0x40(%rsp), %rax
addq %rax, %r12
addq 0x38(%rsp), %rbp
addq %rax, %r13
jmp 0x1af78
movq 0x10(%rsp), %rdi
movq %rcx, %rbx
callq 0x91d0
movq 0x8(%rsp), %rdi
callq 0x95b0
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x90b0