// File: /workspace/github_cpp_makefile_star2_O2/jingdao[P]PointCloudApp/pcd.cpp
// Function: PCD::euclideanClustering(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::euclideanClustering(std::vector<std::vector<int>> *indices,float distance,size_t minSize,size_t maxSize,size_t maxClusters) {
	Ind* byX = new Ind[numPoints];
	Ind* byY = new Ind[numPoints];
	Ind* byZ = new Ind[numPoints];
	for (int i=0;i<numPoints;i++) {
		byX[i] = {float_data[i*4], i};
		byY[i] = {float_data[i*4 + 1], i};
		byZ[i] = {float_data[i*4 + 2], i};
	}
	qsort(byX,numPoints,sizeof(Ind),compare);
	qsort(byY,numPoints,sizeof(Ind),compare);
	qsort(byZ,numPoints,sizeof(Ind),compare);
	bool* visited = new bool[numPoints]();
	for (int i=0;i<numPoints;i++) {
		if (visited[i]) continue;
		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);
			Ind key,*xl,*xh,*yl,*yh,*zl,*zh;
			key.val = float_data[p*4] - distance;
			xl = (Ind*) closestBSearch(&key,byX,numPoints,sizeof(Ind),compare,true);
			key.val = float_data[p*4] + distance;
			xh = (Ind*) closestBSearch(&key,byX,numPoints,sizeof(Ind),compare,false);
			key.val = float_data[p*4+1] - distance;
			yl = (Ind*) closestBSearch(&key,byY,numPoints,sizeof(Ind),compare,true);
			key.val = float_data[p*4+1] + distance;
			yh = (Ind*) closestBSearch(&key,byY,numPoints,sizeof(Ind),compare,false);
			key.val = float_data[p*4+2] - distance;
			zl = (Ind*) closestBSearch(&key,byZ,numPoints,sizeof(Ind),compare,true);
			key.val = float_data[p*4+2] + distance;
			zh = (Ind*) closestBSearch(&key,byZ,numPoints,sizeof(Ind),compare,false);
			HashTable ht;
			int closeX,closeY,closeZ;
			for (Ind* k = xl; k <= xh; k++) ht.insert(k->index,&closeX);
			for (Ind* k = yl; k <= yh; k++) if (ht.remove(k->index)) ht.insert(k->index,&closeY);
			for (Ind* k = zl; k <= zh; k++) if (ht.remove(k->index) == &closeY) ht.insert(k->index,&closeZ);
			for (int k=0; k<ht.size; k++) {
				if (ht.entries[k] == &closeZ) {
					neighbors.push_back(ht.keys[k]);
				}
			}
			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[] byX;
	delete[] byY;
	delete[] byZ;
	delete[] visited;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %r8, 0xa0(%rsp)
