// File: /workspace/github_cpp_makefile_star2_O1/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 $0x228, %rsp            # imm = 0x228
movl %ecx, -0x34(%rbp)
movq %rdx, %r14
movq %rsi, -0x40(%rbp)
movq %rdi, %r12
leaq 0x3792(%rip), %rdi      # 0xca9e
callq 0x21c0
movl 0x4(%r12), %edx
movq %rsp, %rbx
leaq 0xf(%rdx), %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
testq %rdx, %rdx
je 0x9336
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20b0
movq %rbx, -0x88(%rbp)
movl $0x70, %edi
callq 0x2150
movq %rax, %rbx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x40(%rax)
movupd %xmm0, 0x50(%rax)
movupd %xmm0, 0x60(%rax)
movl -0x34(%rbp), %eax
movl %eax, (%rbx)
leaq -0x250(%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 0xa9e0
movq %r13, %rdi
movq %rbx, %rsi
callq 0xab5e
movl %eax, -0x30(%rbp)
movq -0x88(%rbp), %r15
movq -0x240(%rbp), %rbx
cmpq %rbx, -0x220(%rbp)
je 0x98df
movupd (%rbx), %xmm0
movupd 0x10(%rbx), %xmm1
movups 0x20(%rbx), %xmm2
movups 0x30(%rbx), %xmm3
movaps %xmm3, -0xd0(%rbp)
movaps %xmm2, -0xe0(%rbp)
movapd %xmm1, -0xf0(%rbp)
movapd %xmm0, -0x100(%rbp)
leaq 0x40(%rbx), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x6d40
addq $0x58, %rbx
leaq -0xa8(%rbp), %rdi
movq %rbx, %rsi
callq 0x6d40
movq %r13, %rdi
callq 0xae64
movslq -0x100(%rbp), %rax
movb $0x1, (%r15,%rax)
movq 0x10(%r12), %rcx
imulq $0x70, %rax, %rax
movb 0x10(%rcx,%rax), %al
movb %al, -0x29(%rbp)
testb %al, %al
je 0x96e9
xorpd %xmm0, %xmm0
movapd %xmm0, -0x80(%rbp)
movq $0x0, -0x70(%rbp)
movl -0x100(%rbp), %eax
cmpl -0x34(%rbp), %eax
leaq -0x60(%rbp), %r15
je 0x95d0
movq 0x10(%r12), %rbx
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
movaps %xmm3, -0x1d0(%rbp)
movaps %xmm2, -0x1e0(%rbp)
movapd %xmm1, -0x1f0(%rbp)
movapd %xmm0, -0x200(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x6d40
addq %r13, %rbx
addq $0x58, %rbx
leaq -0x1a8(%rbp), %rdi
movq %rbx, %rsi
callq 0x6d40
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, -0x160(%rbp)
movaps %xmm2, -0x170(%rbp)
movapd %xmm1, -0x180(%rbp)
movapd %xmm0, -0x190(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x6d40
addq %r15, %rbx
addq $0x58, %rbx
leaq -0x138(%rbp), %rdi
movq %rbx, %rsi
callq 0x6d40
leaq -0x60(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
leaq -0x200(%rbp), %rdx
leaq -0x190(%rbp), %rcx
callq 0x655c
movq -0x78(%rbp), %rsi
cmpq -0x70(%rbp), %rsi
je 0x956d
movupd -0x60(%rbp), %xmm0
movupd -0x50(%rbp), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, -0x78(%rbp)
jmp 0x9579
leaq -0x80(%rbp), %rdi
movq %r15, %rdx
callq 0xaf14
movq -0x138(%rbp), %rdi
testq %rdi, %rdi
je 0x958a
callq 0x2130
movq -0x150(%rbp), %rdi
testq %rdi, %rdi
je 0x959b
callq 0x2130
movq -0x1a8(%rbp), %rdi
testq %rdi, %rdi
je 0x95ac
callq 0x2130
movq -0x1c0(%rbp), %rdi
testq %rdi, %rdi
je 0x95bd
callq 0x2130
movq 0x10(%r12), %rax
movl 0xc(%rax,%r13), %eax
cmpl -0x34(%rbp), %eax
jne 0x945c
xorpd %xmm0, %xmm0
movapd %xmm0, -0x60(%rbp)
movq $0x0, -0x50(%rbp)
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x963d
movl $0x1, %ebx
xorl %edx, %edx
shlq $0x5, %rdx
addq %rax, %rdx
movq -0x58(%rbp), %rsi
cmpq -0x50(%rbp), %rsi
je 0x961e
movupd (%rdx), %xmm0
movupd 0x10(%rdx), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, -0x58(%rbp)
jmp 0x9626
movq %r15, %rdi
callq 0x4cf6
movl %ebx, %edx
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
incl %ebx
cmpq %rdx, %rcx
ja 0x95f1
movq -0x78(%rbp), %rax
subq -0x80(%rbp), %rax
shrq $0x5, %rax
decl %eax
js 0x9695
movl %eax, %ebx
leaq 0x1(%rbx), %r13
shlq $0x5, %rbx
movq -0x80(%rbp), %rdx
addq %rbx, %rdx
movq -0x58(%rbp), %rsi
cmpq -0x50(%rbp), %rsi
je 0x9684
movupd (%rdx), %xmm0
movupd 0x10(%rdx), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, -0x58(%rbp)
jmp 0x968c
movq %r15, %rdi
callq 0x4cf6
addq $-0x20, %rbx
decq %r13
jg 0x9657
movl -0x100(%rbp), %eax
movq -0x40(%rbp), %rdx
movq 0x20(%rdx), %rcx
movq 0x28(%rdx), %rdx
subq %rcx, %rdx
shrq $0x5, %rdx
movl %edx, %r13d
movq %r13, %rdx
decq %r13
testl %r13d, %r13d
js 0x976e
movl %r13d, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
shlq $0x5, %rsi
cmpl %eax, 0x4(%rcx,%rsi)
je 0x9774
addq %rcx, %rsi
cmpl %eax, 0x8(%rsi)
jne 0x96b1
decl %edx
movl %edx, %r13d
jmp 0x9774
movq 0x10(%r12), %rsi
movslq -0x100(%rbp), %rax
imulq $0x70, %rax, %rdx
movq 0x40(%rsi,%rdx), %rcx
cmpq %rcx, 0x48(%rsi,%rdx)
je 0x98b1
movl $0x1, %ebx
xorl %edx, %edx
movslq (%rcx,%rdx,4), %rcx
cmpb $0x0, (%r15,%rcx)
jne 0x973f
imulq $0x70, %rcx, %rdx
cmpb $0x0, 0x13(%rsi,%rdx)
jne 0x973f
addq %rdx, %rsi
cmpb $0x1, 0x11(%rsi)
jne 0x973f
movl %eax, 0xc(%rsi)
movb $0x1, (%r15,%rcx)
movq %r13, %rdi
callq 0xab5e
movl %ebx, %edx
movq 0x10(%r12), %rsi
movslq -0x100(%rbp), %rax
imulq $0x70, %rax, %rdi
movq 0x40(%rsi,%rdi), %rcx
movq 0x48(%rsi,%rdi), %rdi
subq %rcx, %rdi
sarq $0x2, %rdi
incl %ebx
cmpq %rdx, %rdi
ja 0x9710
jmp 0x98b1
movl -0x64(%rbp), %eax
movl %eax, %r13d
movl %r13d, %edx
movq -0x40(%rbp), %rcx
movq 0x20(%rcx), %rax
movq 0x28(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rdx, %rcx
jbe 0x97e4
leal 0x1(%r13), %ebx
shlq $0x5, %rdx
addq %rax, %rdx
movq -0x58(%rbp), %rsi
cmpq -0x50(%rbp), %rsi
je 0x97c0
movupd (%rdx), %xmm0
movupd 0x10(%rdx), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, -0x58(%rbp)
jmp 0x97c8
movq %r15, %rdi
callq 0x4cf6
movl %ebx, %edx
movq -0x40(%rbp), %rcx
movq 0x20(%rcx), %rax
movq 0x28(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
incl %ebx
cmpq %rdx, %rcx
ja 0x9793
movq -0x40(%rbp), %rax
movl (%rax), %ecx
leaq -0x120(%rbp), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x7681
movq %rsp, %r15
movq -0x120(%rbp), %rbx
movq -0x118(%rbp), %rax
movq %rax, %rdi
subq %rbx, %rdi
movq %rsp, %rdx
subq %rdi, %rdx
sarq $0x4, %rdi
movq %rdx, %rsp
cmpq %rbx, %rax
je 0x9852
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 0x982f
movq -0x40(%rbp), %rax
movl 0x8(%rax), %esi
movq 0x10(%rax), %rcx
callq 0x7a5c
movq %r15, %rsp
movsd 0x18(%r12), %xmm1
ucomisd %xmm0, %xmm1
setae %al
movl %eax, -0x30(%rbp)
testq %rbx, %rbx
je 0x9883
movq %rbx, %rdi
callq 0x2130
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x9891
callq 0x2130
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x989f
callq 0x2130
movl %r13d, -0x64(%rbp)
movq -0x88(%rbp), %r15
leaq -0x250(%rbp), %r13
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x98c2
callq 0x2130
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x98d3
callq 0x2130
cmpb $0x0, -0x29(%rbp)
je 0x93a6
jmp 0x98e6
movl $0x0, -0x30(%rbp)
leaq -0x250(%rbp), %rdi
callq 0xa8a6
movl -0x30(%rbp), %eax
andb $0x1, %al
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9943
movq %rax, %r14
jmp 0x99b4
movq %rax, %r14
jmp 0x991a
movq %rax, %r14
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x994f
movq %rbx, %rdi
callq 0x2130
jmp 0x994f
movq %rax, %r14
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x99c0
callq 0x2130
jmp 0x99c0
movq %rax, %r14
jmp 0x99c0
jmp 0x994c
jmp 0x994c
movq %rax, %r14
movq -0x60(%rbp), %rdi
jmp 0x9964
movq %rax, %r14
jmp 0x999a
movq %rax, %r14
movq -0x1c0(%rbp), %rdi
testq %rdi, %rdi
je 0x99a6
callq 0x2130
jmp 0x99a6
movq %rax, %r14
movq -0x150(%rbp), %rdi
testq %rdi, %rdi
je 0x999a
callq 0x2130
jmp 0x999a
movq %rax, %r14
jmp 0x99a6
movq %rax, %r14
leaq -0x190(%rbp), %rdi
callq 0x6ca0
leaq -0x200(%rbp), %rdi
callq 0x6ca0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x99b4
callq 0x2130
leaq -0x100(%rbp), %rdi
callq 0x6ca0
leaq -0x250(%rbp), %rdi
callq 0xa8a6
movq %r14, %rdi
callq 0x2220