// File: /workspace/github_cpp_makefile_star2_O1/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 $0x98, %rsp
movq %r8, 0x80(%rsp)
movq %rcx, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movss %xmm0, 0x74(%rsp)
movq %rsi, 0x78(%rsp)
movq %rdi, %r13
cmpq $0x0, 0x70(%rdi)
jne 0x6fd6
movl $0x40, %edi
callq 0x2200
movq %rax, %r14
movq %rax, %rdi
movq %r13, %rsi
callq 0x83c0
movq %r14, 0x70(%r13)
movslq 0x60(%r13), %rbx
movq %rbx, %rdi
callq 0x2040
movq %rax, %rbp
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2100
movl $0x0, 0x8(%rsp)
testq %rbx, %rbx
jle 0x7230
leaq 0x10(%rsp), %rbx
leaq 0x50(%rsp), %r14
leaq 0x30(%rsp), %r12
xorl %eax, %eax
movslq %eax, %rcx
cmpb $0x0, (%rbp,%rcx)
jne 0x721c
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x60(%rsp)
movq %rcx, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq %rcx, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
je 0x705c
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x7069
movq %rbx, %rdi
leaq 0x8(%rsp), %rdx
callq 0x80de
movslq 0x8(%rsp), %rax
movb $0x1, (%rbp,%rax)
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x717a
movl -0x4(%rax), %ecx
movl %ecx, 0xc(%rsp)
addq $-0x4, %rax
movq %rax, 0x18(%rsp)
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x70ac
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x70b9
movq %r14, %rdi
leaq 0xc(%rsp), %rdx
callq 0x80de
movq 0x58(%r13), %rax
movq 0x70(%r13), %rdi
movslq 0xc(%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
movq %r12, %rsi
movss 0x74(%rsp), %xmm3
callq 0x876a
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq %rax, %rcx
je 0x7167
xorl %r15d, %r15d
movslq (%rax,%r15,4), %rcx
cmpb $0x0, (%rbp,%rcx)
jne 0x714b
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x7131
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x713d
leaq (%rax,%r15,4), %rdx
movq %rbx, %rdi
callq 0x80de
movq 0x30(%rsp), %rax
movslq (%rax,%r15,4), %rax
movb $0x1, (%rbp,%rax)
incq %r15
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rdx, %r15
jb 0x710d
cmpq %rax, %rcx
je 0x7073
movq %rax, 0x38(%rsp)
jmp 0x7073
movq 0x58(%rsp), %rax
subq 0x50(%rsp), %rax
sarq $0x2, %rax
cmpq 0x88(%rsp), %rax
setb %cl
cmpq 0x90(%rsp), %rax
seta %al
orb %cl, %al
jne 0x71af
movq 0x78(%rsp), %rdi
movq %r14, %rsi
callq 0x7c10
movq 0x78(%rsp), %rax
movq 0x8(%rax), %r15
subq (%rax), %r15
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x71d2
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x71e9
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x7200
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
sarq $0x3, %r15
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r15
cmpq 0x80(%rsp), %r15
jae 0x7230
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
cmpl 0x60(%r13), %eax
jl 0x7014
movq %rbp, %rdi
callq 0x2260
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x40, %esi
movq %r14, %rdi
jmp 0x729e
jmp 0x725b
jmp 0x725b
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7275
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x728c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x72a3
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x23a0