// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq %rsi, %rdi
callq 0x2fae
testl %eax, %eax
je 0x6346
pushq $0x1
popq %rdi
pushq $0x8
popq %rsi
callq 0x2180
movl $0xfffffffb, (%rax)     # imm = 0xFFFFFFFB
jmp 0x6406
addq $0x8, %rbx
xorl %r13d, %r13d
movsd -0x30(%rbp), %xmm0
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x63f1
movq (%rbx), %rax
movl (%rax), %ecx
cmpl $0x1, %ecx
je 0x63a1
testl %ecx, %ecx
jne 0x63e8
movq 0x8(%rax), %rax
movq (%rax), %rdi
movq (%r15), %rsi
callq 0x4e4e
testl %eax, %eax
je 0x63e3
movq 0x8(%rbx), %rsi
movq %r15, %rdi
movq %r14, %rdx
movsd -0x30(%rbp), %xmm0
callq 0x6308
movl (%rax), %ecx
cmpl $-0x1, %ecx
je 0x63d8
cmpl $0x1, %ecx
jne 0x63db
jmp 0x640c
leaq 0xdfc8(%rip), %rcx      # 0x14370
movq (%rcx), %rcx
movq (%rcx), %rcx
movq 0x8(%rax), %rax
movslq 0x8(%rax), %rax
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
callq 0x6233
movl %eax, %r12d
pushq $0x1
popq %rdi
pushq $0x8
popq %rsi
callq 0x2180
cmpl $0x1, %r12d
jne 0x63db
jmp 0x641b
movb $0x1, %r13b
movq %rax, %rdi
callq 0x2280
movsd -0x30(%rbp), %xmm0
addq $0x10, %rbx
jmp 0x6352
pushq $0x1
popq %rdi
pushq $0x8
popq %rsi
callq 0x2180
andb $0x1, %r13b
movzbl %r13b, %ecx
movl %ecx, (%rax)
pushq $-0x1
popq %rcx
movl %ecx, 0x4(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, (%rax)
movq (%rbx), %rcx
movq 0x8(%rcx), %rcx
movl 0x8(%rcx), %ecx
jmp 0x6409