// File: /workspace/github_cpp_makefile_star2_O2/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 $0x248, %rsp            # imm = 0x248
movl %ecx, %r14d
movq %rdx, -0x88(%rbp)
movq %rsi, -0x40(%rbp)
movq %rdi, %r12
leaq 0x2d46(%rip), %rdi      # 0xaa6e
callq 0x21a0
movl 0x4(%r12), %eax
movq %rsp, %rdx
leaq 0xf(%rax), %rcx
andq $-0x10, %rcx
subq %rcx, %rdx
movq %rdx, %rsp
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x7d53
movb $0x0, (%rdx,%rcx)
incq %rcx
jmp 0x7d45
movq %rdx, -0x68(%rbp)
pushq $0x70
popq %rdi
callq 0x2110
movq %rax, %rbx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x40(%rax)
movupd %xmm0, 0x50(%rax)
movupd %xmm0, 0x60(%rax)
movl %r14d, (%rax)
leaq -0x100(%rbp), %r13
movq %r13, %rdi
callq 0x88e2
movq %r13, %rdi
movq %rbx, %rsi
callq 0x8ec8
leaq -0x170(%rbp), %rbx
leaq -0xb0(%rbp), %r13
movl %r14d, -0x44(%rbp)
movq -0xf0(%rbp), %rsi
cmpq %rsi, -0xd0(%rbp)
je 0x80ef
movq %rbx, %rdi
callq 0x5734
leaq -0x100(%rbp), %rdi
callq 0x9164
movslq -0x170(%rbp), %rcx
movq -0x68(%rbp), %rdi
movb $0x1, (%rdi,%rcx)
movq 0x10(%r12), %rsi
imulq $0x70, %rcx, %rax
movb 0x10(%rsi,%rax), %al
movb %al, -0x29(%rbp)
testb %al, %al
je 0x7f51
xorpd %xmm0, %xmm0
movapd %xmm0, -0x80(%rbp)
andq $0x0, -0x70(%rbp)
cmpl %r14d, %ecx
je 0x7e80
movslq %ecx, %rax
imulq $0x70, %rax, %rbx
addq %rbx, %rsi
leaq -0x1f8(%rbp), %rdi
callq 0x5734
movq 0x10(%r12), %rax
movslq 0xc(%rax,%rbx), %rcx
imulq $0x70, %rcx, %rsi
addq %rax, %rsi
leaq -0x268(%rbp), %r15
movq %r15, %rdi
callq 0x5734
movq %r13, %rdi
movq %r12, %rsi
leaq -0x1f8(%rbp), %rdx
movq %r15, %rcx
callq 0x52b3
leaq -0x80(%rbp), %rdi
movq %r13, %rsi
callq 0x91e4
leaq -0x268(%rbp), %rdi
callq 0x57ca
leaq -0x1f8(%rbp), %rdi
callq 0x57ca
movq 0x10(%r12), %rsi
movl 0xc(%rsi,%rbx), %ecx
jmp 0x7e01
xorpd %xmm0, %xmm0
movapd %xmm0, -0xb0(%rbp)
andq $0x0, -0xa0(%rbp)
xorl %ebx, %ebx
movq -0x88(%rbp), %r14
movl %ebx, %ebx
movq (%r14), %rsi
movq 0x8(%r14), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %rbx, %rax
jbe 0x7ec8
movq %rbx, %rax
shlq $0x5, %rax
addq %rax, %rsi
movq %r13, %rdi
callq 0x4066
incl %ebx
jmp 0x7e9d
movq -0x78(%rbp), %rax
subq -0x80(%rbp), %rax
shrq $0x5, %rax
movl %eax, %ebx
decq %rbx
testl %ebx, %ebx
js 0x7efa
movl %ebx, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
shlq $0x5, %rsi
addq -0x80(%rbp), %rsi
decq %rbx
movq %r13, %rdi
callq 0x4066
jmp 0x7ed9
movl -0x170(%rbp), %ecx
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rax
movq %rax, %rdx
subq %rsi, %rdx
shrq $0x5, %rdx
movl %edx, %r14d
movq %r14, %rdx
decq %r14
testl %r14d, %r14d
js 0x7fcb
movl %r14d, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
shlq $0x5, %rdi
cmpl %ecx, 0x4(%rsi,%rdi)
je 0x7fd1
addq %rsi, %rdi
cmpl %ecx, 0x8(%rdi)
jne 0x7f19
decl %edx
movl %edx, %r14d
jmp 0x7fd1
xorl %ebx, %ebx
movl %ebx, %ebx
movslq %ecx, %rax
imulq $0x70, %rax, %rdx
movq 0x40(%rsi,%rdx), %rax
movq 0x48(%rsi,%rdx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rbx, %rdx
jbe 0x7fb9
movslq (%rax,%rbx,4), %rdx
cmpb $0x0, (%rdi,%rdx)
jne 0x7fb5
imulq $0x70, %rdx, %rax
cmpb $0x0, 0x13(%rsi,%rax)
jne 0x7fb5
addq %rsi, %rax
cmpb $0x1, 0x11(%rax)
jne 0x7fb5
movl %ecx, 0xc(%rax)
movb $0x1, (%rdi,%rdx)
leaq -0x100(%rbp), %rdi
movq %rax, %rsi
callq 0x8ec8
movq 0x10(%r12), %rsi
movl -0x170(%rbp), %ecx
movq -0x68(%rbp), %rdi
incl %ebx
jmp 0x7f53
movl -0x38(%rbp), %eax
movl %eax, %r14d
leaq -0x170(%rbp), %rbx
jmp 0x80d3
movl -0x38(%rbp), %ecx
movl %ecx, %r14d
movl %r14d, %ebx
movl %ebx, %ebx
subq %rsi, %rax
sarq $0x5, %rax
cmpq %rbx, %rax
jbe 0x8004
movq %rbx, %rax
shlq $0x5, %rax
addq %rax, %rsi
movq %r13, %rdi
callq 0x4066
incl %ebx
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rax
jmp 0x7fd4
xorpd %xmm0, %xmm0
movapd %xmm0, -0x60(%rbp)
andq $0x0, -0x50(%rbp)
movq -0x40(%rbp), %rax
movl (%rax), %ecx
leaq -0x188(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x6170
leaq -0x60(%rbp), %rdi
movq %rbx, %rsi
callq 0x63ca
movq %rbx, %rdi
callq 0x63b6
movq %rsp, -0x38(%rbp)
movq -0x60(%rbp), %rax
subq -0x58(%rbp), %rax
movq %rsp, %rdx
addq %rax, %rdx
movq %rdx, %rsp
movq -0x60(%rbp), %rax
movq -0x58(%rbp), %rdi
subq %rax, %rdi
sarq $0x4, %rdi
xorl %ecx, %ecx
leaq -0x170(%rbp), %rbx
movl %ecx, %ecx
cmpq %rcx, %rdi
jbe 0x8096
movq %rcx, %rsi
shlq $0x4, %rsi
movsd (%rax,%rsi), %xmm0
movsd %xmm0, (%rdx,%rsi)
movsd 0x8(%rax,%rsi), %xmm0
movsd %xmm0, 0x8(%rdx,%rsi)
incl %ecx
jmp 0x806e
movq -0x40(%rbp), %rax
movl 0x8(%rax), %esi
movq 0x10(%rax), %rcx
callq 0x658c
movsd 0x18(%r12), %xmm1
ucomisd %xmm0, %xmm1
setae %r15b
movq -0x38(%rbp), %rsp
leaq -0x60(%rbp), %rdi
callq 0x63b6
movq %r13, %rdi
callq 0x4092
leaq -0x80(%rbp), %rdi
callq 0x4092
movq %rbx, %rdi
callq 0x57ca
movl %r14d, -0x38(%rbp)
cmpb $0x0, -0x29(%rbp)
movl -0x44(%rbp), %r14d
je 0x7da4
jmp 0x80f2
xorl %r15d, %r15d
leaq -0x100(%rbp), %rdi
callq 0x8b16
andb $0x1, %r15b
movl %r15d, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x812b
jmp 0x8118
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x63b6
jmp 0x8137
movq %rax, %rbx
jmp 0x8173
movq %rax, %rbx
jmp 0x817f
jmp 0x8134
jmp 0x8134
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x4092
jmp 0x816a
movq %rax, %rbx
jmp 0x816a
movq %rax, %rbx
jmp 0x815e
movq %rax, %rbx
leaq -0x268(%rbp), %rdi
callq 0x57ca
leaq -0x1f8(%rbp), %rdi
callq 0x57ca
leaq -0x80(%rbp), %rdi
callq 0x4092
leaq -0x170(%rbp), %rdi
callq 0x57ca
leaq -0x100(%rbp), %rdi
callq 0x8b16
movq %rbx, %rdi
callq 0x2200