// File: Proudc[P]CTSS/src/Test.cpp
// Function: roadSimpleQuery(Graph*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int)
void roadSimpleQuery(Graph* myGraph, string inputFolder, string outputFolder, const int startCount, const int stopCount)
{
	int count = startCount;
	while (count <= stopCount)
	{
		printf("Start %dth query...\n", count);
		string strCount = changeIntToStr(count);
		ReferencePath* referencePath = new ReferencePath;
		CompletePath*  completePath  = new CompletePath;
		setQueryEnv(myGraph, referencePath, completePath, inputFolder, strCount);
		
		int    currentVertex = completePath->initialVertex;
		int    recordPos = 0;
		Record record[completePath->edges.size()];
		double currPathLength = 0.0;
		double temDistance;
		vector<Edge> temPath;
		int    timeFlag = 0;
		for (unsigned int i = 1; i < completePath->edges.size(); i++)
		{
			currPathLength += completePath->edges[i - 1].realLength;
			if (completePath->edges[i - 1].firstVertexID == currentVertex)
			{
				currentVertex = completePath->edges[i - 1].secVertexID;
			}
			else
			{
				currentVertex = completePath->edges[i - 1].firstVertexID;
			}
			
			vector<Edge> currentPath;
			setCurrPath(myGraph, &currentPath, completePath, i);
			
			Record* temRecord = new Record;
			temRecord->ratioNumEdge     = ((double)(i)) / completePath->edges.size();
			temRecord->comPathSize      = completePath->edges.size();
			temRecord->referPathLength  = referencePath->referenceLength;
			temRecord->ratioPathLength  = currPathLength / (completePath->completeLength);
			temRecord->currPathLength   = currPathLength;
			temRecord->comPathLength    = completePath->completeLength;
			temRecord->numReferDiscrete = referencePath->numOfReferPoint;
			temRecord->referPathSize    = referencePath->edges.size();
			
			int     timeOutFlag = 0;
			clock_t startTime = clock();
			bool queryResultFlag = roadSimpleQueryPath(myGraph, referencePath, currentPath, temPath, temRecord, currentVertex, &timeOutFlag, &temDistance);
			if (queryResultFlag == false)
			{
				if (timeOutFlag == 1)
				{
					timeFlag = 1;
					break;
				}
				else
				{
					timeOutFlag = 0;
					bool queryResultFlagWithLoop = roadSimleQueryPathWithLoop(myGraph, referencePath, currentPath, temPath, temRecord, currentVertex, &timeOutFlag, &temDistance);
					if (queryResultFlagWithLoop == false)
					{
						if (timeOutFlag == 1)
						{
							timeFlag = 1;
							break;
						}
						else
						{
							clock_t stopTime = clock();
							temRecord->runTime = (double)(stopTime - startTime) / CLOCKS_PER_SEC;
							record[recordPos++] = (*temRecord);
						}
					}
					else
					{
						clock_t stopTime = clock();
						temRecord->runTime = (double)(stopTime - startTime) / CLOCKS_PER_SEC;
						record[recordPos++] = (*temRecord);
					}
				}

			}
			else
			{
				clock_t stopTime = clock();
				temRecord->runTime = (double)(stopTime - startTime) / CLOCKS_PER_SEC;
				record[recordPos++] = (*temRecord);
			}
		}
		if (timeFlag == 1)
		{
			count++;
			continue;	
		}
		string writeFilePath = outputFolder + "/" + strCount + "roadpartial.txt";
		writeSingleRecordToFile(record, recordPos, writeFilePath);
		
		delete referencePath;
		delete completePath;
		count++;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rsi, -0x208(%rbp)
movq %rdx, -0x200(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x4326
movl -0x24(%rbp), %esi
leaq 0x156c3(%rip), %rdi     # 0x1907b
xorl %eax, %eax
callq 0x2040
movl -0x24(%rbp), %esi
leaq -0x48(%rbp), %rdi
callq 0x6680
movl $0x38, %edi
callq 0x2170
movq %rax, -0x210(%rbp)
jmp 0x39de
movq -0x210(%rbp), %rdi
callq 0x5320
movq -0x210(%rbp), %rax
movq %rax, -0x50(%rbp)
movl $0x28, %edi
callq 0x2170
movq %rax, -0x218(%rbp)
jmp 0x3a08
movq -0x218(%rbp), %rdi
callq 0x5340
movq -0x218(%rbp), %rax
movq -0x208(%rbp), %rsi
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x230(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x228(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x220(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x2090
jmp 0x3a55
leaq -0xa8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2090
jmp 0x3a67
movq -0x220(%rbp), %rdx
movq -0x228(%rbp), %rsi
movq -0x230(%rbp), %rdi
leaq -0x88(%rbp), %rcx
leaq -0xa8(%rbp), %r8
callq 0x66b0
jmp 0x3a91
leaq -0xa8(%rbp), %rdi
callq 0x20d0
leaq -0x88(%rbp), %rdi
callq 0x20d0
movq -0x68(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xac(%rbp)
movl $0x0, -0xb0(%rbp)
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
callq 0x5360
movq %rax, %rcx
movq %rcx, %rax
movq %rsp, %rdx
movq %rdx, -0xb8(%rbp)
shlq $0x4, %rcx
leaq (%rcx,%rcx,4), %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x238(%rbp)
movq %rcx, %rsp
movq %rax, -0xc0(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xc8(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x53a0
movl $0x0, -0xec(%rbp)
movl $0x1, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
movq %rax, -0x240(%rbp)
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
callq 0x5360
movq %rax, %rcx
movq -0x240(%rbp), %rax
cmpq %rcx, %rax
jae 0x4123
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movl -0xf0(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x5380
movsd 0x18(%rax), %xmm0
addsd -0xc8(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movl -0xf0(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x5380
movl 0x4(%rax), %eax
cmpl -0xac(%rbp), %eax
jne 0x3c14
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movl -0xf0(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x5380
movl 0x8(%rax), %eax
movl %eax, -0xac(%rbp)
jmp 0x3c37
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x431b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x3c03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x20d0
leaq -0x88(%rbp), %rdi
callq 0x20d0
jmp 0x431b
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movl -0xf0(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x5380
movl 0x4(%rax), %eax
movl %eax, -0xac(%rbp)
leaq -0x108(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x53a0
movq -0x248(%rbp), %rsi
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rdx
movl -0xf0(%rbp), %ecx
callq 0x6c40
jmp 0x3c66
movl $0x50, %edi
callq 0x2170
movq %rax, -0x250(%rbp)
jmp 0x3c79
movq -0x250(%rbp), %rax
movq %rax, -0x110(%rbp)
movl -0xf0(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x268(%rbp)
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
callq 0x5360
movsd -0x268(%rbp), %xmm0
movq %rax, %xmm1
movaps 0x15355(%rip), %xmm2    # 0x19010
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x15359(%rip), %xmm2    # 0x19020
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movq -0x110(%rbp), %rax
movsd %xmm0, 0x38(%rax)
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
callq 0x5360
movl %eax, %ecx
movq -0x110(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x50(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0x110(%rbp), %rax
movsd %xmm0, 0x48(%rax)
movsd -0xc8(%rbp), %xmm0
movq -0x68(%rbp), %rax
movsd 0x8(%rax), %xmm1
divsd %xmm1, %xmm0
movq -0x110(%rbp), %rax
movsd %xmm0, 0x40(%rax)
movsd -0xc8(%rbp), %xmm0
movq -0x110(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movq -0x68(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x110(%rbp), %rax
movsd %xmm0, 0x30(%rax)
movq -0x50(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x110(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x50(%rbp), %rdi
addq $0x20, %rdi
callq 0x5360
movl %eax, %ecx
movq -0x110(%rbp), %rax
movl %ecx, 0x18(%rax)
movl $0x0, -0x114(%rbp)
callq 0x2100
movq %rax, -0x120(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x260(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x258(%rbp)
leaq -0x140(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x53c0
jmp 0x3dc9
movq -0x258(%rbp), %rsi
movq -0x260(%rbp), %rdi
movq -0x110(%rbp), %r8
movl -0xac(%rbp), %r9d
subq $0x10, %rsp
movq %rsp, %rax
leaq -0xd0(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq -0x114(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x140(%rbp), %rdx
leaq -0xe8(%rbp), %rcx
callq 0x10ba0
addq $0x10, %rsp
movb %al, -0x269(%rbp)
jmp 0x3e20
leaq -0x140(%rbp), %rdi
callq 0x54b0
movb -0x269(%rbp), %al
andb $0x1, %al
movb %al, -0x121(%rbp)
movb -0x121(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x406f
cmpl $0x1, -0x114(%rbp)
jne 0x3e9e
movl $0x1, -0xec(%rbp)
movl $0x4, -0x144(%rbp)
jmp 0x40e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4112
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x54b0
jmp 0x4112
movl $0x0, -0x114(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x280(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x278(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x53c0
jmp 0x3ed3
movq -0x278(%rbp), %rsi
movq -0x280(%rbp), %rdi
movq -0x110(%rbp), %r8
movl -0xac(%rbp), %r9d
subq $0x10, %rsp
movq %rsp, %rax
leaq -0xd0(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq -0x114(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x160(%rbp), %rdx
leaq -0xe8(%rbp), %rcx
callq 0x12cd0
addq $0x10, %rsp
movb %al, -0x281(%rbp)
jmp 0x3f2a
leaq -0x160(%rbp), %rdi
callq 0x54b0
movb -0x281(%rbp), %al
andb $0x1, %al
movb %al, -0x145(%rbp)
movb -0x145(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4002
cmpl $0x1, -0x114(%rbp)
jne 0x3f97
movl $0x1, -0xec(%rbp)
movl $0x4, -0x144(%rbp)
jmp 0x40e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x54b0
jmp 0x4112
callq 0x2100
movq -0x238(%rbp), %rdi
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rax
subq -0x120(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x15043(%rip), %xmm1    # 0x19008
divsd %xmm1, %xmm0
movq -0x110(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movq -0x110(%rbp), %rsi
movl -0xb0(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xb0(%rbp)
cltq
imulq $0x50, %rax, %rax
addq %rax, %rdi
movl $0x50, %edx
callq 0x2130
jmp 0x406b
callq 0x2100
movq -0x238(%rbp), %rdi
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rax
subq -0x120(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x14fd8(%rip), %xmm1    # 0x19008
divsd %xmm1, %xmm0
movq -0x110(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movq -0x110(%rbp), %rsi
movl -0xb0(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xb0(%rbp)
cltq
imulq $0x50, %rax, %rax
addq %rax, %rdi
movl $0x50, %edx
callq 0x2130
jmp 0x406d
jmp 0x40d8
callq 0x2100
movq -0x238(%rbp), %rdi
movq %rax, -0x178(%rbp)
movq -0x178(%rbp), %rax
subq -0x120(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x14f6b(%rip), %xmm1    # 0x19008
divsd %xmm1, %xmm0
movq -0x110(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movq -0x110(%rbp), %rsi
movl -0xb0(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xb0(%rbp)
cltq
imulq $0x50, %rax, %rax
addq %rax, %rdi
movl $0x50, %edx
callq 0x2130
movl $0x0, -0x144(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x54b0
movl -0x144(%rbp), %eax
testl %eax, %eax
je 0x40fc
jmp 0x40fa
jmp 0x4123
jmp 0x40fe
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
jmp 0x3b26
leaq -0x108(%rbp), %rdi
callq 0x54b0
jmp 0x430f
cmpl $0x1, -0xec(%rbp)
jne 0x4144
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl $0x2, -0x144(%rbp)
jmp 0x4266
movq -0x200(%rbp), %rsi
leaq 0x14f3e(%rip), %rdx     # 0x19090
leaq -0x1d8(%rbp), %rdi
callq 0x52a0
jmp 0x4160
leaq -0x1b8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x5560
jmp 0x4179
leaq 0x14f29(%rip), %rdx     # 0x190a9
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x5510
jmp 0x4195
leaq -0x1b8(%rbp), %rdi
callq 0x20d0
leaq -0x1d8(%rbp), %rdi
callq 0x20d0
movl -0xb0(%rbp), %eax
movl %eax, -0x288(%rbp)
leaq -0x1f8(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x2090
jmp 0x41ce
movl -0x288(%rbp), %esi
movq -0x238(%rbp), %rdi
leaq -0x1f8(%rbp), %rdx
callq 0x7ee0
jmp 0x41e9
leaq -0x1f8(%rbp), %rdi
callq 0x20d0
movq -0x50(%rbp), %rax
movq %rax, -0x290(%rbp)
cmpq $0x0, %rax
je 0x421e
movq -0x290(%rbp), %rdi
callq 0x55b0
movq -0x290(%rbp), %rdi
callq 0x2150
movq -0x68(%rbp), %rax
movq %rax, -0x298(%rbp)
cmpq $0x0, %rax
je 0x4247
movq -0x298(%rbp), %rdi
callq 0x55d0
movq -0x298(%rbp), %rdi
callq 0x2150
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x20d0
movl $0x0, -0x144(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x54b0
movq -0xb8(%rbp), %rax
movq %rax, %rsp
leaq -0x48(%rbp), %rdi
callq 0x20d0
movl -0x144(%rbp), %eax
testl %eax, %eax
je 0x4296
jmp 0x4291
jmp 0x39a2
jmp 0x39a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x430f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x42cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x20d0
leaq -0x1d8(%rbp), %rdi
callq 0x20d0
jmp 0x430f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4303
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x20d0
leaq -0x198(%rbp), %rdi
callq 0x20d0
leaq -0xe8(%rbp), %rdi
callq 0x54b0
leaq -0x48(%rbp), %rdi
callq 0x20d0
jmp 0x432b
movq %rbp, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x2240
nopw %cs:(%rax,%rax)