// File: /workspace/github_cpp_makefile_star2_O3/ADAPTLab[P]MuDBSCAN/MuC_RTree.cpp
// Function: GcanAssign2(data*, GhdrNd*, region*, double)
Assign GcanAssign2(Data currDataPoint, GHdrNd hdrNdTree, Region x2rgnRect, double eps)
{
	Assign assignStruct;

	// if(GisLstEmpty(hdrNdTree) || rgnRect == NULL || rgnRect->iBottomLeft == NULL || rgnRect->iTopRight == NULL)
	if(GisLstEmpty(hdrNdTree))
	{
		assignStruct = (Assign)calloc(1, sizeof(struct assign));
		// assert(assignStruct != NULL);
		assignStruct->canBeAssigned = -5;
		assignStruct->groupid = -1;
		return assignStruct;
	}
 	
 	unsigned int uiRecCnt = 0;
	int iCnt = 0;
    double t;
    static int flag = 0;
	GLstNd lstNdTemp = hdrNdTree->ptrFirstNd;
	int aflag = -2;
	bool eps2 = 0;

	// Assign assignStruct;
	while(lstNdTemp != NULL)
    {	
    	int assignflag;
		switch(lstNdTemp->tnInfo->ndType)
        {   
        	case INTNODE:   

	            if(RisContains(lstNdTemp->tnInfo->tdInfo->rgnRect, currDataPoint->iData))
	            // if(GisOverLap(, x2rgnRect))
	            {
	            	assignStruct = GcanAssign2(currDataPoint, lstNdTemp->ptrChildLst, x2rgnRect, eps);
	            	if(assignStruct->canBeAssigned==1)
	            	{
            			return assignStruct;
	            	}
	            	else if(assignStruct->canBeAssigned==-1)
	            	{
	            		eps2 = -1;
	            	}
            		free(assignStruct);
	          	}              
            break;

            case EXTNODE:  
            	// fprintf(stderr, "%lf\n", eps); 
				aflag = GisEpsDistant(x2rgnRect, groupList->groupItems[lstNdTemp->tnInfo->tdInfo->groupElem], eps);
				assignStruct = (Assign)calloc(1, sizeof(struct assign));
				// assert(assignStruct != NULL);
				if(aflag == 1)
				{
					assignStruct->canBeAssigned = 1;
					assignStruct->groupid = lstNdTemp->tnInfo->tdInfo->groupElem;
					return assignStruct;
				}
				free(assignStruct);        				    				
            break;
		}

		lstNdTemp = lstNdTemp->ptrNextNd;
	}

	//When eps2=0 it means that there is no group in which this point can be put but you can create a group for this point.
	//When eps=-1 it means that there is no group in which this point can be put and this point will go into the unassigned list.

	assignStruct = (Assign)calloc(1, sizeof(struct assign));
	// assert(assignStruct != NULL);
	assignStruct->canBeAssigned = eps2;
	assignStruct->groupid = -1;

	return assignStruct;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movsd %xmm0, -0x30(%rbp)
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %rdi
callq 0x4299
testl %eax, %eax
je 0x7d0c
movl $0x1, %edi
movl $0x8, %esi
callq 0x31b0
movl $0xfffffffb, (%rax)     # imm = 0xFFFFFFFB
jmp 0x7de0
movq 0x8(%r15), %r12
testq %r12, %r12
je 0x7dcd
xorl %r13d, %r13d
movsd -0x30(%rbp), %xmm0
movq (%r12), %rax
movl (%rax), %ecx
cmpl $0x1, %ecx
je 0x7d6a
testl %ecx, %ecx
jne 0x7db5
movq 0x8(%rax), %rax
movq (%rax), %rdi
movq (%r14), %rsi
callq 0x6555
testl %eax, %eax
je 0x7db0
movq 0x8(%r12), %rsi
movq %r14, %rdi
movq %rbx, %rdx
movsd -0x30(%rbp), %xmm0
callq 0x7cca
movl (%rax), %ecx
cmpl $-0x1, %ecx
je 0x7da5
cmpl $0x1, %ecx
jne 0x7da8
jmp 0x7de8
leaq 0xf62f(%rip), %rcx      # 0x173a0
movq (%rcx), %rcx
movq (%rcx), %rcx
movq 0x8(%rax), %rax
movslq 0x8(%rax), %rax
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
callq 0x7b75
movl %eax, %r15d
movl $0x1, %edi
movl $0x8, %esi
callq 0x31b0
cmpl $0x1, %r15d
jne 0x7da8
jmp 0x7df7
movb $0x1, %r13b
movq %rax, %rdi
callq 0x3310
movsd -0x30(%rbp), %xmm0
movq 0x10(%r12), %r12
testq %r12, %r12
jne 0x7d21
andb $0x1, %r13b
movzbl %r13b, %ebx
jmp 0x7dcf
xorl %ebx, %ebx
movl $0x1, %edi
movl $0x8, %esi
callq 0x31b0
movl %ebx, (%rax)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %ecx, 0x4(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, (%rax)
movq (%r12), %rcx
movq 0x8(%rcx), %rcx
movl 0x8(%rcx), %ecx
jmp 0x7de5