// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x120, %rsp            # imm = 0x120
movq %rdi, %rbx
xorpd %xmm0, %xmm0
movupd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movupd %xmm0, -0x68(%rbp)
movupd %xmm0, -0x78(%rbp)
movupd %xmm0, -0x88(%rbp)
movupd %xmm0, -0xd8(%rbp)
movupd %xmm0, -0xe8(%rbp)
movupd %xmm0, -0xf8(%rbp)
movl %ecx, -0xc8(%rbp)
movq (%rdx), %rax
cmpq %rax, 0x8(%rdx)
je 0x783c
movq %rdx, %r14
movq %rsi, %r15
xorl %ecx, %ecx
xorl %r12d, %r12d
shlq $0x5, %rcx
movl 0x4(%rax,%rcx), %edx
movl 0x8(%rax,%rcx), %esi
cmpl %edx, -0xc8(%rbp)
movl %esi, %edi
cmovel %edx, %edi
cmovel %esi, %edx
movsd 0x18(%rax,%rcx), %xmm1
movq 0x10(%r15), %rax
movslq %edi, %rcx
imulq $0x70, %rcx, %rcx
movsd 0x18(%rax,%rcx), %xmm2
movsd %xmm2, -0xb0(%rbp)
movsd 0x20(%rax,%rcx), %xmm3
movsd %xmm3, -0xa8(%rbp)
movslq %edx, %rcx
imulq $0x70, %rcx, %rdx
movsd 0x18(%rax,%rdx), %xmm4
movsd %xmm4, -0x120(%rbp)
movsd 0x20(%rax,%rdx), %xmm5
movsd %xmm5, -0x118(%rbp)
movl %ecx, -0xc8(%rbp)
subsd %xmm2, %xmm4
movsd 0x20(%r15), %xmm0
mulsd %xmm0, %xmm4
divsd %xmm1, %xmm4
movsd %xmm4, -0x40(%rbp)
subsd %xmm3, %xmm5
mulsd %xmm0, %xmm5
movsd %xmm1, -0x48(%rbp)
divsd %xmm1, %xmm5
movsd %xmm5, -0x38(%rbp)
movsd %xmm2, -0x58(%rbp)
movsd %xmm3, -0x50(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm2, -0x30(%rbp)
subsd %xmm2, %xmm0
movsd -0x50(%rbp), %xmm2
movapd %xmm2, %xmm1
movsd %xmm3, -0x28(%rbp)
subsd %xmm3, %xmm1
callq 0x59a1
movsd -0x48(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x781f
movl $0x10, %edi
callq 0x2150
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, 0x8(%rax)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x77fb
movupd (%rax), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x8(%rbx)
jmp 0x7806
movq %rbx, %rdi
movq %rax, %rdx
callq 0x790c
movsd -0x30(%rbp), %xmm2
addsd -0x40(%rbp), %xmm2
movsd -0x28(%rbp), %xmm3
addsd -0x38(%rbp), %xmm3
jmp 0x7795
incl %r12d
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
movq %r12, %rcx
cmpq %r12, %rdx
ja 0x76ee
movl $0x10, %edi
callq 0x2150
movsd -0x120(%rbp), %xmm0
movsd %xmm0, (%rax)
movsd -0x118(%rbp), %xmm0
movsd %xmm0, 0x8(%rax)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x7878
movupd (%rax), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x8(%rbx)
jmp 0x7883
movq %rbx, %rdi
movq %rax, %rdx
callq 0x790c
movq -0xe0(%rbp), %rdi
testq %rdi, %rdi
je 0x7894
callq 0x2130
movq -0xf8(%rbp), %rdi
testq %rdi, %rdi
je 0x78a5
callq 0x2130
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x78b3
callq 0x2130
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0x78c4
callq 0x2130
movq %rbx, %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x78db
jmp 0x78db
movq %rax, %r14
leaq -0x138(%rbp), %rdi
callq 0x6ca0
leaq -0xc8(%rbp), %rdi
callq 0x6ca0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x7903
callq 0x2130
movq %r14, %rdi
callq 0x2220
nop