// File: /workspace/github_cpp_makefile_star2_O2/jingdao[P]PointCloudApp/pcd.cpp
// Function: PCD::euclideanClusteringKDTree(std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>*, float, unsigned long, unsigned long, unsigned long)
void PCD::euclideanClusteringKDTree(std::vector<std::vector<int>> *indices,float distance,size_t minSize,size_t maxSize,size_t maxClusters) {
	if (!kdtree) kdtree = new KdTree(this);
	bool* visited = new bool[numPoints]();
	for (int i=0;i<numPoints;i++) {
		if (visited[i]) continue;
//		printf("%d %lu\n",i,indices->size());
		std::vector<int> P,Q,neighbors;
		Q.push_back(i);
		visited[i] = true;
		while (Q.size() > 0) {
			int p = Q[Q.size()-1];
			Q.pop_back();
			P.push_back(p);
			kdtree->search(&neighbors,float_data[p*4],float_data[p*4+1],float_data[p*4+2],distance);
			for (size_t j=0;j<neighbors.size();j++) {
				if (!visited[neighbors[j]]) {
					Q.push_back(neighbors[j]);
					visited[neighbors[j]] = true;
				}
			}
			neighbors.clear();
		}
		if (P.size() >= minSize && P.size() <= maxSize)
			indices->push_back(P);
		if (indices->size() >= maxClusters)
			break;
	}
	delete[] visited;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, 0x70(%rsp)
movq %rcx, 0x80(%rsp)
movq %rdx, 0x78(%rsp)
movss %xmm0, 0xc(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, %r13
cmpq $0x0, 0x70(%rdi)
jne 0x637e
pushq $0x40
popq %rdi
callq 0x2200
movq %rax, %r14
movq %rax, %rdi
movq %r13, %rsi
callq 0x75d8
movq %r14, 0x70(%r13)
movl 0x60(%r13), %r12d
movslq %r12d, %rbx
movq %rbx, %rdi
callq 0x2040
movq %rax, %rbp
xorl %r14d, %r14d
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2100
leaq 0x30(%rsp), %rbx
leaq 0x50(%rsp), %r15
movl %r14d, 0x4(%rsp)
cmpl %r12d, %r14d
jge 0x654c
movslq %r14d, %rax
cmpb $0x0, (%rbp,%rax)
jne 0x6544
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %rbx, %rdi
leaq 0x4(%rsp), %rsi
callq 0x6d04
movslq 0x4(%rsp), %rax
movb $0x1, (%rbp,%rax)
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x64d1
movl -0x4(%rax), %ecx
movl %ecx, 0x8(%rsp)
addq $-0x4, %rax
movq %rax, 0x38(%rsp)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0x6d04
movq 0x58(%r13), %rax
movq 0x70(%r13), %rdi
movslq 0x8(%rsp), %rcx
leaq (,%rcx,4), %rdx
shlq $0x4, %rcx
movss (%rax,%rcx), %xmm0
leal 0x1(%rdx), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm1
orl $0x2, %edx
movslq %edx, %rcx
movss (%rax,%rcx,4), %xmm2
leaq 0x10(%rsp), %rsi
movss 0xc(%rsp), %xmm3
callq 0x7928
movq 0x10(%rsp), %rsi
xorl %r12d, %r12d
xorl %r14d, %r14d
movq 0x18(%rsp), %rax
movq %rax, %rcx
subq %rsi, %rcx
sarq $0x2, %rcx
cmpq %rcx, %r14
jae 0x64be
movslq (%rsi,%r12), %rax
cmpb $0x0, (%rbp,%rax)
jne 0x64b5
addq %r12, %rsi
movq %rbx, %rdi
callq 0x6d04
movq 0x10(%rsp), %rsi
movslq (%rsi,%r12), %rax
movb $0x1, (%rbp,%rax)
incq %r14
addq $0x4, %r12
jmp 0x647d
cmpq %rsi, %rax
je 0x6401
movq %rsi, 0x18(%rsp)
jmp 0x6401
movq 0x58(%rsp), %rax
subq 0x50(%rsp), %rax
sarq $0x2, %rax
cmpq 0x78(%rsp), %rax
setb %cl
cmpq 0x80(%rsp), %rax
seta %al
orb %cl, %al
jne 0x6503
movq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x6d22
movq 0x28(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x2d00
movq %rbx, %rdi
callq 0x2d00
movq %r15, %rdi
callq 0x2d00
cmpq 0x70(%rsp), %r14
jae 0x654c
movl 0x4(%rsp), %r14d
movl 0x60(%r13), %r12d
incl %r14d
jmp 0x63aa
movq %rbp, %rdi
callq 0x2270
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
pushq $0x40
popq %rsi
movq %r14, %rdi
callq 0x2210
jmp 0x659b
jmp 0x657a
jmp 0x657a
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2d00
leaq 0x30(%rsp), %rdi
callq 0x2d00
leaq 0x50(%rsp), %rdi
callq 0x2d00
movq %rbx, %rdi
callq 0x23b0