// File: ADAPTLab[P]MuDBSCAN/MuC_RTree.cpp
// Function: findNeighbours3(dataHdr*, int, double, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>*)
Neighbours findNeighbours3(DataHdr dataList, int pointid, double eps, vector < vector <int > >* p_cur_insert)
{

	findNeighbourCount++;
	Data point = dataList->dataClstElem + pointid;

	// if(point->haloPoint == TRUE)
	// {
	// 	fprintf(stderr, "Unexpected condition! FindNeighbours called on Remote Point!");
	// 	exit(-1);
	// }

	Group group = groupList->groupItems[point->group_id];

	Neighbours n = (Neighbours)calloc(1, sizeof(struct neighbours));
	// assert(n != NULL);
	
	n->id = pointid;

	n->neighbours_local_outer = (vectorc*)malloc(sizeof(struct vectorc));
	// assert(n->neighbours_local != NULL);
	VECTOR_INIT(n->neighbours_local_outer, INTEGER);

	n->neighbours_remote_outer = (vectorc*)malloc(sizeof(struct vectorc));
	// assert(n->neighbours_remote != NULL);
	VECTOR_INIT(n->neighbours_remote_outer, INTEGER);

	n->neighbours_local_inner=(vectorc*)malloc(sizeof(struct vectorc));
	// assert(n->neighbours_local_distance != NULL);
	VECTOR_INIT(n->neighbours_local_inner, INTEGER);

	n->neighbours_remote_inner = (vectorc*)malloc(sizeof(struct vectorc));
	// assert(n->neighbours_remote_distance != NULL);
	VECTOR_INIT(n->neighbours_remote_inner, INTEGER);

	Region region = createCellRegOfPoint(point, eps);
	Region potentialRegion;

	int inner_neighbours = 0;
	int total_neighbours = 0;
	double two = 2;
	Data temp;

	int i=0, j=0;

	//FIRST SEARCH FOR NEIGHBOURS IN THE PRESENT GROUP.
	RHdrNd hdrNdTree = group->bcell->auxCellRTree;
	findNeighboursGroup(hdrNdTree, region, point, n, eps);
	int p;
	i=0;

	// if(VECTOR_TOTAL(n->neighbours_local) != VECTOR_TOTAL(n->neighbours_local_distance) || VECTOR_TOTAL(n->neighbours_remote) != VECTOR_TOTAL(n->neighbours_remote_distance))
	// {
	// 	fprintf(stderr, "findNeighbours3 doesn't not conform to the standard!\n");
	// 	exit(-1);
	// }

	//THEN SEARCH FOR NEIGHBOURS IN THE FILTERED REACHABLE GROUPS
	Group reachableGroup,filteredGroup;
	DataPoint d;
	for(i=0; i<VECTOR_TOTAL(group->reachable_groups); i++)
	{
		int id = group->reachable_groups->intItems[i];
		Group reachableGroup = groupList->groupItems[id];
		DataPoint d = (dataList->dataClstElem + reachableGroup->master_id)->iData;
		potentialRegion = createCellRegOfDataPoint(d, eps);

		if(GisOverLap(region, potentialRegion))
		{
			filteredGroup = groupList->groupItems[id];
			j=0;
			hdrNdTree = filteredGroup->bcell->auxCellRTree;
			findNeighboursGroup(hdrNdTree, region, point, n, eps);
		}

		free(potentialRegion->iBottomLeft);
		free(potentialRegion->iTopRight);
		free(potentialRegion);
	}

	inner_neighbours = VECTOR_TOTAL(n->neighbours_remote_inner) + VECTOR_TOTAL(n->neighbours_local_inner);
	total_neighbours = VECTOR_TOTAL(n->neighbours_remote_outer) + VECTOR_TOTAL(n->neighbours_local_outer) + inner_neighbours;

	if(inner_neighbours >= MINPOINTS)
	{
		if(point->haloPoint == FALSE && point->core_tag == FALSE) totalCore++;

		point->core_tag = TRUE;
		point->ClusterID = 1;
		point->isProcessed = TRUE;

		Group g = groupList->groupItems[point->group_id];

		if(visited[point->id] != 1)
        {
            visited[point->id] = 1;
            addHelper[0] = point->id;
            VECTOR_ADD(g->corepoints, addHelper);
            VECTOR_ADD(unprocessedCore, addHelper);
        }

        int root = point->id;
        Data data;
        Data dataroot1;
        Data dataroot2;
        for(i=0;i<VECTOR_TOTAL(n->neighbours_local_inner);i++)
        {
			data = dataList->dataClstElem + n->neighbours_local_inner->intItems[i];
			if(data->haloPoint == FALSE && data->core_tag == FALSE) totalCore++;
			
			data->core_tag = TRUE;
			data->isProcessed = TRUE;
			data->ClusterID = 1;
			
			g = groupList->groupItems[data->group_id];

			if(visited[data->id] != 1)
        	{
                visited[data->id] = 1;
                addHelper[0] = data->id;
                VECTOR_ADD(g->corepoints, addHelper);
              	VECTOR_ADD(unprocessedCore, addHelper);
        	}

        	int root1 = data->id;
			int root2 = root;

			dataroot1 = dataList->dataClstElem + root1;
            dataroot2 = dataList->dataClstElem + root2;

			unionFindMerge(dataList, root1, root2, dataroot1, dataroot2);
        }

        for(i=0;i<VECTOR_TOTAL(n->neighbours_local_outer);i++)
        {
        	data = dataList->dataClstElem + n->neighbours_local_outer->intItems[i];

			if(data->ClusterID == 0 || data->core_tag == TRUE)
			{
				int root1 = data->id;
				int root2 = root;
				data->ClusterID = 1;
				dataroot1 = dataList->dataClstElem + root1;
                dataroot2 = dataList->dataClstElem + root2;

                unionFindMerge(dataList, root1, root2, dataroot1, dataroot2);
                // REMS algorithm to (union) merge the trees
                // UNION OPERATION
			}
        }

        Data dataremote;
        for(i=0;i<VECTOR_TOTAL(n->neighbours_remote_inner);i++)
        {
        	data = dataList->dataClstElem + n->neighbours_remote_inner->intItems[i];

			if(visited[data->id] != 1)
        	{
                visited[data->id] = 1;
                addHelper[0] = data->id;
                VECTOR_ADD(g->corepoints, addHelper);
              	VECTOR_ADD(unprocessedCore, addHelper);
        	}

			data->core_tag = TRUE;
			data->isProcessed = TRUE;
			data->ClusterID = 1;

			Data dataremote = data;
            (*p_cur_insert)[dataremote->actualProcessId].push_back(point->id);
            (*p_cur_insert)[dataremote->actualProcessId].push_back(dataremote->remoteIndex);
        }


        for(i=0;i<VECTOR_TOTAL(n->neighbours_remote_outer);i++)
        {
        	Data data = dataList->dataClstElem + n->neighbours_remote_outer->intItems[i];

			data->ClusterID = 1;
			dataremote = data;
            (*p_cur_insert)[dataremote->actualProcessId].push_back(point->id);
            (*p_cur_insert)[dataremote->actualProcessId].push_back(dataremote->remoteIndex);
		}
	}

	if(total_neighbours >= MINPOINTS)
	{
		Group g = groupList->groupItems[point->group_id];

		if(point->haloPoint == FALSE && point->core_tag == FALSE) totalCore++;
		
		point->core_tag = TRUE;
		point->ClusterID = 1;

		if(visited[point->id] != 1)
        {
	        visited[point->id] = 1;
	        addHelper[0] = point->id;
	        VECTOR_ADD(g->corepoints, addHelper);
            VECTOR_ADD(unprocessedCore, addHelper);
	    }
	}

	free(region->iBottomLeft);
	free(region->iTopRight);
	free(region);

	return n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movsd %xmm0, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
leaq 0x2172a(%rip), %rax     # 0x3883c
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x2171e(%rip), %rax     # 0x3883c
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0xc(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x216d2(%rip), %rax     # 0x38810
movq (%rax), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movslq 0x20(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movl $0x1, %edi
movl $0x30, %esi
callq 0x9400
movq %rax, -0x38(%rbp)
movl -0xc(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movl $0x30, %edi
callq 0x9910
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
xorl %esi, %esi
callq 0xa170
movl $0x30, %edi
callq 0x9910
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
xorl %esi, %esi
callq 0xa170
movl $0x30, %edi
callq 0x9910
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
xorl %esi, %esi
callq 0xa170
movl $0x30, %edi
callq 0x9910
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
callq 0xa170
movq -0x28(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
callq 0x17b40
movq %rax, -0x40(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movsd 0x15010(%rip), %xmm0    # 0x2c238
movsd %xmm0, -0x58(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x38(%rbp), %rcx
movsd -0x18(%rbp), %xmm0
callq 0x16e90
movl $0x0, -0x64(%rbp)
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x104(%rbp)
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0xa2b0
movl %eax, %ecx
movl -0x104(%rbp), %eax
cmpl %ecx, %eax
jge 0x1739f
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rax
movslq -0x64(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x94(%rbp)
leaq 0x21557(%rip), %rax     # 0x38810
movq (%rax), %rax
movq (%rax), %rax
movslq -0x94(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xa0(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0xa0(%rbp), %rcx
movslq 0x30(%rcx), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
callq 0x17c20
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x148f0
cmpl $0x0, %eax
je 0x1736f
leaq 0x214ed(%rip), %rax     # 0x38810
movq (%rax), %rax
movq (%rax), %rax
movslq -0x94(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x88(%rbp)
movl $0x0, -0x68(%rbp)
movq -0x88(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x38(%rbp), %rcx
movsd -0x18(%rbp), %xmm0
callq 0x16e90
movq -0x48(%rbp), %rax
movq (%rax), %rdi
callq 0x97c0
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x97c0
movq -0x48(%rbp), %rdi
callq 0x97c0
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x17273
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xa2b0
movl %eax, -0x10c(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xa2b0
movl %eax, %ecx
movl -0x10c(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xa2b0
movl %eax, -0x108(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0xa2b0
movl %eax, %ecx
movl -0x108(%rbp), %eax
addl %ecx, %eax
addl -0x4c(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
leaq 0x213ca(%rip), %rcx     # 0x387d0
cmpl (%rcx), %eax
jl 0x17a18
movq -0x28(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x17437
movq -0x28(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x17437
leaq 0x2141f(%rip), %rax     # 0x38848
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x21413(%rip), %rax     # 0x38848
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x30(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x2c(%rax)
leaq 0x213b1(%rip), %rax     # 0x38810
movq (%rax), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movslq 0x20(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xb0(%rbp)
leaq 0x213a1(%rip), %rax     # 0x38820
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
cmpl $0x1, (%rax,%rcx,4)
je 0x174ef
leaq 0x21389(%rip), %rax     # 0x38820
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %ecx
leaq 0x21349(%rip), %rax     # 0x38800
movq (%rax), %rax
movl %ecx, (%rax)
movq -0xb0(%rbp), %rax
movq 0x58(%rax), %rdi
leaq 0x21332(%rip), %rax     # 0x38800
movq (%rax), %rsi
callq 0xa6e0
leaq 0x21373(%rip), %rax     # 0x38850
movq (%rax), %rdi
leaq 0x21319(%rip), %rax     # 0x38800
movq (%rax), %rsi
callq 0xa6e0
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0xb4(%rbp)
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x110(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xa2b0
movl %eax, %ecx
movl -0x110(%rbp), %eax
cmpl %ecx, %eax
jge 0x176d6
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq 0x8(%rcx), %rcx
movslq -0x64(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x17582
movq -0xc0(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x17582
leaq 0x212d4(%rip), %rax     # 0x38848
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x212c8(%rip), %rax     # 0x38848
movl %ecx, (%rax)
movq -0xc0(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0xc0(%rbp), %rax
movl $0x1, 0x2c(%rax)
movq -0xc0(%rbp), %rax
movl $0x1, 0x30(%rax)
leaq 0x2125d(%rip), %rax     # 0x38810
movq (%rax), %rax
movq (%rax), %rax
movq -0xc0(%rbp), %rcx
movslq 0x20(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xb0(%rbp)
leaq 0x2124a(%rip), %rax     # 0x38820
movq (%rax), %rax
movq -0xc0(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
cmpl $0x1, (%rax,%rcx,4)
je 0x1764f
leaq 0x2122f(%rip), %rax     # 0x38820
movq (%rax), %rax
movq -0xc0(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0xc0(%rbp), %rax
movl 0x1c(%rax), %ecx
leaq 0x211e9(%rip), %rax     # 0x38800
movq (%rax), %rax
movl %ecx, (%rax)
movq -0xb0(%rbp), %rax
movq 0x58(%rax), %rdi
leaq 0x211d2(%rip), %rax     # 0x38800
movq (%rax), %rsi
callq 0xa6e0
leaq 0x21213(%rip), %rax     # 0x38850
movq (%rax), %rdi
leaq 0x211b9(%rip), %rax     # 0x38800
movq (%rax), %rsi
callq 0xa6e0
movq -0xc0(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0xd4(%rbp)
movl -0xb4(%rbp), %eax
movl %eax, -0xd8(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0xd4(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0xd8(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0x8(%rbp), %rdi
movl -0xd4(%rbp), %esi
movl -0xd8(%rbp), %edx
movq -0xc8(%rbp), %rcx
movq -0xd0(%rbp), %r8
callq 0xf1b0
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x17503
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x114(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0xa2b0
movl %eax, %ecx
movl -0x114(%rbp), %eax
cmpl %ecx, %eax
jge 0x177e2
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq 0x8(%rcx), %rcx
movslq -0x64(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
cmpl $0x0, 0x30(%rax)
je 0x1774b
movq -0xc0(%rbp), %rax
cmpl $0x1, 0x28(%rax)
jne 0x177d2
movq -0xc0(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0xdc(%rbp)
movl -0xb4(%rbp), %eax
movl %eax, -0xe0(%rbp)
movq -0xc0(%rbp), %rax
movl $0x1, 0x30(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0xdc(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0xe0(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0x8(%rbp), %rdi
movl -0xdc(%rbp), %esi
movl -0xe0(%rbp), %edx
movq -0xc8(%rbp), %rcx
movq -0xd0(%rbp), %r8
callq 0xf1b0
jmp 0x177d4
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x176dd
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x118(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xa2b0
movl %eax, %ecx
movl -0x118(%rbp), %eax
cmpl %ecx, %eax
jge 0x1794a
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%rcx), %rcx
movslq -0x64(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
leaq 0x20fe0(%rip), %rax     # 0x38820
movq (%rax), %rax
movq -0xc0(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
cmpl $0x1, (%rax,%rcx,4)
je 0x178b9
leaq 0x20fc5(%rip), %rax     # 0x38820
movq (%rax), %rax
movq -0xc0(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0xc0(%rbp), %rax
movl 0x1c(%rax), %ecx
leaq 0x20f7f(%rip), %rax     # 0x38800
movq (%rax), %rax
movl %ecx, (%rax)
movq -0xb0(%rbp), %rax
movq 0x58(%rax), %rdi
leaq 0x20f68(%rip), %rax     # 0x38800
movq (%rax), %rsi
callq 0xa6e0
leaq 0x20fa9(%rip), %rax     # 0x38850
movq (%rax), %rdi
leaq 0x20f4f(%rip), %rax     # 0x38800
movq (%rax), %rsi
callq 0xa6e0
movq -0xc0(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0xc0(%rbp), %rax
movl $0x1, 0x2c(%rax)
movq -0xc0(%rbp), %rax
movl $0x1, 0x30(%rax)
movq -0xc0(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rdi
movq -0xf0(%rbp), %rax
movslq 0xc(%rax), %rsi
callq 0x11a90
movq %rax, %rdi
movq -0x28(%rbp), %rsi
addq $0x1c, %rsi
callq 0x11ab0
movq -0x20(%rbp), %rdi
movq -0xf0(%rbp), %rax
movslq 0xc(%rax), %rsi
callq 0x11a90
movq %rax, %rdi
movq -0xf0(%rbp), %rsi
addq $0x10, %rsi
callq 0x11ab0
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x177e9
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x11c(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xa2b0
movl %eax, %ecx
movl -0x11c(%rbp), %eax
cmpl %ecx, %eax
jge 0x17a16
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq 0x8(%rcx), %rcx
movslq -0x64(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movl $0x1, 0x30(%rax)
movq -0xf8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x20(%rbp), %rdi
movq -0xe8(%rbp), %rax
movslq 0xc(%rax), %rsi
callq 0x11a90
movq %rax, %rdi
movq -0x28(%rbp), %rsi
addq $0x1c, %rsi
callq 0x11ab0
movq -0x20(%rbp), %rdi
movq -0xe8(%rbp), %rax
movslq 0xc(%rax), %rsi
callq 0x11a90
movq %rax, %rdi
movq -0xe8(%rbp), %rsi
addq $0x10, %rsi
callq 0x11ab0
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x17951
jmp 0x17a18
movl -0x50(%rbp), %eax
leaq 0x20dae(%rip), %rcx     # 0x387d0
cmpl (%rcx), %eax
jl 0x17b02
leaq 0x20ddf(%rip), %rax     # 0x38810
movq (%rax), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movslq 0x20(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x100(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x17a73
movq -0x28(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x17a73
leaq 0x20de3(%rip), %rax     # 0x38848
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x20dd7(%rip), %rax     # 0x38848
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x30(%rax)
leaq 0x20d90(%rip), %rax     # 0x38820
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
cmpl $0x1, (%rax,%rcx,4)
je 0x17b00
leaq 0x20d78(%rip), %rax     # 0x38820
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %ecx
leaq 0x20d38(%rip), %rax     # 0x38800
movq (%rax), %rax
movl %ecx, (%rax)
movq -0x100(%rbp), %rax
movq 0x58(%rax), %rdi
leaq 0x20d21(%rip), %rax     # 0x38800
movq (%rax), %rsi
callq 0xa6e0
leaq 0x20d62(%rip), %rax     # 0x38850
movq (%rax), %rdi
leaq 0x20d08(%rip), %rax     # 0x38800
movq (%rax), %rsi
callq 0xa6e0
jmp 0x17b02
movq -0x40(%rbp), %rax
movq (%rax), %rdi
callq 0x97c0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x97c0
movq -0x40(%rbp), %rdi
callq 0x97c0
movq -0x38(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)