// File: /workspace/github_cpp_makefile_star2_O2/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
subq $0x28, %rsp
movq %rcx, -0x30(%rbp)
movq %rdx, -0x38(%rbp)
movq %rsi, %r13
movq %rdi, %r12
xorl %r14d, %r14d
xorl %edi, %edi
xorl %esi, %esi
callq 0x51a5
movq %rax, %rbx
leaq 0xede4(%rip), %rax      # 0x14334
movl (%rax), %ecx
leaq 0xee17(%rip), %rax      # 0x14370
movq (%rax), %rax
testl %ecx, %ecx
movl $0x0, %r15d
cmovgl %ecx, %r15d
cmpq %r14, %r15
je 0x55d6
movl (%r13), %ecx
cmpl $0x1, %ecx
je 0x5580
testl %ecx, %ecx
jne 0x55d1
movq 0x8(%r13), %rcx
jmp 0x5593
movq (%rax), %rcx
movq 0x8(%r13), %rdx
movslq 0x8(%rdx), %rdx
movq (%rcx,%rdx,8), %rcx
addq $0x38, %rcx
movq (%rcx), %rcx
movq 0x8(%rcx), %rdx
movsd (%rdx,%r14,8), %xmm0
movq 0x8(%r12), %rdx
maxsd (%rdx,%r14,8), %xmm0
movq 0x8(%rbx), %rdx
movsd %xmm0, (%rdx,%r14,8)
movq (%rcx), %rcx
movsd (%rcx,%r14,8), %xmm0
movq (%r12), %rcx
minsd (%rcx,%r14,8), %xmm0
movq (%rbx), %rcx
movsd %xmm0, (%rcx,%r14,8)
incq %r14
jmp 0x5568
movq %rbx, %rdi
callq 0x568f
movapd %xmm0, -0x50(%rbp)
movq %r12, %rdi
callq 0x568f
movapd -0x50(%rbp), %xmm2
subsd %xmm0, %xmm2
movq -0x38(%rbp), %rax
movsd (%rax), %xmm0
ucomisd 0x9ac4(%rip), %xmm0     # 0xf0c8
jne 0x5608
jnp 0x563c
ucomisd %xmm2, %xmm0
jae 0x563c
movq (%rbx), %rdi
xorl %r12d, %r12d
callq 0x2280
movq 0x8(%rbx), %rdi
callq 0x2280
movq %rbx, %rdi
callq 0x2280
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorpd %xmm1, %xmm1
subsd %xmm2, %xmm1
cmpeqsd %xmm2, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movlpd %xmm0, (%rax)
movq (%rbx), %rdi
xorl %eax, %eax
pushq $0x1
popq %r12
movq -0x30(%rbp), %rdx
cmpq %rax, %r15
je 0x5614
movsd (%rdi,%rax,8), %xmm0
movq (%rdx), %rcx
movsd %xmm0, (%rcx,%rax,8)
movq 0x8(%rbx), %rcx
movsd (%rcx,%rax,8), %xmm0
movq 0x8(%rdx), %rcx
movsd %xmm0, (%rcx,%rax,8)
incq %rax
jmp 0x5666