// File: /workspace/github_cpp_makefile_star2_O1/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 0x68ff
movq %rax, %rbx
leaq 0x1063d(%rip), %rax     # 0x17364
movslq (%rax), %rax
testq %rax, %rax
jle 0x6da4
movl (%r13), %ecx
leaq 0x10666(%rip), %rdx     # 0x173a0
movq (%rdx), %rdx
xorl %esi, %esi
cmpl $0x1, %ecx
je 0x6d4e
testl %ecx, %ecx
jne 0x6d9c
movq 0x8(%r13), %rdi
jmp 0x6d61
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 0x6d3f
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
testq %rbx, %rbx
je 0x6de6
testl %eax, %eax
jle 0x6dde
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
movsd 0xb31c(%rip), %xmm0     # 0x120e0
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm2
subsd (%rcx,%rsi,8), %xmm2
mulsd %xmm2, %xmm0
incq %rsi
cmpq %rsi, %rax
jne 0x6dc6
jmp 0x6de6
movsd 0xb2fa(%rip), %xmm0     # 0x120e0
testq %r12, %r12
je 0x6e22
testl %eax, %eax
jle 0x6e1a
movq (%r12), %rcx
movq 0x8(%r12), %rdx
movsd 0xb2e0(%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 0x6e02
jmp 0x6e22
movsd 0xb2be(%rip), %xmm1     # 0x120e0
subsd %xmm1, %xmm0
movsd (%r15), %xmm1
ucomisd 0xb2b5(%rip), %xmm1     # 0x120e8
jne 0x6e37
jnp 0x6e40
xorl %r12d, %r12d
ucomisd %xmm0, %xmm1
jb 0x6e99
xorpd %xmm2, %xmm2
subsd %xmm0, %xmm2
cmpeqsd %xmm0, %xmm1
andpd %xmm1, %xmm2
andnpd %xmm0, %xmm1
orpd %xmm2, %xmm1
movlpd %xmm1, (%r15)
movl $0x1, %r12d
testl %eax, %eax
jle 0x6e99
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
movq (%r14), %rsi
movq 0x8(%r14), %rdi
xorl %r8d, %r8d
movsd (%rcx,%r8,8), %xmm0
movsd %xmm0, (%rsi,%r8,8)
movsd (%rdx,%r8,8), %xmm0
movsd %xmm0, (%rdi,%r8,8)
incq %r8
cmpq %r8, %rax
jne 0x6e79
movq (%rbx), %rdi
callq 0x3310
movq 0x8(%rbx), %rdi
callq 0x3310
movq %rbx, %rdi
callq 0x3310
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq