// File: Proudc[P]CTSS/src/ContinuousQuery/Discrete.cpp
// Function: creatTrajPoint(Graph*, std::vector<Edge, std::allocator<Edge>>&, int)
std::vector<Point> creatTrajPoint(Graph* myGraph, std::vector<Edge>& temPath, int initialVertex)
{
	// printf("Start discretizing the path...\n");
	std::vector<Point> temPointList;
	Vertex helpFirst, helpSec;
	helpFirst.vertexID = initialVertex;
	for (unsigned int i = 0; i < temPath.size(); i++)
	{
		Edge helpEdge = temPath[i];
		if (helpFirst.vertexID == helpEdge.firstVertexID)
		{
			helpFirst.longitude = myGraph->vertexsVector[helpEdge.firstVertexID].longitude;
			helpFirst.latitude  = myGraph->vertexsVector[helpEdge.firstVertexID].latitude;
			helpSec.longitude   = myGraph->vertexsVector[helpEdge.secVertexID].longitude;
			helpSec.latitude    = myGraph->vertexsVector[helpEdge.secVertexID].latitude;
			helpFirst.vertexID  = helpEdge.secVertexID;
		}
		else
		{
			helpFirst.longitude = myGraph->vertexsVector[helpEdge.secVertexID].longitude;
			helpFirst.latitude  = myGraph->vertexsVector[helpEdge.secVertexID].latitude;
			helpSec.longitude   = myGraph->vertexsVector[helpEdge.firstVertexID].longitude;
			helpSec.latitude    = myGraph->vertexsVector[helpEdge.firstVertexID].latitude;
			helpFirst.vertexID  = helpEdge.firstVertexID;
		}
		double x1 = helpFirst.longitude;
		double y1 = helpFirst.latitude;
		double x2 = helpSec.longitude;
		double y2 = helpSec.latitude;

		double xLength = (x2 - x1) * (myGraph->SECTION_LENGTH) / (helpEdge.realLength);
		double yLength = (y2 - y1) * (myGraph->SECTION_LENGTH) / (helpEdge.realLength);
		double x = x1;
		double y = y1;
		while (realDistance((x1 - x), (y1 - y), y1) < helpEdge.realLength)
		{
			Point* temPoint = new Point;
			temPoint->x = x;
			temPoint->y = y;
			temPointList.push_back(*temPoint);
			x += xLength;
			y += yLength;
		}
	}
	Point* temPoint = new Point;
	temPoint->x = helpSec.longitude;
	temPoint->y = helpSec.latitude;
	temPointList.push_back(*temPoint);
	// printf("The temPointList's size is :%d\n", temPointList.size());
	// printf("Discretization of the path completed!!!\n");
	return temPointList;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x198(%rbp)
movq %rdi, %rax
movq %rax, -0x190(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movb $0x0, -0x1d(%rbp)
callq 0xb8c0
leaq -0x90(%rbp), %rdi
callq 0x8dd0
leaq -0x100(%rbp), %rdi
callq 0x8dd0
movl -0x1c(%rbp), %eax
movl %eax, -0x90(%rbp)
movl $0x0, -0x104(%rbp)
movl -0x104(%rbp), %eax
movq %rax, -0x1a0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5360
movq %rax, %rcx
movq -0x1a0(%rbp), %rax
cmpq %rcx, %rax
jae 0xb812
movq -0x18(%rbp), %rdi
movl -0x104(%rbp), %eax
movl %eax, %esi
callq 0x5380
movq (%rax), %rcx
movq %rcx, -0x128(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x120(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x118(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x110(%rbp)
movl -0x90(%rbp), %eax
cmpl -0x124(%rbp), %eax
jne 0xb59d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x124(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x124(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x120(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0xe8(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x120(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0xe0(%rbp)
movl -0x120(%rbp), %eax
movl %eax, -0x90(%rbp)
jmp 0xb62f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x120(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x120(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x124(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0xe8(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x124(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0xe0(%rbp)
movl -0x124(%rbp), %eax
movl %eax, -0x90(%rbp)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x130(%rbp)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x138(%rbp)
movsd -0xe8(%rbp), %xmm0
movsd %xmm0, -0x140(%rbp)
movsd -0xe0(%rbp), %xmm0
movsd %xmm0, -0x148(%rbp)
movsd -0x140(%rbp), %xmm0
subsd -0x130(%rbp), %xmm0
movq -0x10(%rbp), %rax
mulsd 0x20(%rax), %xmm0
divsd -0x110(%rbp), %xmm0
movsd %xmm0, -0x150(%rbp)
movsd -0x148(%rbp), %xmm0
subsd -0x138(%rbp), %xmm0
movq -0x10(%rbp), %rax
mulsd 0x20(%rax), %xmm0
divsd -0x110(%rbp), %xmm0
movsd %xmm0, -0x158(%rbp)
movsd -0x130(%rbp), %xmm0
movsd %xmm0, -0x160(%rbp)
movsd -0x138(%rbp), %xmm0
movsd %xmm0, -0x168(%rbp)
movsd -0x130(%rbp), %xmm0
movsd -0x160(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd -0x138(%rbp), %xmm2
movsd -0x168(%rbp), %xmm3
movaps %xmm2, %xmm1
subsd %xmm3, %xmm1
callq 0x6fb0
movsd %xmm0, -0x1a8(%rbp)
jmp 0xb715
movsd -0x1a8(%rbp), %xmm1
movsd -0x110(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xb7fc
movl $0x10, %edi
callq 0x2170
movq %rax, -0x1b0(%rbp)
jmp 0xb742
movq -0x198(%rbp), %rdi
movq -0x1b0(%rbp), %rax
movq %rax, -0x180(%rbp)
movsd -0x160(%rbp), %xmm0
movq -0x180(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x168(%rbp), %xmm0
movq -0x180(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x180(%rbp), %rsi
callq 0xb9b0
jmp 0xb78c
movsd -0x150(%rbp), %xmm0
addsd -0x160(%rbp), %xmm0
movsd %xmm0, -0x160(%rbp)
movsd -0x158(%rbp), %xmm0
addsd -0x168(%rbp), %xmm0
movsd %xmm0, -0x168(%rbp)
jmp 0xb6db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x90a0
leaq -0x90(%rbp), %rdi
callq 0x90a0
movq -0x198(%rbp), %rdi
callq 0xb910
jmp 0xb8ad
jmp 0xb7fe
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0xb48f
movl $0x10, %edi
callq 0x2170
movq %rax, -0x1b8(%rbp)
jmp 0xb825
movq -0x198(%rbp), %rdi
movq -0x1b8(%rbp), %rax
movq %rax, -0x188(%rbp)
movsd -0xe8(%rbp), %xmm0
movq -0x188(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0xe0(%rbp), %xmm0
movq -0x188(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x188(%rbp), %rsi
callq 0xb9b0
jmp 0xb86f
movb $0x1, -0x1d(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x90a0
leaq -0x90(%rbp), %rdi
callq 0x90a0
testb $0x1, -0x1d(%rbp)
jne 0xb89d
movq -0x198(%rbp), %rdi
callq 0xb910
movq -0x190(%rbp), %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
movq -0x170(%rbp), %rdi
callq 0x2240
nopl (%rax)