// File: /workspace/github_cpp_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
xorpd %xmm0, %xmm0
movupd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movupd %xmm0, -0x70(%rbp)
movupd %xmm0, -0x80(%rbp)
movupd %xmm0, -0x90(%rbp)
movupd %xmm0, -0xe0(%rbp)
movupd %xmm0, -0xf0(%rbp)
movupd %xmm0, -0x100(%rbp)
movl %ecx, -0xd0(%rbp)
xorl %r13d, %r13d
pushq $0x10
popq %r12
movl %r13d, %r13d
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %r13, %rcx
jbe 0x6309
movq %r13, %rcx
shlq $0x5, %rcx
movl 0x4(%rax,%rcx), %edx
movl 0x8(%rax,%rcx), %esi
movsd 0x18(%rax,%rcx), %xmm1
cmpl %edx, -0xd0(%rbp)
movq 0x10(%r15), %rax
movl %esi, %ecx
cmovel %edx, %ecx
cmovel %esi, %edx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
movsd 0x18(%rax,%rcx), %xmm2
movsd %xmm2, -0xb8(%rbp)
movsd 0x20(%rax,%rcx), %xmm3
movsd %xmm3, -0xb0(%rbp)
movslq %edx, %rcx
imulq $0x70, %rcx, %rdx
movsd 0x18(%rax,%rdx), %xmm4
movsd %xmm4, -0x128(%rbp)
movsd 0x20(%rax,%rdx), %xmm5
movsd %xmm5, -0x120(%rbp)
movl %ecx, -0xd0(%rbp)
subsd %xmm2, %xmm4
movsd 0x20(%r15), %xmm0
mulsd %xmm0, %xmm4
divsd %xmm1, %xmm4
movsd %xmm4, -0x48(%rbp)
subsd %xmm3, %xmm5
mulsd %xmm0, %xmm5
movsd %xmm1, -0x50(%rbp)
divsd %xmm1, %xmm5
movsd %xmm5, -0x40(%rbp)
movsd %xmm2, -0x60(%rbp)
movsd %xmm3, -0x58(%rbp)
movsd -0x60(%rbp), %xmm0
movsd %xmm2, -0x38(%rbp)
subsd %xmm2, %xmm0
movsd -0x58(%rbp), %xmm2
movapd %xmm2, %xmm1
movsd %xmm3, -0x30(%rbp)
subsd %xmm3, %xmm1
callq 0x4907
movsd -0x50(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x6301
movq %r12, %rdi
callq 0x2110
movsd -0x38(%rbp), %xmm1
movsd -0x30(%rbp), %xmm0
movsd %xmm1, (%rax)
movsd %xmm0, 0x8(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6392
movsd -0x38(%rbp), %xmm2
movsd -0x30(%rbp), %xmm3
addsd -0x48(%rbp), %xmm2
addsd -0x40(%rbp), %xmm3
jmp 0x6295
incl %r13d
jmp 0x61d1
pushq $0x10
popq %rdi
callq 0x2110
movsd -0x128(%rbp), %xmm0
movsd %xmm0, (%rax)
movsd -0x120(%rbp), %xmm0
movsd %xmm0, 0x8(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6392
leaq -0x140(%rbp), %rdi
callq 0x57ca
leaq -0xd0(%rbp), %rdi
callq 0x57ca
movq %rbx, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6366
jmp 0x6366
movq %rax, %r14
leaq -0x140(%rbp), %rdi
callq 0x57ca
leaq -0xd0(%rbp), %rdi
callq 0x57ca
movq %rbx, %rdi
callq 0x63b6
movq %r14, %rdi
callq 0x2200
nop