// File: Proudc[P]CTSS/src/ContinuousQuery/Base.cpp
// Function: setDistToRefer(Graph*, ReferencePath*)
void setDistToRefer(Graph* myGraph, ReferencePath* temPath)
{
	printf("Start calculating the shortest distance from each vertex to the reference path...\n");
	for (unsigned int i = 0; i < myGraph->vertexPos; i++)
	{
		double temDist = std::numeric_limits<double>::max();
		if (myGraph->vertexsVector[i].referFlag == true)
		{
			myGraph->vertexsVector[i].distToRefer = 0;
			continue;
		}
		for (unsigned int j = 0; j < temPath->edges.size(); j++)
		{
			double x  = myGraph->vertexsVector[i].longitude;
			double y  = myGraph->vertexsVector[i].latitude;
			double x1 = myGraph->vertexsVector[temPath->edges[j].firstVertexID].longitude;
			double y1 = myGraph->vertexsVector[temPath->edges[j].firstVertexID].latitude;
			double x2 = myGraph->vertexsVector[temPath->edges[j].secVertexID].longitude;
			double y2 = myGraph->vertexsVector[temPath->edges[j].secVertexID].latitude;
			double dist = pointToSegDist(x, y, x1, y1, x2, y2);
			temDist = dist < temDist ? dist : temDist;
		}
		myGraph->vertexsVector[i].distToRefer = temDist;
	}
	printf("The shortest distance from each vertex to the reference path is calculated!!!\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x11a20(%rip), %rdi     # 0x1937a
movb $0x0, %al
callq 0x2040
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x7baa
callq 0x90d0
movsd %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movb 0x10(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x79c0
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x28(%rax)
jmp 0x7b9c
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x5360
movq %rax, %rcx
movq -0x68(%rbp), %rax
cmpq %rcx, %rax
jae 0x7b80
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0x5380
movq %rax, %rcx
movq -0x88(%rbp), %rax
movslq 0x4(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0x5380
movq %rax, %rcx
movq -0x80(%rbp), %rax
movslq 0x4(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0x5380
movq %rax, %rcx
movq -0x78(%rbp), %rax
movslq 0x8(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0x5380
movq %rax, %rcx
movq -0x70(%rbp), %rax
movslq 0x8(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x30(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x40(%rbp), %xmm2
movsd -0x48(%rbp), %xmm3
movsd -0x50(%rbp), %xmm4
movsd -0x58(%rbp), %xmm5
callq 0x7360
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x7b58
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
jmp 0x7b65
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x79c7
movsd -0x20(%rbp), %xmm0
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x28(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x7968
leaq 0x1181c(%rip), %rdi     # 0x193cd
movb $0x0, %al
callq 0x2040
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)