// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdx, -0x128(%rbp)
movq %rsi, -0x130(%rbp)
movq %rdi, -0x58(%rbp)
cmpl %r8d, %ecx
jg 0x3e52
movl %r8d, %r13d
movl %ecx, %ebx
leaq -0x190(%rbp), %r15
leaq -0x70(%rbp), %r12
movl %r8d, -0x94(%rbp)
leaq 0x8886(%rip), %rdi      # 0xc072
movl %ebx, %esi
xorl %eax, %eax
callq 0x2040
leaq -0x100(%rbp), %rdi
movl %ebx, %esi
callq 0x4f6b
movl $0x38, %edi
callq 0x2150
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%rax)
movq %rax, -0x48(%rbp)
movq $0x0, 0x30(%rax)
movl $0x28, %edi
callq 0x2150
movq %rax, %r14
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rax)
movq $0x0, 0x20(%rax)
movq %r15, -0x1a0(%rbp)
movq -0x130(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x1a0(%rbp), %rdi
callq 0x4c3e
movq %r14, -0x30(%rbp)
leaq -0x170(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
addq %rsi, %rdx
leaq -0x180(%rbp), %r14
movq %r14, %rdi
callq 0x4c3e
movq -0x58(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x30(%rbp), %rdx
leaq -0x1a0(%rbp), %rcx
movq %r14, %r8
callq 0x5015
movq -0x180(%rbp), %rdi
leaq -0x170(%rbp), %rax
cmpq %rax, %rdi
je 0x38c9
callq 0x2130
movq %rbx, -0xc0(%rbp)
movq -0x1a0(%rbp), %rdi
cmpq %r15, %rdi
je 0x38e1
callq 0x2130
movq %rsp, -0x138(%rbp)
movq -0x30(%rbp), %rcx
movl (%rcx), %ebx
movq 0x18(%rcx), %rax
subq 0x10(%rcx), %rax
sarq %rax
leaq (%rax,%rax,4), %rax
movq %rsp, %rdx
subq %rax, %rdx
movq %rdx, -0x88(%rbp)
movq %rdx, %rsp
xorpd %xmm0, %xmm0
movapd %xmm0, -0x120(%rbp)
movq $0x0, -0x110(%rbp)
movq 0x10(%rcx), %rax
movq 0x18(%rcx), %rdx
subq %rax, %rdx
xorl %ecx, %ecx
movl $0x0, %esi
movq %rsi, -0x40(%rbp)
cmpq $0x21, %rdx
jb 0x3c3f
movl $0x1, %r12d
xorpd %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x30(%rbp), %r15
leal -0x1(%r12), %ecx
shlq $0x5, %rcx
movsd -0x90(%rbp), %xmm0
addsd 0x18(%rax,%rcx), %xmm0
movsd %xmm0, -0x90(%rbp)
leaq (%rax,%rcx), %rdx
xorl %esi, %esi
cmpl %ebx, 0x4(%rax,%rcx)
sete %sil
movl 0x4(%rdx,%rsi,4), %r13d
xorpd %xmm0, %xmm0
movapd %xmm0, -0x80(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x58(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movq %r15, %rdx
movl %r12d, %ecx
callq 0x5647
movl $0x50, %edi
callq 0x2150
movq %rax, %r14
movq %r12, -0x50(%rbp)
movl %r12d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movq 0x18(%r15), %rax
subq 0x10(%r15), %rax
sarq $0x5, %rax
movq %rax, %xmm1
punpckldq 0x862c(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x8634(%rip), %xmm1     # 0xc030
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd %xmm0, 0x38(%r14)
movl %eax, 0x14(%r14)
movq -0x48(%rbp), %rbx
movsd 0x18(%rbx), %xmm0
movsd %xmm0, 0x48(%r14)
movsd 0x8(%r15), %xmm0
movsd -0x90(%rbp), %xmm2
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x40(%r14)
movsd %xmm2, 0x28(%r14)
movsd %xmm0, 0x30(%r14)
movl 0x8(%rbx), %eax
movq 0x28(%rbx), %rcx
subq 0x20(%rbx), %rcx
movl %eax, 0x8(%r14)
shrq $0x5, %rcx
movl %ecx, 0x18(%r14)
movl $0x0, -0xb8(%rbp)
callq 0x20d0
movq %rax, %r15
leaq -0x1d0(%rbp), %r12
movq %r12, %rdi
leaq -0x80(%rbp), %rsi
callq 0x4bba
movq -0x58(%rbp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
leaq -0x120(%rbp), %rcx
movq %r14, %r8
movl %r13d, %ebx
movl %r13d, %r9d
leaq -0x140(%rbp), %rax
pushq %rax
leaq -0xb8(%rbp), %rax
pushq %rax
callq 0x915d
addq $0x10, %rsp
movl %eax, %r12d
movq -0x1d0(%rbp), %rdi
testq %rdi, %rdi
je 0x3ad0
callq 0x2130
testb %r12b, %r12b
je 0x3b22
callq 0x20d0
subq %r15, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x8563(%rip), %xmm0     # 0xc050
movsd %xmm0, 0x20(%r14)
movq -0x40(%rbp), %rcx
movslq %ecx, %rax
incl %ecx
movq %rcx, -0x40(%rbp)
leaq (%rax,%rax,4), %rdi
shlq $0x4, %rdi
addq -0x88(%rbp), %rdi
movl $0xa, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movb $0x1, %r14b
jmp 0x3bf0
cmpl $0x1, -0xb8(%rbp)
leaq -0x1b8(%rbp), %r12
je 0x3be6
movl $0x0, -0xb8(%rbp)
movq %r12, %rdi
leaq -0x80(%rbp), %rsi
callq 0x4bba
movq -0x58(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %r12, %rdx
leaq -0x120(%rbp), %rcx
movq %r14, %r8
movl %ebx, %r9d
leaq -0x140(%rbp), %rax
pushq %rax
leaq -0xb8(%rbp), %rax
pushq %rax
callq 0x99d4
addq $0x10, %rsp
movl %eax, %r12d
movq -0x1b8(%rbp), %rdi
testq %rdi, %rdi
je 0x3b91
callq 0x2130
cmpl $0x1, -0xb8(%rbp)
setne %al
orb %al, %r12b
je 0x3be6
callq 0x20d0
subq %r15, %rax
cvtsi2sd %rax, %xmm0
divsd 0x849b(%rip), %xmm0     # 0xc050
movsd %xmm0, 0x20(%r14)
movq -0x40(%rbp), %rax
cltq
leaq (%rax,%rax,4), %rdi
shlq $0x4, %rdi
addq -0x88(%rbp), %rdi
movl $0xa, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
incl %eax
movq %rax, -0x40(%rbp)
jmp 0x3b1a
xorl %r14d, %r14d
movl $0x1, -0x34(%rbp)
movq -0x30(%rbp), %r15
movq -0x50(%rbp), %r12
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x3c06
callq 0x2130
testb %r14b, %r14b
je 0x3c26
incl %r12d
movq 0x10(%r15), %rax
movq 0x18(%r15), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %r12, %rcx
ja 0x3969
cmpl $0x1, -0x34(%rbp)
sete %cl
leaq -0x190(%rbp), %r15
leaq -0x70(%rbp), %r12
movl -0x94(%rbp), %r13d
testb %cl, %cl
movq -0xc0(%rbp), %rbx
jne 0x3e14
leaq -0xd0(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x128(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %rbx
movq %rbx, %rdi
callq 0x4c3e
movq %rbx, %rdi
leaq 0x8401(%rip), %rsi      # 0xc087
callq 0x2250
movq %rbx, %rdi
leaq -0xa8(%rbp), %rbx
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
callq 0x2060
movq %rbx, -0xb8(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x3cd1
movq %rdx, -0xb8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa8(%rbp)
jmp 0x3cd9
movupd (%rcx), %xmm0
movupd %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, -0xb0(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0xb8(%rbp), %rdi
leaq 0x839f(%rip), %rsi      # 0xc0a0
callq 0x2250
movq %r12, -0x80(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x3d26
movq %rdx, -0x80(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x70(%rbp)
jmp 0x3d30
movupd (%rcx), %xmm0
movupd %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, -0x78(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0xb8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x3d58
callq 0x2130
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
leaq -0x160(%rbp), %rbx
je 0x3d77
callq 0x2130
leaq -0x150(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x4c3e
movq -0x88(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq %rbx, %rdx
callq 0x6247
movq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x3dc3
callq 0x2130
movq -0x48(%rbp), %rax
addq $0x20, %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3dd8
callq 0x2130
movq -0x30(%rbp), %rbx
addq $0x10, %rbx
movq -0x48(%rbp), %rdi
callq 0x2130
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x3df6
callq 0x2130
movq -0x30(%rbp), %rdi
callq 0x2130
movq -0x80(%rbp), %rdi
cmpq %r12, %rdi
movq -0xc0(%rbp), %rbx
je 0x3e14
callq 0x2130
movq -0x120(%rbp), %rdi
testq %rdi, %rdi
je 0x3e25
callq 0x2130
movq -0x138(%rbp), %rsp
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x3e44
callq 0x2130
leal 0x1(%rbx), %eax
cmpl %r13d, %ebx
movl %eax, %ebx
jne 0x37e5
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3f65
leaq -0xd0(%rbp), %r14
movq %rax, %rbx
jmp 0x3eb7
movq %rax, %rbx
jmp 0x3ee7
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x3f65
jmp 0x3f60
leaq -0xd0(%rbp), %r14
movq %rbx, %rcx
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
cmpq %rcx, %rdi
je 0x3eb7
callq 0x2130
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3f65
jmp 0x3f60
movq %rax, %rbx
movq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x3ee7
callq 0x2130
movq -0x80(%rbp), %rdi
cmpq %r12, %rdi
je 0x3f65
jmp 0x3f60
jmp 0x3f22
movq %rax, %rbx
jmp 0x3f14
movq %rax, %rbx
movq -0x180(%rbp), %rdi
leaq -0x170(%rbp), %rax
cmpq %rax, %rdi
je 0x3f14
callq 0x2130
movq -0x1a0(%rbp), %rdi
cmpq %r15, %rdi
je 0x3f76
jmp 0x3f71
movq %rax, %rbx
jmp 0x3f76
movq %rax, %rbx
movq -0x1b8(%rbp), %rdi
testq %rdi, %rdi
je 0x3f57
jmp 0x3f49
jmp 0x3f54
movq %rax, %rbx
movq -0x1d0(%rbp), %rdi
testq %rdi, %rdi
je 0x3f57
callq 0x2130
jmp 0x3f57
jmp 0x3f54
jmp 0x3f54
movq %rax, %rbx
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x3f65
callq 0x2130
movq -0x120(%rbp), %rdi
testq %rdi, %rdi
je 0x3f76
callq 0x2130
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x3f8e
callq 0x2130
movq %rbx, %rdi
callq 0x2220