// File: 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
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x170(%rbp)
movslq 0x60(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2040
movq %rax, %rcx
movq -0x170(%rbp), %rax
movq %rcx, -0x38(%rbp)
movslq 0x60(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2040
movq %rax, %rcx
movq -0x170(%rbp), %rax
movq %rcx, -0x40(%rbp)
movslq 0x60(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2040
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x170(%rbp), %rcx
movl -0x4c(%rbp), %eax
cmpl 0x60(%rcx), %eax
jge 0xa16a
movq -0x170(%rbp), %rax
movq 0x58(%rax), %rcx
movl -0x4c(%rbp), %edx
shll $0x2, %edx
movslq %edx, %rdx
movss (%rcx,%rdx,4), %xmm0
movss %xmm0, -0x54(%rbp)
movl -0x4c(%rbp), %ecx
movl %ecx, -0x50(%rbp)
movq -0x38(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
movq -0x54(%rbp), %rsi
movq %rsi, (%rcx,%rdx,8)
movq 0x58(%rax), %rcx
movl -0x4c(%rbp), %edx
shll $0x2, %edx
addl $0x1, %edx
movslq %edx, %rdx
movss (%rcx,%rdx,4), %xmm0
movss %xmm0, -0x5c(%rbp)
movl -0x4c(%rbp), %ecx
movl %ecx, -0x58(%rbp)
movq -0x40(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
movq -0x5c(%rbp), %rsi
movq %rsi, (%rcx,%rdx,8)
movq 0x58(%rax), %rax
movl -0x4c(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x64(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq -0x64(%rbp), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xa0b5
movq -0x170(%rbp), %rax
movq -0x38(%rbp), %rdi
movslq 0x60(%rax), %rsi
movl $0x8, %edx
leaq -0x355(%rip), %rcx      # 0x9e30
callq 0x23b0
movq -0x170(%rbp), %rax
movq -0x40(%rbp), %rdi
movslq 0x60(%rax), %rsi
movl $0x8, %edx
leaq -0x375(%rip), %rcx      # 0x9e30
callq 0x23b0
movq -0x170(%rbp), %rax
movq -0x48(%rbp), %rdi
movslq 0x60(%rax), %rsi
movl $0x8, %edx
leaq -0x395(%rip), %rcx      # 0x9e30
callq 0x23b0
movq -0x170(%rbp), %rax
movslq 0x60(%rax), %rdi
movq %rdi, -0x180(%rbp)
callq 0x2040
movq -0x180(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0x178(%rbp)
xorl %esi, %esi
callq 0x2100
movq -0x178(%rbp), %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movq -0x170(%rbp), %rcx
movl -0x74(%rbp), %eax
cmpl 0x60(%rcx), %eax
jge 0xa911
movq -0x70(%rbp), %rax
movslq -0x74(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0xa231
jmp 0xa8dd
leaq -0x90(%rbp), %rdi
callq 0x3130
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x3130
leaq -0xc0(%rbp), %rdi
callq 0x3130
movq -0x188(%rbp), %rdi
leaq -0x74(%rbp), %rsi
callq 0xae30
jmp 0xa26e
movq -0x70(%rbp), %rax
movslq -0x74(%rbp), %rcx
movb $0x1, (%rax,%rcx)
leaq -0xa8(%rbp), %rdi
callq 0xaca0
cmpq $0x0, %rax
jbe 0xa84c
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0xaca0
movq -0x190(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0xacc0
movq -0x190(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xd0(%rbp)
callq 0xaea0
leaq -0x90(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0xae30
jmp 0xa2de
movq -0x170(%rbp), %rax
movq 0x58(%rax), %rcx
movl -0xd0(%rbp), %edx
shll $0x2, %edx
movslq %edx, %rdx
movss (%rcx,%rdx,4), %xmm0
movss -0x14(%rbp), %xmm1
subss %xmm1, %xmm0
movss %xmm0, -0xd8(%rbp)
movq -0x38(%rbp), %rsi
movl 0x60(%rax), %edx
leaq -0x4e9(%rip), %r8       # 0x9e30
leaq -0xd8(%rbp), %rdi
movl $0x8, %ecx
movl $0x1, %r9d
callq 0x9e90
movq %rax, -0x198(%rbp)
jmp 0xa339
movq -0x170(%rbp), %rax
movq -0x198(%rbp), %rcx
movq %rcx, -0xe0(%rbp)
movq 0x58(%rax), %rcx
movl -0xd0(%rbp), %edx
shll $0x2, %edx
movslq %edx, %rdx
movss (%rcx,%rdx,4), %xmm0
movss -0x14(%rbp), %xmm1
addss %xmm1, %xmm0
movss %xmm0, -0xd8(%rbp)
movq -0x38(%rbp), %rsi
movl 0x60(%rax), %edx
leaq -0x552(%rip), %r8       # 0x9e30
leaq -0xd8(%rbp), %rdi
movl $0x8, %ecx
xorl %r9d, %r9d
callq 0x9e90
movq %rax, -0x1a0(%rbp)
jmp 0xa39f
movq -0x170(%rbp), %rax
movq -0x1a0(%rbp), %rcx
movq %rcx, -0xe8(%rbp)
movq 0x58(%rax), %rcx
movl -0xd0(%rbp), %edx
shll $0x2, %edx
movslq %edx, %rdx
movss 0x4(%rcx,%rdx,4), %xmm0
movss -0x14(%rbp), %xmm1
subss %xmm1, %xmm0
movss %xmm0, -0xd8(%rbp)
movq -0x40(%rbp), %rsi
movl 0x60(%rax), %edx
leaq -0x5b9(%rip), %r8       # 0x9e30
leaq -0xd8(%rbp), %rdi
movl $0x8, %ecx
movl $0x1, %r9d
callq 0x9e90
movq %rax, -0x1a8(%rbp)
jmp 0xa409
movq -0x170(%rbp), %rax
movq -0x1a8(%rbp), %rcx
movq %rcx, -0xf0(%rbp)
movq 0x58(%rax), %rcx
movl -0xd0(%rbp), %edx
shll $0x2, %edx
movslq %edx, %rdx
movss 0x4(%rcx,%rdx,4), %xmm0
movss -0x14(%rbp), %xmm1
addss %xmm1, %xmm0
movss %xmm0, -0xd8(%rbp)
movq -0x40(%rbp), %rsi
movl 0x60(%rax), %edx
leaq -0x623(%rip), %r8       # 0x9e30
leaq -0xd8(%rbp), %rdi
movl $0x8, %ecx
xorl %r9d, %r9d
callq 0x9e90
movq %rax, -0x1b0(%rbp)
jmp 0xa470
movq -0x170(%rbp), %rax
movq -0x1b0(%rbp), %rcx
movq %rcx, -0xf8(%rbp)
movq 0x58(%rax), %rcx
movl -0xd0(%rbp), %edx
shll $0x2, %edx
movslq %edx, %rdx
movss 0x8(%rcx,%rdx,4), %xmm0
movss -0x14(%rbp), %xmm1
subss %xmm1, %xmm0
movss %xmm0, -0xd8(%rbp)
movq -0x48(%rbp), %rsi
movl 0x60(%rax), %edx
leaq -0x68a(%rip), %r8       # 0x9e30
leaq -0xd8(%rbp), %rdi
movl $0x8, %ecx
movl $0x1, %r9d
callq 0x9e90
movq %rax, -0x1b8(%rbp)
jmp 0xa4da
movq -0x170(%rbp), %rax
movq -0x1b8(%rbp), %rcx
movq %rcx, -0x100(%rbp)
movq 0x58(%rax), %rcx
movl -0xd0(%rbp), %edx
shll $0x2, %edx
movslq %edx, %rdx
movss 0x8(%rcx,%rdx,4), %xmm0
movss -0x14(%rbp), %xmm1
addss %xmm1, %xmm0
movss %xmm0, -0xd8(%rbp)
movq -0x48(%rbp), %rsi
movl 0x60(%rax), %edx
leaq -0x6f4(%rip), %r8       # 0x9e30
leaq -0xd8(%rbp), %rdi
movl $0x8, %ecx
xorl %r9d, %r9d
callq 0x9e90
movq %rax, -0x1c0(%rbp)
jmp 0xa541
movq -0x1c0(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x11f90
jmp 0xa55d
movq -0xe0(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
cmpq -0xe8(%rbp), %rax
ja 0xa5ea
movq -0x140(%rbp), %rax
movl 0x4(%rax), %esi
leaq -0x128(%rbp), %rdi
leaq -0x12c(%rbp), %rdx
callq 0x12090
jmp 0xa59a
jmp 0xa59c
movq -0x140(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x140(%rbp)
jmp 0xa56b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0xa8eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x12050
jmp 0xa8eb
movq -0xf0(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rax
cmpq -0xf8(%rbp), %rax
ja 0xa66b
movq -0x148(%rbp), %rax
movl 0x4(%rax), %esi
leaq -0x128(%rbp), %rdi
callq 0x12500
movq %rax, -0x1c8(%rbp)
jmp 0xa627
movq -0x1c8(%rbp), %rax
cmpq $0x0, %rax
je 0xa655
movq -0x148(%rbp), %rax
movl 0x4(%rax), %esi
leaq -0x128(%rbp), %rdi
leaq -0x130(%rbp), %rdx
callq 0x12090
jmp 0xa653
jmp 0xa655
jmp 0xa657
movq -0x148(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x148(%rbp)
jmp 0xa5f8
movq -0x100(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rax
cmpq -0x108(%rbp), %rax
ja 0xa6f2
movq -0x150(%rbp), %rax
movl 0x4(%rax), %esi
leaq -0x128(%rbp), %rdi
callq 0x12500
movq %rax, -0x1d0(%rbp)
jmp 0xa6a8
movq -0x1d0(%rbp), %rax
leaq -0x130(%rbp), %rcx
cmpq %rcx, %rax
jne 0xa6dc
movq -0x150(%rbp), %rax
movl 0x4(%rax), %esi
leaq -0x128(%rbp), %rdi
leaq -0x134(%rbp), %rdx
callq 0x12090
jmp 0xa6da
jmp 0xa6dc
jmp 0xa6de
movq -0x150(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x150(%rbp)
jmp 0xa679
movl $0x0, -0x154(%rbp)
movl -0x154(%rbp), %eax
cmpl -0x110(%rbp), %eax
jge 0xa75a
movq -0x118(%rbp), %rax
movslq -0x154(%rbp), %rcx
leaq -0x134(%rbp), %rdx
cmpq %rdx, (%rax,%rcx,8)
jne 0xa747
movq -0x120(%rbp), %rax
movslq -0x154(%rbp), %rcx
leaq (%rax,%rcx,4), %rsi
leaq -0xc0(%rbp), %rdi
callq 0xae30
jmp 0xa745
jmp 0xa747
jmp 0xa749
movl -0x154(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x154(%rbp)
jmp 0xa6fc
movq $0x0, -0x160(%rbp)
movq -0x160(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xaca0
movq %rax, %rcx
movq -0x1d8(%rbp), %rax
cmpq %rcx, %rax
jae 0xa82f
movq -0x70(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq -0x160(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0xacc0
movq %rax, %rcx
movq -0x1e0(%rbp), %rax
movslq (%rcx), %rcx
testb $0x1, (%rax,%rcx)
jne 0xa816
movq -0x160(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0xacc0
movq %rax, %rsi
leaq -0xa8(%rbp), %rdi
callq 0xae30
jmp 0xa7e7
movq -0x70(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x160(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0xacc0
movq %rax, %rcx
movq -0x1e8(%rbp), %rax
movslq (%rcx), %rcx
movb $0x1, (%rax,%rcx)
jmp 0xa818
movq -0x160(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x160(%rbp)
jmp 0xa765
leaq -0xc0(%rbp), %rdi
callq 0xaed0
leaq -0x128(%rbp), %rdi
callq 0x12050
jmp 0xa27a
leaq -0x90(%rbp), %rdi
callq 0xaca0
cmpq -0x20(%rbp), %rax
jb 0xa884
leaq -0x90(%rbp), %rdi
callq 0xaca0
cmpq -0x28(%rbp), %rax
ja 0xa884
movq -0x10(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xaef0
jmp 0xa882
jmp 0xa884
movq -0x10(%rbp), %rdi
callq 0xa9d0
cmpq -0x30(%rbp), %rax
jb 0xa89f
movl $0x5, -0x164(%rbp)
jmp 0xa8a9
movl $0x0, -0x164(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x31d0
leaq -0xa8(%rbp), %rdi
callq 0x31d0
leaq -0x90(%rbp), %rdi
callq 0x31d0
movl -0x164(%rbp), %eax
testl %eax, %eax
je 0xa8db
jmp 0xa8d9
jmp 0xa911
jmp 0xa8dd
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0xa20b
leaq -0xc0(%rbp), %rdi
callq 0x31d0
leaq -0xa8(%rbp), %rdi
callq 0x31d0
leaq -0x90(%rbp), %rdi
callq 0x31d0
jmp 0xa98e
movq -0x38(%rbp), %rax
movq %rax, -0x1f0(%rbp)
cmpq $0x0, %rax
je 0xa92e
movq -0x1f0(%rbp), %rdi
callq 0x2250
movq -0x40(%rbp), %rax
movq %rax, -0x1f8(%rbp)
cmpq $0x0, %rax
je 0xa94b
movq -0x1f8(%rbp), %rdi
callq 0x2250
movq -0x48(%rbp), %rax
movq %rax, -0x200(%rbp)
cmpq $0x0, %rax
je 0xa968
movq -0x200(%rbp), %rdi
callq 0x2250
movq -0x70(%rbp), %rax
movq %rax, -0x208(%rbp)
cmpq $0x0, %rax
je 0xa985
movq -0x208(%rbp), %rdi
callq 0x2250
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq -0xc8(%rbp), %rdi
callq 0x2380
nopw (%rax,%rax)