// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movl %r8d, %r12d
movq %rcx, -0x48(%rbp)
movq %rdx, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
movq 0x28(%rsi), %rax
cmpq %rax, 0x30(%rsi)
je 0x7cd3
movq %rsi, %r13
movl $0x1, %r15d
xorl %ecx, %ecx
movslq (%rax,%rcx,4), %rdx
shlq $0x5, %rdx
addq 0x8(%r14), %rdx
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0x7cb0
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, -0x38(%rbp)
jmp 0x7cb9
leaq -0x40(%rbp), %rdi
callq 0x4d16
movl %r15d, %ecx
movq 0x28(%r13), %rax
movq 0x30(%r13), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
incl %r15d
cmpq %rcx, %rdx
ja 0x7c82
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
movq %rcx, %rdx
shrq $0x5, %rdx
movl %edx, %edx
movq %rdx, %r13
decq %rdx
testl %edx, %edx
js 0x7d0b
movl %edx, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
shlq $0x5, %rsi
cmpl %r12d, 0x4(%rax,%rsi)
je 0x7d0b
cmpl %r12d, 0x8(%rax,%rsi)
jne 0x7ce7
leal -0x1(%r13), %edx
sarq $0x5, %rcx
cmpq %rdx, %rcx
jbe 0x7d67
leaq -0x40(%rbp), %r15
shlq $0x5, %rdx
addq %rax, %rdx
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0x7d45
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, -0x38(%rbp)
jmp 0x7d4d
movq %r15, %rdi
callq 0x4d16
movl %r13d, %edx
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
incl %r13d
cmpq %rdx, %rcx
ja 0x7d1c
leaq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdi
callq 0x81de
movl (%rbx), %ecx
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rdx
movq %r14, %rsi
callq 0x7577
movq %rsp, %r14
movq -0x60(%rbp), %rax
subq -0x58(%rbp), %rax
movq %rsp, %rdx
addq %rax, %rdx
movq %rdx, %rsp
movq -0x60(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, %rdi
subq %rax, %rdi
sarq $0x4, %rdi
cmpq %rax, %rcx
je 0x7ddf
movl $0x8, %ecx
movl $0x1, %esi
movsd -0x8(%rax,%rcx), %xmm0
movsd %xmm0, -0x8(%rdx,%rcx)
movsd (%rax,%rcx), %xmm0
movsd %xmm0, (%rdx,%rcx)
movl %esi, %r8d
addq $0x10, %rcx
incl %esi
cmpq %r8, %rdi
ja 0x7dbb
movl 0x8(%rbx), %esi
movq 0x10(%rbx), %rcx
callq 0x7924
movsd %xmm0, -0x48(%rbp)
movq %r14, %rsp
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x7e01
callq 0x2120
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x7e0f
callq 0x2120
movsd -0x48(%rbp), %xmm0
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x7e3f
callq 0x2120
jmp 0x7e3f
jmp 0x7e3c
jmp 0x7e3c
jmp 0x7e3c
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x7e4d
callq 0x2120
movq %rbx, %rdi
callq 0x2210