// File: /workspace/github_cpp_makefile_star2_O3/ADAPTLab[P]MuDBSCAN/MuC_RTree.cpp
// Function: GexpansionArea(region*, GtreeNode*, double*, region*)
Boolean GexpansionArea(Region rgnRect, GTreeNode tnInfo, Double ptrDMinExp, Region rgnNewRect)
{
    int iCnt = 0;
    Region rgnRectTemp = GinitRgnRect(NULL, NULL);

    for(iCnt = 0; iCnt < DIMENSION; iCnt++)
    {   
    	switch(tnInfo->ndType)
        {   
        	case INTNODE:
				rgnRectTemp->iTopRight[iCnt] = (tnInfo->tdInfo->rgnRect->iTopRight[iCnt] > rgnRect->iTopRight[iCnt]) ? tnInfo->tdInfo->rgnRect->iTopRight[iCnt] : rgnRect->iTopRight[iCnt];
				rgnRectTemp->iBottomLeft[iCnt] = (tnInfo->tdInfo->rgnRect->iBottomLeft[iCnt] < rgnRect->iBottomLeft[iCnt]) ? tnInfo->tdInfo->rgnRect->iBottomLeft[iCnt] : rgnRect->iBottomLeft[iCnt];
	            break;

		    case EXTNODE:
				rgnRectTemp->iTopRight[iCnt] = (groupList->groupItems[tnInfo->tdInfo->groupElem]->bcell->maxOriginalBoundary[iCnt] > rgnRect->iTopRight[iCnt]) ? groupList->groupItems[tnInfo->tdInfo->groupElem]->bcell->maxOriginalBoundary[iCnt] : rgnRect->iTopRight[iCnt];
				rgnRectTemp->iBottomLeft[iCnt] = (groupList->groupItems[tnInfo->tdInfo->groupElem]->bcell->minOriginalBoundary[iCnt] < rgnRect->iBottomLeft[iCnt]) ? groupList->groupItems[tnInfo->tdInfo->groupElem]->bcell->minOriginalBoundary[iCnt] : rgnRect->iBottomLeft[iCnt];
				break;
		}
	}

	double dExp = Garea(rgnRectTemp) - Garea(rgnRect);

	if(*ptrDMinExp == -1 || dExp <= *ptrDMinExp)
    {   if(dExp == *ptrDMinExp)
			*ptrDMinExp = 0 - dExp;
		else
			*ptrDMinExp = dExp;
        for(iCnt =0; iCnt< DIMENSION; iCnt++)
        {	rgnNewRect->iBottomLeft[iCnt] = rgnRectTemp->iBottomLeft[iCnt];
			rgnNewRect->iTopRight[iCnt] = rgnRectTemp->iTopRight[iCnt];
		}
		free(rgnRectTemp->iBottomLeft);
		free(rgnRectTemp->iTopRight);
		free(rgnRectTemp);

		return TRUE;
	}

	free(rgnRectTemp->iBottomLeft);
	free(rgnRectTemp->iTopRight);
	free(rgnRectTemp);

	return FALSE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r12
xorl %edi, %edi
xorl %esi, %esi
callq 0x68bb
movq %rax, %rbx
leaq 0x1068e(%rip), %rax     # 0x17364
movslq (%rax), %rax
testq %rax, %rax
jle 0x6d9d
movl (%r13), %ecx
leaq 0x106b3(%rip), %rdx     # 0x173a0
movq (%rdx), %rdx
xorl %esi, %esi
cmpl $0x1, %ecx
je 0x6d01
testl %ecx, %ecx
jne 0x6d4f
movq 0x8(%r13), %rdi
jmp 0x6d14
movq (%rdx), %rdi
movq 0x8(%r13), %r8
movslq 0x8(%r8), %r8
movq (%rdi,%r8,8), %rdi
addq $0x38, %rdi
movq (%rdi), %rdi
movq 0x8(%rdi), %r8
movsd (%r8,%rsi,8), %xmm0
movq 0x8(%r12), %r8
maxsd (%r8,%rsi,8), %xmm0
movq 0x8(%rbx), %r8
movsd %xmm0, (%r8,%rsi,8)
movq (%rdi), %rdi
movsd (%rdi,%rsi,8), %xmm0
movq (%r12), %rdi
minsd (%rdi,%rsi,8), %xmm0
movq (%rbx), %rdi
movsd %xmm0, (%rdi,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x6cf2
testl %eax, %eax
setle %cl
xorpd %xmm0, %xmm0
testq %rbx, %rbx
sete %dl
je 0x6d70
movsd 0xb370(%rip), %xmm0     # 0x120e0
orb %cl, %dl
jne 0x6db0
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
movsd 0xb35d(%rip), %xmm0     # 0x120e0
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm1
subsd (%rcx,%rsi,8), %xmm1
mulsd %xmm1, %xmm0
incq %rsi
cmpq %rsi, %rax
jne 0x6d85
jmp 0x6db0
testq %rbx, %rbx
je 0x6dac
movsd 0xb336(%rip), %xmm0     # 0x120e0
jmp 0x6db0
xorpd %xmm0, %xmm0
testl %eax, %eax
setle %cl
xorpd %xmm1, %xmm1
testq %r12, %r12
sete %dl
je 0x6dc9
movsd 0xb317(%rip), %xmm1     # 0x120e0
orb %cl, %dl
jne 0x6df6
movq (%r12), %rcx
movq 0x8(%r12), %rdx
movsd 0xb302(%rip), %xmm1     # 0x120e0
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm2
subsd (%rcx,%rsi,8), %xmm2
mulsd %xmm2, %xmm1
incq %rsi
cmpq %rsi, %rax
jne 0x6de0
subsd %xmm1, %xmm0
movsd (%r15), %xmm1
ucomisd 0xb2e1(%rip), %xmm1     # 0x120e8
jne 0x6e0b
jnp 0x6e22
ucomisd %xmm0, %xmm1
jae 0x6e22
movq (%rbx), %rdi
callq 0x3310
movq 0x8(%rbx), %r14
xorl %r15d, %r15d
jmp 0x6e82
xorpd %xmm2, %xmm2
subsd %xmm0, %xmm2
cmpeqsd %xmm0, %xmm1
andpd %xmm1, %xmm2
andnpd %xmm0, %xmm1
orpd %xmm2, %xmm1
movlpd %xmm1, (%r15)
movq (%rbx), %rdi
testl %eax, %eax
jle 0x6e73
movq (%r14), %rcx
movq 0x8(%r14), %rdx
movq 0x8(%rbx), %r14
xorl %esi, %esi
movsd (%rdi,%rsi,8), %xmm0
movsd %xmm0, (%rcx,%rsi,8)
movsd (%r14,%rsi,8), %xmm0
movsd %xmm0, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x6e54
jmp 0x6e77
movq 0x8(%rbx), %r14
callq 0x3310
movl $0x1, %r15d
movq %r14, %rdi
callq 0x3310
movq %rbx, %rdi
callq 0x3310
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq