// File: /workspace/github_cpp_makefile_star2_O2/Proudc[P]CTSS/src/ContinuousQuery/Frechet.cpp
// Function: dfdDistBetweenTwoPaths(Graph*, TraversingPath*, ReferencePath*, std::vector<Edge, std::allocator<Edge>>&, int)
double dfdDistBetweenTwoPaths(Graph* myGraph, TraversingPath* temPath, ReferencePath* referencePath, std::vector<Edge>& lastPath, int finalVertexID)
{
	// printf("Start calculating the dfd between a half path and the reference path...\n");
	std::vector<Edge> finalPath;
	for (unsigned int i = 0; i < temPath->edges.size(); i++)
	{
		finalPath.push_back(myGraph->edgesVector[temPath->edges[i]]);
	}
	int pos;
	for (int i = (referencePath->edges.size()) - 1; i >= 0; i--)
	{
		int firstVertexID = referencePath->edges[i].firstVertexID;
		int secVertexID   = referencePath->edges[i].secVertexID;
		if ((firstVertexID == finalVertexID) || (secVertexID == finalVertexID))
		{
			pos = i;
			break;
		}
	}
	for (unsigned int i = pos; i < referencePath->edges.size(); i++)
	{
		finalPath.push_back(referencePath->edges[i]);
	}

	lastPath = finalPath;

	std::vector<Point> 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);
	return temDist;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, %r12d
movq %rcx, -0x68(%rbp)
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, -0x30(%rbp)
xorps %xmm0, %xmm0
leaq -0x60(%rbp), %r15
movaps %xmm0, (%r15)
andq $0x0, 0x10(%r15)
xorl %r14d, %r14d
movl %r14d, %r14d
movq 0x28(%r13), %rax
movq 0x30(%r13), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jbe 0x6904
movslq (%rax,%r14,4), %rsi
shlq $0x5, %rsi
movq -0x30(%rbp), %rax
addq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x4066
incl %r14d
jmp 0x68d0
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rax
movq %rax, %rcx
subq %rsi, %rcx
shrq $0x5, %rcx
movl %ecx, %ecx
movq %rcx, %r15
decq %rcx
testl %ecx, %ecx
js 0x693c
movl %ecx, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
shlq $0x5, %rdx
cmpl %r12d, 0x4(%rsi,%rdx)
je 0x693c
cmpl %r12d, 0x8(%rsi,%rdx)
jne 0x6918
decl %r15d
leaq -0x60(%rbp), %r12
movl %r15d, %r15d
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r15, %rax
jbe 0x6971
movq %r15, %rax
shlq $0x5, %rax
addq %rax, %rsi
movq %r12, %rdi
callq 0x4066
incl %r15d
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rax
jmp 0x6943
leaq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdi
callq 0x6d70
movl (%rbx), %ecx
leaq -0x48(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movq -0x30(%rbp), %rsi
callq 0x6170
movq %rsp, %r14
movq -0x48(%rbp), %rax
subq -0x40(%rbp), %rax
movq %rsp, %rdx
addq %rax, %rdx
movq %rdx, %rsp
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rdi
subq %rax, %rdi
sarq $0x4, %rdi
xorl %ecx, %ecx
movl %ecx, %ecx
cmpq %rcx, %rdi
jbe 0x69de
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 0x69b6
movl 0x8(%rbx), %esi
movq 0x10(%rbx), %rcx
callq 0x658c
movsd %xmm0, -0x30(%rbp)
movq %r14, %rsp
leaq -0x48(%rbp), %rdi
callq 0x63b6
leaq -0x60(%rbp), %rdi
callq 0x4092
movsd -0x30(%rbp), %xmm0
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x63b6
jmp 0x6a2f
jmp 0x6a2c
jmp 0x6a2c
jmp 0x6a2c
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x4092
movq %rbx, %rdi
callq 0x2200