// File: /workspace/github_cpp_makefile_star2_O2/ADAPTLab[P]MuDBSCAN/RTree.cpp
// Function: RexpansionArea(region*, RtreeNode*, double*, region*)
Boolean RexpansionArea(Region rgnRect, RTreeNode tnInfo, Double ptrDMinExp, Region rgnNewRect)
{
    int iCnt = 0;
    Region rgnRectTemp = RinitRgnRect(NULL, NULL);
    // assert(rgnRectTemp != 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] = (tnInfo->tdInfo->dataClstElem->iData[iCnt] > rgnRect->iTopRight[iCnt]) ? tnInfo->tdInfo->dataClstElem->iData[iCnt] : rgnRect->iTopRight[iCnt];
			rgnRectTemp->iBottomLeft[iCnt] = (tnInfo->tdInfo->dataClstElem->iData[iCnt] < rgnRect->iBottomLeft[iCnt]) ? tnInfo->tdInfo->dataClstElem->iData[iCnt] : rgnRect->iBottomLeft[iCnt];
			break;
		}
	}
	double dExp = Rarea(rgnRectTemp) - Rarea(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, %r14
movq %rdx, -0x38(%rbp)
movq %rsi, %r13
movq %rdi, %r12
xorl %r15d, %r15d
xorl %edi, %edi
xorl %esi, %esi
callq 0x3c84
movq %rax, %rbx
leaq 0x103bd(%rip), %rax     # 0x14334
movl (%rax), %eax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movq %rcx, -0x30(%rbp)
leaq (,%rcx,8), %rax
xorl %ecx, %ecx
cmpq %r15, %rax
je 0x4022
movl (%r13), %edx
cmpl $0x1, %edx
je 0x3fd5
testl %edx, %edx
jne 0x4016
movq 0x8(%r13), %rdx
movq (%rdx), %rdx
movq 0x8(%rdx), %rsi
movsd (%rsi,%r15), %xmm0
movq 0x8(%r12), %rsi
maxsd (%rsi,%r15), %xmm0
movq 0x8(%rbx), %rsi
movsd %xmm0, (%rsi,%r15)
movq (%rdx), %rdx
addq %r15, %rdx
jmp 0x3fff
movq 0x8(%r13), %rdx
movq 0x8(%rdx), %rdx
movq (%rdx), %rsi
leaq (%rsi,%rcx,8), %rdx
movsd (%rsi,%r15), %xmm0
movq 0x8(%r12), %rsi
maxsd (%rsi,%r15), %xmm0
movq 0x8(%rbx), %rsi
movsd %xmm0, (%rsi,%r15)
movsd (%rdx), %xmm0
movq (%r12), %rdx
minsd (%rdx,%r15), %xmm0
movq (%rbx), %rdx
movsd %xmm0, (%rdx,%r15)
incq %rcx
addq $0x8, %r15
jmp 0x3f91
movq %rbx, %rdi
callq 0x40db
movapd %xmm0, -0x50(%rbp)
movq %r12, %rdi
callq 0x40db
movapd -0x50(%rbp), %xmm2
subsd %xmm0, %xmm2
movq -0x38(%rbp), %rax
movsd (%rax), %xmm0
ucomisd 0xb078(%rip), %xmm0     # 0xf0c8
jne 0x4054
jnp 0x4088
ucomisd %xmm2, %xmm0
jae 0x4088
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, %rdx
je 0x4060
movsd (%rdi,%rax,8), %xmm0
movq (%r14), %rcx
movsd %xmm0, (%rcx,%rax,8)
movq 0x8(%rbx), %rcx
movsd (%rcx,%rax,8), %xmm0
movq 0x8(%r14), %rcx
movsd %xmm0, (%rcx,%rax,8)
incq %rax
jmp 0x40b2