// File: ADAPTLab[P]MuDBSCAN/MuC_RTree.cpp
// Function: insertPointintoGroup(group*, data*)
void insertPointintoGroup(Group currGroup, Data currDataPoint)
{
	// Data master = data
	DataPoint d = currGroup->master;

	double dist = distance(currDataPoint->iData, d);
	
	currGroup->total_count++;
	addHelper[0] = currDataPoint->id;

	VECTOR_ADD(currGroup->total_points, addHelper);
	double two = 2;

	if(dist <= EPS/two)
	{
		currGroup->inner_count++;
		addHelper[0] = currDataPoint->id;
		VECTOR_ADD(currGroup->inner_points, addHelper);
	}

	if(currGroup->threshold < dist) currGroup->threshold = dist;

	currDataPoint->group_id = currGroup->id;

	BCell currBCell = currGroup->bcell;
	int x,i;

	if(VECTOR_TOTAL(currGroup->total_points) == 1)
	{
		for(x = 0; x < DIMENSION; x++)
		{
			currBCell->minActualBoundary[x] = currDataPoint->iData[x];
			currBCell->maxActualBoundary[x] = currDataPoint->iData[x];
		}		
	}
	else
	{
		for(i = 0; i< DIMENSION; i++)
		{
			if(currBCell->minActualBoundary[i] > currDataPoint->iData[i])
			{
				currBCell->minActualBoundary[i] = currDataPoint->iData[i];
			}

			if(currBCell->maxActualBoundary[i] < currDataPoint->iData[i])
			{
				currBCell->maxActualBoundary[i] = currDataPoint->iData[i];
			}
		}
	}

	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x16af0
movsd %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
leaq 0x208d4(%rip), %rax     # 0x38800
movq (%rax), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x208c0(%rip), %rax     # 0x38800
movq (%rax), %rsi
callq 0xa6e0
movsd 0x142e8(%rip), %xmm0    # 0x2c238
movsd %xmm0, -0x28(%rbp)
movsd -0x20(%rbp), %xmm1
leaq 0x20867(%rip), %rax     # 0x387c8
movsd (%rax), %xmm0
divsd -0x28(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x17fa7
movq -0x8(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
leaq 0x20875(%rip), %rax     # 0x38800
movq (%rax), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x20861(%rip), %rax     # 0x38800
movq (%rax), %rsi
callq 0xa6e0
movq -0x8(%rbp), %rax
fldt 0x40(%rax)
fldl -0x20(%rbp)
fucompi %st(1), %st
fstp %st(0)
jbe 0x17fc3
jmp 0x17fb9
fldl -0x20(%rbp)
movq -0x8(%rbp), %rax
fstpt 0x40(%rax)
movq -0x8(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xa2b0
cmpl $0x1, %eax
jne 0x18055
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
leaq 0x207d5(%rip), %rcx     # 0x387d4
cmpl (%rcx), %eax
jge 0x18050
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x34(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x17ff5
jmp 0x1810c
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
leaq 0x2076e(%rip), %rcx     # 0x387d4
cmpl (%rcx), %eax
jge 0x1810a
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x180b2
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x180fa
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x180fc
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1805c
jmp 0x1810c
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)