// File: 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
subq $0x360, %rsp            # imm = 0x360
movq %rdx, -0x2e8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
leaq 0x86b9(%rip), %rdi      # 0x19ab1
xorl %eax, %eax
callq 0x2040
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movq %rsp, %rcx
movq %rcx, -0x30(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x2e0(%rbp)
movq %rcx, %rsp
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x11458
movq -0x2e0(%rbp), %rax
movl -0x3c(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x11433
movl $0x70, %edi
callq 0x2170
movq %rax, %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x8dd0
movq -0x2f8(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x24(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
leaq -0x98(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x14380
movq -0x2f0(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x143b0
jmp 0x114aa
jmp 0x114ac
leaq -0x98(%rbp), %rdi
callq 0x143e0
movb %al, -0x2f9(%rbp)
jmp 0x114c0
movb -0x2f9(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x114d1
jmp 0x11c76
leaq -0x98(%rbp), %rdi
callq 0x14400
movq %rax, -0x308(%rbp)
jmp 0x114e6
movq -0x308(%rbp), %rsi
leaq -0x118(%rbp), %rdi
callq 0x8f20
jmp 0x114fb
leaq -0x98(%rbp), %rdi
callq 0x14420
jmp 0x11509
movq -0x2e0(%rbp), %rax
movslq -0x118(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x118(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movb 0x10(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x116f6
movl $0x0, -0x11c(%rbp)
movl -0x11c(%rbp), %eax
movq %rax, -0x310(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x118(%rbp), %rax
imulq $0x70, %rax, %rax
addq %rax, %rdi
addq $0x40, %rdi
callq 0x90e0
movq %rax, %rcx
movq -0x310(%rbp), %rax
cmpq %rcx, %rax
jae 0x116f1
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x118(%rbp), %rax
imulq $0x70, %rax, %rax
addq %rax, %rdi
addq $0x40, %rdi
movl -0x11c(%rbp), %eax
movl %eax, %esi
callq 0x9100
movq %rax, %rcx
movq -0x2e0(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x120(%rbp)
movslq -0x120(%rbp), %rcx
movb (%rax,%rcx), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x116db
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x120(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movb 0x13(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x116db
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x120(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movb 0x11(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x116db
movl $0x70, %edi
callq 0x2170
movq %rax, -0x318(%rbp)
jmp 0x1163d
movq -0x318(%rbp), %rdi
callq 0x8dd0
movq -0x318(%rbp), %rcx
movq -0x2e0(%rbp), %rax
movq %rcx, -0x128(%rbp)
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq -0x120(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
movq %rcx, -0x128(%rbp)
movl -0x118(%rbp), %edx
movq -0x128(%rbp), %rcx
movl %edx, 0xc(%rcx)
movslq -0x120(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movq -0x128(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x143b0
jmp 0x116ab
jmp 0x116db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x11ca1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x11c68
jmp 0x116dd
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x1154c
jmp 0x11c41
leaq -0x140(%rbp), %rdi
callq 0x53a0
movl -0x118(%rbp), %eax
movl %eax, -0x14c(%rbp)
movl -0x14c(%rbp), %eax
cmpl -0x24(%rbp), %eax
je 0x11843
movq -0x10(%rbp), %rax
movq %rax, -0x320(%rbp)
movq 0x10(%rax), %rsi
movslq -0x14c(%rbp), %rax
imulq $0x70, %rax, %rax
addq %rax, %rsi
leaq -0x1e0(%rbp), %rdi
callq 0x8f20
jmp 0x11748
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movslq -0x14c(%rbp), %rax
imulq $0x70, %rax, %rax
movslq 0xc(%rsi,%rax), %rax
imulq $0x70, %rax, %rax
addq %rax, %rsi
leaq -0x250(%rbp), %rdi
callq 0x8f20
jmp 0x11775
movq -0x320(%rbp), %rsi
leaq -0x170(%rbp), %rdi
leaq -0x1e0(%rbp), %rdx
leaq -0x250(%rbp), %rcx
callq 0x8340
jmp 0x11798
leaq -0x140(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x14440
jmp 0x117ad
leaq -0x250(%rbp), %rdi
callq 0x90a0
leaq -0x1e0(%rbp), %rdi
callq 0x90a0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x14c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x14c(%rbp)
jmp 0x1170e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x11c33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x11832
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x90a0
leaq -0x1e0(%rbp), %rdi
callq 0x90a0
jmp 0x11c33
leaq -0x268(%rbp), %rdi
callq 0x53a0
movl $0x0, -0x26c(%rbp)
movq -0x2e8(%rbp), %rdi
movl -0x26c(%rbp), %eax
movq %rax, -0x328(%rbp)
callq 0x5360
movq %rax, %rcx
movq -0x328(%rbp), %rax
cmpq %rcx, %rax
jae 0x118d0
movq -0x2e8(%rbp), %rdi
movl -0x26c(%rbp), %eax
movl %eax, %esi
callq 0x5380
movq %rax, %rsi
leaq -0x268(%rbp), %rdi
callq 0x55f0
jmp 0x118a6
jmp 0x118a8
movl -0x26c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x26c(%rbp)
jmp 0x11859
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x11c27
leaq -0x140(%rbp), %rdi
callq 0x5360
subq $0x1, %rax
movl %eax, -0x270(%rbp)
cmpl $0x0, -0x270(%rbp)
jl 0x11926
movslq -0x270(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x5380
movq %rax, %rsi
leaq -0x268(%rbp), %rdi
callq 0x55f0
jmp 0x11913
jmp 0x11915
movl -0x270(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x270(%rbp)
jmp 0x118e6
movl -0x118(%rbp), %eax
movl %eax, -0x278(%rbp)
movq -0x18(%rbp), %rdi
addq $0x20, %rdi
callq 0x5360
subq $0x1, %rax
movl %eax, -0x27c(%rbp)
cmpl $0x0, -0x27c(%rbp)
jl 0x119b1
movq -0x18(%rbp), %rdi
addq $0x20, %rdi
movslq -0x27c(%rbp), %rsi
callq 0x5380
movl 0x4(%rax), %eax
cmpl -0x278(%rbp), %eax
je 0x11990
movq -0x18(%rbp), %rdi
addq $0x20, %rdi
movslq -0x27c(%rbp), %rsi
callq 0x5380
movl 0x8(%rax), %eax
cmpl -0x278(%rbp), %eax
jne 0x1199e
movl -0x27c(%rbp), %eax
movl %eax, -0x274(%rbp)
jmp 0x119b1
jmp 0x119a0
movl -0x27c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x27c(%rbp)
jmp 0x11949
movl -0x274(%rbp), %eax
movl %eax, -0x280(%rbp)
movl -0x280(%rbp), %eax
movq %rax, -0x330(%rbp)
movq -0x18(%rbp), %rdi
addq $0x20, %rdi
callq 0x5360
movq %rax, %rcx
movq -0x330(%rbp), %rax
cmpq %rcx, %rax
jae 0x11a1f
movq -0x18(%rbp), %rdi
addq $0x20, %rdi
movl -0x280(%rbp), %eax
movl %eax, %esi
callq 0x5380
movq %rax, %rsi
leaq -0x268(%rbp), %rdi
callq 0x55f0
jmp 0x11a0c
jmp 0x11a0e
movl -0x280(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x280(%rbp)
jmp 0x119bd
leaq -0x298(%rbp), %rdi
callq 0xb8c0
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rax
movl (%rax), %ecx
leaq -0x2b0(%rbp), %rdi
leaq -0x268(%rbp), %rdx
callq 0xb430
jmp 0x11a4a
leaq -0x298(%rbp), %rdi
movq %rdi, -0x340(%rbp)
leaq -0x2b0(%rbp), %rsi
movq %rsi, -0x348(%rbp)
callq 0xb8e0
movq -0x348(%rbp), %rdi
callq 0xb910
movq -0x340(%rbp), %rdi
callq 0xb970
movq %rax, %rdx
movq %rdx, %rax
movq %rsp, %rcx
movq %rcx, -0x2b8(%rbp)
shlq $0x4, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x338(%rbp)
movq %rcx, %rsp
movq %rax, -0x2c0(%rbp)
movl $0x0, -0x2c4(%rbp)
movl -0x2c4(%rbp), %eax
movq %rax, -0x350(%rbp)
leaq -0x298(%rbp), %rdi
callq 0xb970
movq %rax, %rcx
movq -0x350(%rbp), %rax
cmpq %rcx, %rax
jae 0x11b83
movl -0x2c4(%rbp), %eax
movl %eax, %esi
leaq -0x298(%rbp), %rdi
callq 0xb990
movq %rax, %rcx
movq -0x338(%rbp), %rax
movsd (%rcx), %xmm0
movl -0x2c4(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movl -0x2c4(%rbp), %eax
movl %eax, %esi
leaq -0x298(%rbp), %rdi
callq 0xb990
movq %rax, %rcx
movq -0x338(%rbp), %rax
movsd 0x8(%rcx), %xmm0
movl -0x2c4(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movl -0x2c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0x11ab8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x298(%rbp), %rdi
callq 0xb910
jmp 0x11c27
leaq -0x298(%rbp), %rdi
callq 0xb970
movq -0x338(%rbp), %rdx
movl %eax, %edi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %esi
movq 0x10(%rax), %rcx
callq 0xc5b0
movsd %xmm0, -0x358(%rbp)
jmp 0x11bb2
movsd -0x358(%rbp), %xmm0
movsd %xmm0, -0x2d0(%rbp)
movsd -0x2d0(%rbp), %xmm1
movq -0x10(%rbp), %rax
movsd 0x18(%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0x11be9
movb $0x1, -0x1(%rbp)
movl $0x1, -0x2d4(%rbp)
jmp 0x11bf7
movb $0x0, -0x1(%rbp)
movl $0x1, -0x2d4(%rbp)
movq -0x2b8(%rbp), %rax
movq %rax, %rsp
leaq -0x298(%rbp), %rdi
callq 0xb910
leaq -0x268(%rbp), %rdi
callq 0x54b0
leaq -0x140(%rbp), %rdi
callq 0x54b0
jmp 0x11c4b
leaq -0x268(%rbp), %rdi
callq 0x54b0
leaq -0x140(%rbp), %rdi
callq 0x54b0
jmp 0x11c68
movl $0x0, -0x2d4(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x90a0
movl -0x2d4(%rbp), %eax
testl %eax, %eax
jne 0x11c84
jmp 0x11c63
jmp 0x114ac
leaq -0x118(%rbp), %rdi
callq 0x90a0
jmp 0x11ca1
movb $0x0, -0x1(%rbp)
movl $0x1, -0x2d4(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x14470
movq -0x30(%rbp), %rax
movq %rax, %rsp
movb -0x1(%rbp), %al
andb $0x1, %al
movq %rbp, %rsp
popq %rbp
retq
leaq -0x98(%rbp), %rdi
callq 0x14470
movq -0xa0(%rbp), %rdi
callq 0x2240
nopl (%rax)