movq %rcx, 0xb0(%rsp)
movq %rdx, 0xa8(%rsp)
movss %xmm0, 0x8(%rsp)
movq %rsi, 0x78(%rsp)
movq %rdi, %r15
movslq 0x60(%rdi), %rbx
leaq (,%rbx,8), %rax
testq %rbx, %rbx
pushq $-0x1
popq %r14
cmovnsq %rax, %r14
movq %r14, %rdi
callq 0x2040
movq %rax, 0x30(%rsp)
movq %r14, %rdi
callq 0x2040
movq %rax, 0x28(%rsp)
movq %r14, %rdi
callq 0x2040
movq %rax, 0x20(%rsp)
movq 0x58(%r15), %rax
xorl %ecx, %ecx
testl %ebx, %ebx
movl $0x0, %edx
cmovgl %ebx, %edx
shlq $0x3, %rdx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x676f
movss (%rax,%rsi,2), %xmm0
movq 0x30(%rsp), %rdi
movss %xmm0, (%rdi,%rsi)
movl %ecx, 0x4(%rdi,%rsi)
movss 0x4(%rax,%rsi,2), %xmm0
movq 0x28(%rsp), %rdi
movss %xmm0, (%rdi,%rsi)
movl %ecx, 0x4(%rdi,%rsi)
movss 0x8(%rax,%rsi,2), %xmm0
movq 0x20(%rsp), %rdi
movss %xmm0, (%rdi,%rsi)
movl %ecx, 0x4(%rdi,%rsi)
addq $0x8, %rsi
incl %ecx
jmp 0x6727
leaq -0x1d3(%rip), %r12      # 0x65a3
pushq $0x8
popq %r14
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x23d0
movslq 0x60(%r15), %rsi
movq 0x28(%rsp), %rdi
movq %r14, %rdx
movq %r12, %rcx
callq 0x23d0
movslq 0x60(%r15), %rsi
movq 0x20(%rsp), %rdi
movq %r14, %rdx
movq %r12, %rcx
callq 0x23d0
movl 0x60(%r15), %ebp
movslq %ebp, %rbx
movq %rbx, %rdi
callq 0x2040
movq %rax, %r13
xorl %r14d, %r14d
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2100
leaq 0xc(%rsp), %rbx
movq %r15, 0x18(%rsp)
movq %r13, 0xb8(%rsp)
movl %r14d, 0x14(%rsp)
cmpl %ebp, %r14d
jge 0x6c10
movslq %r14d, %rax
cmpb $0x0, (%r13,%rax)
jne 0x6c08
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
andq $0x0, 0x90(%rsp)
movaps %xmm0, 0x60(%rsp)
andq $0x0, 0x70(%rsp)
movaps %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x6d04
movslq 0x14(%rsp), %rax
movb $0x1, (%r13,%rax)
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
je 0x6b78
movl -0x4(%rax), %ecx
movl %ecx, 0x4(%rsp)
addq $-0x4, %rax
movq %rax, 0x68(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x6d04
movq 0x58(%r15), %rax
movslq 0x4(%rsp), %rcx
shlq $0x4, %rcx
movss (%rax,%rcx), %xmm0
subss 0x8(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movl 0x60(%r15), %edx
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
pushq $0x8
popq %r14
movl %r14d, %ecx
movq %r12, %r8
pushq $0x1
popq %r9
callq 0x65bd
movq %rax, %r13
movq 0x18(%rsp), %rdx
movq 0x58(%rdx), %rax
movslq 0x4(%rsp), %rcx
shlq $0x4, %rcx
movss (%rax,%rcx), %xmm0
addss 0x8(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movl 0x60(%rdx), %edx
leaq 0xc(%rsp), %rdi
movq 0x30(%rsp), %rsi
movl %r14d, %ecx
leaq -0x353(%rip), %r8       # 0x65a3
xorl %r9d, %r9d
callq 0x65bd
movq %rax, %rbx
movq 0x18(%rsp), %rdx
movq 0x58(%rdx), %rax
movslq 0x4(%rsp), %rcx
shlq $0x4, %rcx
movss 0x4(%rax,%rcx), %xmm0
subss 0x8(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movl 0x60(%rdx), %edx
leaq 0xc(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl %r14d, %ecx
leaq -0x399(%rip), %r8       # 0x65a3
pushq $0x1
popq %r9
callq 0x65bd
movq %rax, %rbp
movq 0x18(%rsp), %rdx
movq 0x58(%rdx), %rax
movslq 0x4(%rsp), %rcx
shlq $0x4, %rcx
movss 0x4(%rax,%rcx), %xmm0
addss 0x8(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movl 0x60(%rdx), %edx
leaq 0xc(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl %r14d, %ecx
leaq -0x3e0(%rip), %r8       # 0x65a3
xorl %r9d, %r9d
callq 0x65bd
movq %rax, %r12
movq 0x18(%rsp), %rdx
movq 0x58(%rdx), %rax
movslq 0x4(%rsp), %rcx
shlq $0x4, %rcx
movss 0x8(%rax,%rcx), %xmm0
subss 0x8(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movl 0x60(%rdx), %edx
leaq 0xc(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl %r14d, %ecx
leaq -0x426(%rip), %r8       # 0x65a3
pushq $0x1
popq %r9
callq 0x65bd
movq %rax, %r15
movq 0x18(%rsp), %rdx
movq 0x58(%rdx), %rax
movslq 0x4(%rsp), %rcx
shlq $0x4, %rcx
movss 0x8(%rax,%rcx), %xmm0
addss 0x8(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movl 0x60(%rdx), %edx
leaq 0xc(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl %r14d, %ecx
leaq -0x46d(%rip), %r8       # 0x65a3
xorl %r9d, %r9d
callq 0x65bd
movq %rax, %r14
leaq 0xc0(%rsp), %rdi
callq 0x9174
cmpq %rbx, %r13
ja 0x6a4c
movl 0x4(%r13), %esi
leaq 0xc0(%rsp), %rdi
leaq 0xe4(%rsp), %rdx
callq 0x9216
addq $0x8, %r13
jmp 0x6a28
movq 0xb8(%rsp), %r13
leaq 0xc0(%rsp), %rbx
cmpq %r12, %rbp
ja 0x6a87
movl 0x4(%rbp), %esi
movq %rbx, %rdi
callq 0x9472
testq %rax, %rax
je 0x6a81
movl 0x4(%rbp), %esi
movq %rbx, %rdi
leaq 0x3c(%rsp), %rdx
callq 0x9216
addq $0x8, %rbp
jmp 0x6a5c
leaq -0x4eb(%rip), %r12      # 0x65a3
cmpq %r14, %r15
ja 0x6ac0
movl 0x4(%r15), %esi
movq %rbx, %rdi
callq 0x9472
leaq 0x3c(%rsp), %rcx
cmpq %rcx, %rax
jne 0x6aba
movl 0x4(%r15), %esi
movq %rbx, %rdi
leaq 0x38(%rsp), %rdx
callq 0x9216
addq $0x8, %r15
jmp 0x6a8e
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x18(%rsp), %r15
movslq 0xd8(%rsp), %rax
cmpq %rax, %r14
jge 0x6b08
movq 0xd0(%rsp), %rax
leaq 0x38(%rsp), %rcx
cmpq %rcx, (%rax,%rbx,2)
jne 0x6aff
movq 0xc8(%rsp), %rsi
addq %rbx, %rsi
leaq 0x40(%rsp), %rdi
callq 0x6d04
incq %r14
addq $0x4, %rbx
jmp 0x6aca
movq 0x40(%rsp), %rsi
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x48(%rsp), %rax
movq %rax, %rcx
subq %rsi, %rcx
sarq $0x2, %rcx
cmpq %rcx, %r14
jae 0x6b57
movslq (%rsi,%rbx), %rax
cmpb $0x0, (%r13,%rax)
jne 0x6b4e
addq %rbx, %rsi
leaq 0x60(%rsp), %rdi
callq 0x6d04
movq 0x40(%rsp), %rsi
movslq (%rsi,%rbx), %rax
movb $0x1, (%r13,%rax)
incq %r14
addq $0x4, %rbx
jmp 0x6b12
cmpq %rsi, %rax
je 0x6b61
movq %rsi, 0x48(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x91f6
leaq 0xc(%rsp), %rbx
jmp 0x684a
movq 0x88(%rsp), %rax
subq 0x80(%rsp), %rax
sarq $0x2, %rax
cmpq 0xa8(%rsp), %rax
setb %cl
cmpq 0xb0(%rsp), %rax
seta %al
orb %cl, %al
jne 0x6bb8
movq 0x78(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x6d22
movq 0x78(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2d00
leaq 0x60(%rsp), %rdi
callq 0x2d00
leaq 0x80(%rsp), %rdi
callq 0x2d00
cmpq 0xa0(%rsp), %rbx
leaq 0xc(%rsp), %rbx
jae 0x6c10
movl 0x14(%rsp), %r14d
movl 0x60(%r15), %ebp
incl %r14d
jmp 0x67e9
movq 0x30(%rsp), %rdi
callq 0x2270
movq 0x28(%rsp), %rdi
callq 0x2270
movq 0x20(%rsp), %rdi
callq 0x2270
movq %r13, %rdi
callq 0x2270
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6c4e
jmp 0x6c4e
jmp 0x6c4e
movq %rax, %rbx
jmp 0x6c6b
jmp 0x6c5b
jmp 0x6c5b
jmp 0x6c5b
jmp 0x6c5b
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x91f6
leaq 0x40(%rsp), %rdi
callq 0x2d00
leaq 0x60(%rsp), %rdi
callq 0x2d00
leaq 0x80(%rsp), %rdi
callq 0x2d00
movq %rbx, %rdi
callq 0x23b0