// File: /workspace/github_cpp_makefile_star2_O1/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 0x7e8b
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 0x7e68
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, -0x38(%rbp)
jmp 0x7e71
leaq -0x40(%rbp), %rdi
callq 0x4cf6
movl %r15d, %ecx
movq 0x28(%r13), %rax
movq 0x30(%r13), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
incl %r15d
cmpq %rcx, %rdx
ja 0x7e3a
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
movl %ecx, %edx
decq %rdx
testl %edx, %edx
js 0x7ec9
movl %edx, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
shlq $0x5, %rsi
cmpl %r12d, 0x4(%rax,%rsi)
setne %dil
cmpl %r12d, 0x8(%rax,%rsi)
setne %sil
testb %sil, %dil
cmovel %edx, %ecx
jne 0x7e9c
movl %ecx, %edx
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rdx, %rcx
jbe 0x7f32
leal 0x1(%rdx), %r12d
leaq -0x40(%rbp), %r15
shlq $0x5, %rdx
addq %rax, %rdx
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0x7f10
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, -0x38(%rbp)
jmp 0x7f18
movq %r15, %rdi
callq 0x4cf6
movl %r12d, %edx
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
incl %r12d
cmpq %rdx, %rcx
ja 0x7ee7
leaq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdi
callq 0x83a6
movl (%rbx), %ecx
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rdx
movq %r14, %rsi
callq 0x7681
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 0x7faa
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 0x7f86
movl 0x8(%rbx), %esi
movq 0x10(%rbx), %rcx
callq 0x7a5c
movsd %xmm0, -0x48(%rbp)
movq %r14, %rsp
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x7fcc
callq 0x2130
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x7fda
callq 0x2130
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 0x800a
callq 0x2130
jmp 0x800a
jmp 0x8007
jmp 0x8007
jmp 0x8007
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x8018
callq 0x2130
movq %rbx, %rdi
callq 0x2220