// File: /workspace/github_cpp_makefile_star2_O3/Proudc[P]CTSS/src/ContinuousQuery/Pruneline.cpp
// Function: (anonymous namespace)::BFS(Graph*, ReferencePath*, std::vector<Edge, std::allocator<Edge>>, int)
bool BFS(Graph* myGraph, ReferencePath* referencePath, std::vector<Edge> currentPath, int currentVertex)
{
	printf("Start BFS search...\n");
	bool bfsFlag[(myGraph->vertexPos)];
	for (unsigned int i = 0; i < myGraph->vertexPos; i++)
	{
		bfsFlag[i] = false;
	}
	Vertex* firstVertex = new Vertex;
	firstVertex->vertexID = currentVertex;
	std::queue<Vertex> queue;
	queue.push(*firstVertex);
	while (!queue.empty())
	{
		Vertex temVertex = queue.front();
		queue.pop();
		bfsFlag[temVertex.vertexID] = true;
		if (myGraph->vertexsVector[temVertex.vertexID].referFlag == false)
		{
			for (unsigned int i = 0; i < myGraph->vertexsVector[temVertex.vertexID].adjVertexID.size(); i++)
			{
				int nextVertexID = myGraph->vertexsVector[temVertex.vertexID].adjVertexID[i];
				if ((bfsFlag[nextVertexID] == false) && (myGraph->vertexsVector[nextVertexID].currFlag == false) && (myGraph->vertexsVector[nextVertexID].locationFlag == true))
				{
					Vertex* newNode = new Vertex;
					newNode = &(myGraph->vertexsVector[nextVertexID]);
					newNode->parentVertexID = temVertex.vertexID;
					bfsFlag[nextVertexID] = true;
					queue.push(*newNode);
				}
			}
		}
		else
		{
			std::vector<Edge> temPath;
			Vertex* newNode;
			int temID = temVertex.vertexID;
			while (temID != currentVertex)
			{
				temPath.push_back(findEdge(myGraph, myGraph->vertexsVector[temID], myGraph->vertexsVector[myGraph->vertexsVector[temID].parentVertexID]));
				temID = myGraph->vertexsVector[temID].parentVertexID;
			}
			std::vector<Edge> finalPath;
			for (unsigned int i = 0; i < currentPath.size(); i++)
			{
				finalPath.push_back(currentPath[i]);
			}
			for (int i = (temPath.size() - 1); i >= 0; i--)
			{
				finalPath.push_back(temPath[i]);
			}
			int pathPos;
			int finalVertexID = temVertex.vertexID;
			for (int i = referencePath->edges.size() - 1; i >= 0; i--)
			{
				if ((referencePath->edges[i].firstVertexID == finalVertexID) || (referencePath->edges[i].secVertexID == finalVertexID))
				{
					pathPos = i;
					break;
				}
			}
			for (unsigned int i = pathPos; i < referencePath->edges.size(); i++)
			{
				finalPath.push_back(referencePath->edges[i]);
			}
			std::vector<Point> temPointList;
			temPointList = creatTrajPoint(myGraph, finalPath, referencePath->initialVertex);
			Point p[temPointList.size()];
			for (unsigned int i = 0; i < temPointList.size(); i++)
			{
				p[i].x = temPointList[i].x;
				p[i].y = temPointList[i].y;
			}
			double temDist = dfdDist(temPointList.size(), referencePath->numOfReferPoint, p, referencePath->pointOfRefer);
			if (temDist <= (myGraph->delta))
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}
	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movl %ecx, -0x30(%rbp)
movq %rdx, %r14
movq %rsi, -0x78(%rbp)
movq %rdi, %r12
leaq 0x38de(%rip), %rdi      # 0xca9e
callq 0x21b0
movl 0x4(%r12), %edx
movq %rsp, %rbx
leaq 0xf(%rdx), %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
testq %rdx, %rdx
je 0x91ea
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20b0
movq %rbx, -0x80(%rbp)
movl $0x70, %edi
callq 0x2140
movq %rax, %rbx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x40(%rax)
movupd %xmm0, 0x50(%rax)
movupd %xmm0, 0x60(%rax)
movl -0x30(%rbp), %eax
movl %eax, (%rbx)
leaq -0x240(%rbp), %r13
movapd %xmm0, 0x40(%r13)
movapd %xmm0, 0x30(%r13)
movapd %xmm0, 0x20(%r13)
movapd %xmm0, 0x10(%r13)
movapd %xmm0, (%r13)
movq %r13, %rdi
xorl %esi, %esi
callq 0xa806
movq %r13, %rdi
movq %rbx, %rsi
callq 0xa984
movq %rax, -0x58(%rbp)
movq -0x230(%rbp), %rbx
cmpq %rbx, -0x210(%rbp)
je 0x9763
movupd (%rbx), %xmm0
movupd 0x10(%rbx), %xmm1
movups 0x20(%rbx), %xmm2
movups 0x30(%rbx), %xmm3
movaps %xmm3, -0xe0(%rbp)
movaps %xmm2, -0xf0(%rbp)
movapd %xmm1, -0x100(%rbp)
movapd %xmm0, -0x110(%rbp)
leaq 0x40(%rbx), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x6c1e
addq $0x58, %rbx
leaq -0xb8(%rbp), %rdi
movq %rbx, %rsi
callq 0x6c1e
leaq -0x240(%rbp), %rdi
callq 0xac8a
movl -0x110(%rbp), %eax
movslq %eax, %rcx
movq -0x80(%rbp), %rdi
movb $0x1, (%rdi,%rcx)
movq 0x10(%r12), %rbx
imulq $0x70, %rcx, %rdx
movb 0x10(%rbx,%rdx), %r15b
testb %r15b, %r15b
je 0x9592
movb %r15b, -0x2c(%rbp)
xorpd %xmm0, %xmm0
movapd %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
cmpl -0x30(%rbp), %eax
je 0x9472
cltq
imulq $0x70, %rax, %r13
leaq (%rbx,%r13), %rsi
addq $0x40, %rsi
movupd -0x40(%rsi), %xmm0
movupd -0x30(%rsi), %xmm1
movups -0x20(%rsi), %xmm2
movups -0x10(%rsi), %xmm3
movapd %xmm0, -0x1f0(%rbp)
movapd %xmm1, -0x1e0(%rbp)
movaps %xmm2, -0x1d0(%rbp)
movaps %xmm3, -0x1c0(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x6c1e
addq %r13, %rbx
addq $0x58, %rbx
leaq -0x198(%rbp), %rdi
movq %rbx, %rsi
callq 0x6c1e
movq 0x10(%r12), %rbx
movslq 0xc(%rbx,%r13), %rax
imulq $0x70, %rax, %r15
leaq (%rbx,%r15), %rsi
addq $0x40, %rsi
movupd -0x40(%rsi), %xmm0
movupd -0x30(%rsi), %xmm1
movups -0x20(%rsi), %xmm2
movups -0x10(%rsi), %xmm3
movaps %xmm3, -0x150(%rbp)
movaps %xmm2, -0x160(%rbp)
movapd %xmm1, -0x170(%rbp)
movapd %xmm0, -0x180(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x6c1e
addq %r15, %rbx
addq $0x58, %rbx
leaq -0x128(%rbp), %rdi
movq %rbx, %rsi
callq 0x6c1e
leaq -0x50(%rbp), %rdi
movq %r12, %rsi
leaq -0x1f0(%rbp), %rdx
leaq -0x180(%rbp), %rcx
callq 0x644b
movq -0x68(%rbp), %rsi
cmpq -0x60(%rbp), %rsi
je 0x9412
movupd -0x50(%rbp), %xmm0
movupd -0x40(%rbp), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, -0x68(%rbp)
jmp 0x941f
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0xad3a
movq -0x128(%rbp), %rdi
testq %rdi, %rdi
je 0x9430
callq 0x2120
movq -0x140(%rbp), %rdi
testq %rdi, %rdi
je 0x9441
callq 0x2120
movq -0x198(%rbp), %rdi
testq %rdi, %rdi
je 0x9452
callq 0x2120
movq -0x1b0(%rbp), %rdi
testq %rdi, %rdi
je 0x9463
callq 0x2120
movq 0x10(%r12), %rbx
movl 0xc(%rbx,%r13), %eax
jmp 0x9300
xorpd %xmm0, %xmm0
movapd %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x94e0
movl $0x1, %ebx
xorl %edx, %edx
shlq $0x5, %rdx
addq %rax, %rdx
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x94c0
movupd (%rdx), %xmm0
movupd 0x10(%rdx), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x94c9
leaq -0x50(%rbp), %rdi
callq 0x4d16
movl %ebx, %edx
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
incl %ebx
cmpq %rdx, %rcx
ja 0x9493
movq -0x68(%rbp), %rax
subq -0x70(%rbp), %rax
shrq $0x5, %rax
decl %eax
js 0x9539
movl %eax, %ebx
leaq 0x1(%rbx), %r13
shlq $0x5, %rbx
movq -0x70(%rbp), %rdx
addq %rbx, %rdx
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x9527
movupd (%rdx), %xmm0
movupd 0x10(%rdx), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x9530
leaq -0x50(%rbp), %rdi
callq 0x4d16
addq $-0x20, %rbx
decq %r13
jg 0x94fa
movl -0x110(%rbp), %esi
movq -0x78(%rbp), %r15
movq 0x20(%r15), %rax
movq 0x28(%r15), %rcx
subq %rax, %rcx
movq %rcx, %rdx
shrq $0x5, %rdx
movl %edx, %r8d
movq %r8, %rdi
decq %r8
testl %r8d, %r8d
js 0x961a
movl %r8d, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %rdx, %r9
shlq $0x5, %r9
cmpl %esi, 0x4(%rax,%r9)
je 0x9587
addq %rax, %r9
cmpl %esi, 0x8(%r9)
jne 0x9558
decl %edi
movq %rdi, -0x58(%rbp)
jmp 0x961d
movq 0x40(%rbx,%rdx), %rcx
cmpq %rcx, 0x48(%rbx,%rdx)
je 0x9736
movl %r13d, -0x2c(%rbp)
movl $0x1, %r13d
xorl %edx, %edx
movslq (%rcx,%rdx,4), %rcx
cmpb $0x0, (%rdi,%rcx)
jne 0x95ee
imulq $0x70, %rcx, %rsi
cmpb $0x0, 0x13(%rbx,%rsi)
jne 0x95ee
addq %rbx, %rsi
cmpb $0x1, 0x11(%rsi)
jne 0x95ee
movl %eax, 0xc(%rsi)
movb $0x1, (%rdi,%rcx)
leaq -0x240(%rbp), %rdi
callq 0xa984
movq 0x10(%r12), %rbx
movl -0x110(%rbp), %eax
movq -0x80(%rbp), %rdi
movl %r13d, %edx
movslq %eax, %rcx
imulq $0x70, %rcx, %rsi
movq 0x40(%rbx,%rsi), %rcx
movq 0x48(%rbx,%rsi), %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
incl %r13d
cmpq %rdx, %rsi
ja 0x95ae
movl -0x2c(%rbp), %r13d
jmp 0x9736
movl -0x58(%rbp), %edx
sarq $0x5, %rcx
cmpq %rdx, %rcx
jbe 0x967b
movq -0x58(%rbp), %rcx
leal 0x1(%rcx), %ebx
shlq $0x5, %rdx
addq %rax, %rdx
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x965a
movupd (%rdx), %xmm0
movupd 0x10(%rdx), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x9663
leaq -0x50(%rbp), %rdi
callq 0x4d16
movl %ebx, %edx
movq 0x20(%r15), %rax
movq 0x28(%r15), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
incl %ebx
cmpq %rdx, %rcx
ja 0x962d
movl (%r15), %ecx
leaq -0x98(%rbp), %rdi
movq %r12, %rsi
leaq -0x50(%rbp), %rdx
callq 0x7577
movq %rsp, %r13
movq -0x98(%rbp), %rbx
movq -0x90(%rbp), %rax
movq %rax, %rdi
subq %rbx, %rdi
movq %rsp, %rdx
subq %rdi, %rdx
sarq $0x4, %rdi
movq %rdx, %rsp
cmpq %rbx, %rax
je 0x96e7
movl $0x8, %eax
movl $0x1, %ecx
movsd -0x8(%rbx,%rax), %xmm0
movsd %xmm0, -0x8(%rdx,%rax)
movsd (%rbx,%rax), %xmm0
movsd %xmm0, (%rdx,%rax)
movl %ecx, %esi
addq $0x10, %rax
incl %ecx
cmpq %rsi, %rdi
ja 0x96c4
movq -0x78(%rbp), %rax
movl 0x8(%rax), %esi
movq 0x10(%rax), %rcx
callq 0x7924
movq %r13, %rsp
movsd 0x18(%r12), %xmm1
ucomisd %xmm0, %xmm1
setae %r13b
testq %rbx, %rbx
je 0x9716
movq %rbx, %rdi
callq 0x2120
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
movb -0x2c(%rbp), %r15b
je 0x9728
callq 0x2120
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x9736
callq 0x2120
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
je 0x9747
callq 0x2120
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x9758
callq 0x2120
testb %r15b, %r15b
je 0x9251
jmp 0x9766
xorl %r13d, %r13d
leaq -0x240(%rbp), %rdi
callq 0xa6ba
andb $0x1, %r13b
movl %r13d, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x97c0
movq %rax, %r14
jmp 0x9831
movq %rax, %r14
testq %rbx, %rbx
je 0x97cc
movq %rbx, %rdi
callq 0x2120
jmp 0x97cc
jmp 0x97c9
movq %rax, %r14
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x983d
callq 0x2120
jmp 0x983d
movq %rax, %r14
jmp 0x983d
jmp 0x97c9
jmp 0x97c9
movq %rax, %r14
movq -0x50(%rbp), %rdi
jmp 0x97e6
movq %rax, %r14
jmp 0x9823
movq %rax, %r14
jmp 0x9817
movq %rax, %r14
movq -0x1b0(%rbp), %rdi
testq %rdi, %rdi
je 0x9823
callq 0x2120
jmp 0x9823
movq %rax, %r14
movq -0x140(%rbp), %rdi
testq %rdi, %rdi
je 0x9817
callq 0x2120
jmp 0x9817
movq %rax, %r14
leaq -0x180(%rbp), %rdi
callq 0x6b7e
leaq -0x1f0(%rbp), %rdi
callq 0x6b7e
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x9831
callq 0x2120
leaq -0x110(%rbp), %rdi
callq 0x6b7e
leaq -0x240(%rbp), %rdi
callq 0xa6ba
movq %r14, %rdi
callq 0x2210