// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %rax
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r12
xorl %edi, %edi
xorl %esi, %esi
callq 0x513c
movq %rax, %rbx
leaq 0x11f3f(%rip), %rax     # 0x17364
movslq (%rax), %rax
testq %rax, %rax
jle 0x5514
movl (%r13), %ecx
leaq (,%rax,8), %rdx
xorl %esi, %esi
xorl %edi, %edi
cmpl $0x1, %ecx
je 0x547d
testl %ecx, %ecx
jne 0x54be
movq 0x8(%r13), %r8
movq (%r8), %r9
movq 0x8(%r9), %r8
movsd (%r8,%rsi), %xmm0
movq 0x8(%r12), %r8
maxsd (%r8,%rsi), %xmm0
movq 0x8(%rbx), %r8
movsd %xmm0, (%r8,%rsi)
leaq (,%rdi,8), %r8
addq (%r9), %r8
jmp 0x54a6
movq 0x8(%r13), %r8
movq 0x8(%r8), %r8
movq (%r8), %r8
movsd (%r8,%rsi), %xmm0
addq %rsi, %r8
movq 0x8(%r12), %r9
maxsd (%r9,%rsi), %xmm0
movq 0x8(%rbx), %r9
movsd %xmm0, (%r9,%rsi)
movsd (%r8), %xmm0
movq (%r12), %r8
minsd (%r8,%rsi), %xmm0
movq (%rbx), %r8
movsd %xmm0, (%r8,%rsi)
incq %rdi
addq $0x8, %rsi
cmpq %rsi, %rdx
jne 0x5441
testl %eax, %eax
setle %cl
xorpd %xmm0, %xmm0
testq %rbx, %rbx
sete %dl
je 0x54e7
movsd 0xcbf9(%rip), %xmm0     # 0x120e0
orb %cl, %dl
jne 0x5527
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
movsd 0xcbe6(%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 0x54fc
jmp 0x5527
testq %rbx, %rbx
je 0x5523
movsd 0xcbbf(%rip), %xmm0     # 0x120e0
jmp 0x5527
xorpd %xmm0, %xmm0
testl %eax, %eax
setle %cl
xorpd %xmm1, %xmm1
testq %r12, %r12
sete %dl
je 0x5540
movsd 0xcba0(%rip), %xmm1     # 0x120e0
orb %cl, %dl
jne 0x556d
movq (%r12), %rcx
movq 0x8(%r12), %rdx
movsd 0xcb8b(%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 0x5557
subsd %xmm1, %xmm0
movsd (%r15), %xmm1
ucomisd 0xcb6a(%rip), %xmm1     # 0x120e8
jne 0x5582
jnp 0x5599
ucomisd %xmm0, %xmm1
jae 0x5599
movq (%rbx), %rdi
callq 0x3310
movq 0x8(%rbx), %r14
xorl %r15d, %r15d
jmp 0x55f9
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 0x55ea
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 0x55cb
jmp 0x55ee
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