// File: mitchellsayer[P]FastPointCloudSegmentation/src/./nanoflann.hpp
// Function: nanoflann::KDTreeSingleIndexAdaptor<nanoflann::L2_Simple_Adaptor<float, ScanlinePointCloud, float>, ScanlinePointCloud, 3, unsigned long>::middleSplit_(unsigned long*, unsigned long, unsigned long&, int&, float&, nanoflann::CArray<nanoflann::KDTreeSingleIndexAdaptor<nanoflann::L2_Simple_Adaptor<float, ScanlinePointCloud, float>, ScanlinePointCloud, 3, unsigned long>::Interval, 3ul> const&)
void middleSplit_(IndexType* ind, IndexType count, IndexType& index, int& cutfeat, DistanceType& cutval, const BoundingBox& bbox)
		{
			const DistanceType EPS=static_cast<DistanceType>(0.00001);
			ElementType max_span = bbox[0].high-bbox[0].low;
			for (int i=1; i<(DIM>0 ? DIM : dim); ++i) {
				ElementType span = bbox[i].high-bbox[i].low;
				if (span>max_span) {
					max_span = span;
				}
			}
			ElementType max_spread = -1;
			cutfeat = 0;
			for (int i=0; i<(DIM>0 ? DIM : dim); ++i) {
				ElementType span = bbox[i].high-bbox[i].low;
				if (span>(1-EPS)*max_span) {
					ElementType min_elem, max_elem;
					computeMinMax(ind, count, i, min_elem, max_elem);
					ElementType spread = max_elem-min_elem;;
					if (spread>max_spread) {
						cutfeat = i;
						max_spread = spread;
					}
				}
			}
			// split in the middle
			DistanceType split_val = (bbox[cutfeat].low+bbox[cutfeat].high)/2;
			ElementType min_elem, max_elem;
			computeMinMax(ind, count, cutfeat, min_elem, max_elem);

			if (split_val<min_elem) cutval = min_elem;
			else if (split_val>max_elem) cutval = max_elem;
			else cutval = split_val;

			IndexType lim1, lim2;
			planeSplit(ind, count, cutfeat, cutval, lim1, lim2);

			if (lim1>count/2) index = lim1;
			else if (lim2<count/2) index = lim2;
			else index = count/2;
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
movss 0x18de(%rip), %xmm0     # 0x12028
movss %xmm0, -0x34(%rbp)
movq 0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x10bb0
movss 0x4(%rax), %xmm0
movss %xmm0, -0x7c(%rbp)
movq 0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x10bb0
movss -0x7c(%rbp), %xmm0
subss (%rax), %xmm0
movss %xmm0, -0x38(%rbp)
movl $0x1, -0x3c(%rbp)
cmpl $0x3, -0x3c(%rbp)
jge 0x107e8
movq 0x10(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x10bb0
movss 0x4(%rax), %xmm0
movss %xmm0, -0x8c(%rbp)
movq 0x10(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x10bb0
movss -0x8c(%rbp), %xmm0
subss (%rax), %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x40(%rbp), %xmm0
ucomiss -0x38(%rbp), %xmm0
jbe 0x107db
movss -0x40(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
jmp 0x107dd
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x10788
movss 0x1814(%rip), %xmm0     # 0x12004
movss %xmm0, -0x44(%rbp)
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x48(%rbp)
cmpl $0x3, -0x48(%rbp)
jge 0x108bd
movq 0x10(%rbp), %rdi
movslq -0x48(%rbp), %rsi
callq 0x10bb0
movss 0x4(%rax), %xmm0
movss %xmm0, -0x90(%rbp)
movq 0x10(%rbp), %rdi
movslq -0x48(%rbp), %rsi
callq 0x10bb0
movss -0x90(%rbp), %xmm0
subss (%rax), %xmm0
movss %xmm0, -0x4c(%rbp)
movss -0x4c(%rbp), %xmm0
movss 0x17db(%rip), %xmm1     # 0x12030
mulss -0x38(%rbp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x108ad
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x48(%rbp), %ecx
leaq -0x50(%rbp), %r8
leaq -0x54(%rbp), %r9
callq 0x10bd0
movss -0x54(%rbp), %xmm0
subss -0x50(%rbp), %xmm0
movss %xmm0, -0x58(%rbp)
movss -0x58(%rbp), %xmm0
ucomiss -0x44(%rbp), %xmm0
jbe 0x108ab
movl -0x48(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movss -0x58(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
jmp 0x108ad
jmp 0x108af
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x10806
movq 0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movslq (%rax), %rsi
callq 0x10bb0
movss (%rax), %xmm0
movss %xmm0, -0x94(%rbp)
movq 0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movslq (%rax), %rsi
callq 0x10bb0
movss -0x94(%rbp), %xmm0
movq -0x88(%rbp), %rdi
addss 0x4(%rax), %xmm0
movss 0x1727(%rip), %xmm1     # 0x1202c
divss %xmm1, %xmm0
movss %xmm0, -0x5c(%rbp)
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rax
movl (%rax), %ecx
leaq -0x60(%rbp), %r8
leaq -0x64(%rbp), %r9
callq 0x10bd0
movss -0x5c(%rbp), %xmm1
movss -0x60(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x10947
movss -0x60(%rbp), %xmm0
movq -0x30(%rbp), %rax
movss %xmm0, (%rax)
jmp 0x10970
movss -0x5c(%rbp), %xmm0
ucomiss -0x64(%rbp), %xmm0
jbe 0x10961
movss -0x64(%rbp), %xmm0
movq -0x30(%rbp), %rax
movss %xmm0, (%rax)
jmp 0x1096e
movss -0x5c(%rbp), %xmm0
movq -0x30(%rbp), %rax
movss %xmm0, (%rax)
jmp 0x10970
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rax
movl (%rax), %ecx
movq -0x30(%rbp), %r8
leaq -0x70(%rbp), %r9
leaq -0x78(%rbp), %rax
movq %rax, (%rsp)
callq 0x10cb0
movq -0x70(%rbp), %rax
movq -0x18(%rbp), %rcx
shrq %rcx
cmpq %rcx, %rax
jbe 0x109b7
movq -0x70(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x109e4
movq -0x78(%rbp), %rax
movq -0x18(%rbp), %rcx
shrq %rcx
cmpq %rcx, %rax
jae 0x109d4
movq -0x78(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x109e2
movq -0x18(%rbp), %rcx
shrq %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x109e4
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)