// File: /workspace/github_cpp_makefile_star2_O2/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
movl %r8d, -0x5c(%rbp)
movl %ecx, %ebx
movq %rdx, -0xb8(%rbp)
movq %rsi, -0xc0(%rbp)
movq %rdi, -0x38(%rbp)
leaq -0x160(%rbp), %r14
leaq -0x140(%rbp), %r12
cmpl -0x5c(%rbp), %ebx
jg 0x3579
leaq 0x6f83(%rip), %rdi      # 0xa072
movl %ebx, %esi
xorl %eax, %eax
callq 0x2040
movq %r14, %rdi
movl %ebx, %esi
callq 0x432e
pushq $0x38
popq %rdi
callq 0x2110
movq %rax, %r15
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%rax)
andq $0x0, 0x30(%rax)
pushq $0x28
popq %rdi
callq 0x2110
movq %rax, %r13
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rax)
andq $0x0, 0x20(%rax)
movq %r12, %rdi
movq -0xc0(%rbp), %rsi
callq 0x2160
movq %r13, -0x48(%rbp)
leaq -0x1d0(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x2160
movl %ebx, -0x60(%rbp)
movq -0x38(%rbp), %rdi
movq %r15, %rsi
movq -0x48(%rbp), %rbx
movq %rbx, %rdx
movq %r12, %rcx
movq %r13, %r8
callq 0x4346
movq %r15, -0x50(%rbp)
addq $0x20, %r15
movq %r15, -0xc8(%rbp)
movq %rbx, %rax
addq $0x10, %rax
movq %rax, -0xd0(%rbp)
movq %r13, %rdi
callq 0x2090
movq %r12, %rdi
callq 0x2090
movq %rsp, -0xd8(%rbp)
movl (%rbx), %r13d
movq 0x18(%rbx), %rax
subq 0x10(%rbx), %rax
sarq $0x5, %rax
imulq $0x50, %rax, %rax
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x40(%rbp)
movq %rcx, %rsp
xorpd %xmm0, %xmm0
movapd %xmm0, -0xb0(%rbp)
andq $0x0, -0xa0(%rbp)
xorpd %xmm1, %xmm1
movsd %xmm1, -0x58(%rbp)
movq $0x0, -0x70(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
leaq -0x90(%rbp), %r14
movq -0x70(%rbp), %rcx
leal 0x1(%rcx), %r15d
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %r15, %rdx
jbe 0x3482
movl %ecx, %ecx
shlq $0x5, %rcx
leaq (%rax,%rcx), %rdx
movsd -0x58(%rbp), %xmm1
addsd 0x18(%rax,%rcx), %xmm1
movsd %xmm1, -0x58(%rbp)
xorl %esi, %esi
cmpl %r13d, 0x4(%rax,%rcx)
sete %sil
movl 0x4(%rdx,%rsi,4), %r12d
movapd %xmm0, -0x90(%rbp)
andq $0x0, -0x80(%rbp)
movq -0x38(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
movl %r15d, %ecx
callq 0x4709
movq %r15, %r13
pushq $0x50
popq %rdi
callq 0x2110
movq %rax, %r15
movq %r13, -0x70(%rbp)
movl %r13d, %eax
cvtsi2sd %rax, %xmm0
movq 0x18(%rbx), %rax
subq 0x10(%rbx), %rax
sarq $0x5, %rax
movq %rax, %xmm1
punpckldq 0x6d81(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x6d89(%rip), %xmm1     # 0xa030
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd %xmm0, 0x38(%r15)
movl %eax, 0x14(%r15)
movq -0x50(%rbp), %r13
movsd 0x18(%r13), %xmm0
movsd %xmm0, 0x48(%r15)
movsd 0x8(%rbx), %xmm0
movsd -0x58(%rbp), %xmm2
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x40(%r15)
movsd %xmm2, 0x28(%r15)
movsd %xmm0, 0x30(%r15)
movl 0x8(%r13), %eax
movl %eax, 0x8(%r15)
movq 0x28(%r13), %rax
subq 0x20(%r13), %rax
shrq $0x5, %rax
movl %eax, 0x18(%r15)
andl $0x0, -0xf8(%rbp)
callq 0x20c0
movq %rax, -0x68(%rbp)
leaq -0x190(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3fbc
movq -0x38(%rbp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
leaq -0xb0(%rbp), %rcx
movq %r15, %r8
movl %r12d, %r13d
movl %r12d, %r9d
leaq -0x100(%rbp), %rax
pushq %rax
leaq -0xf8(%rbp), %rax
pushq %rax
callq 0x7b73
popq %rcx
popq %rdx
movl %eax, %r14d
movq %rbx, %rdi
callq 0x4092
movslq -0x2c(%rbp), %r12
testb %r14b, %r14b
je 0x33b0
callq 0x20c0
subq -0x68(%rbp), %rax
cvtsi2sd %rax, %xmm0
divsd 0x6cc6(%rip), %xmm0     # 0xa050
movsd %xmm0, 0x20(%r15)
leal 0x1(%r12), %eax
movl %eax, -0x2c(%rbp)
imulq $0x50, %r12, %rdi
addq -0x40(%rbp), %rdi
pushq $0xa
popq %rcx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
movb $0x1, %bl
jmp 0x3463
cmpl $0x1, -0xf8(%rbp)
je 0x345b
andl $0x0, -0xf8(%rbp)
leaq -0x178(%rbp), %r14
movq %r14, %rdi
leaq -0x90(%rbp), %rsi
callq 0x3fbc
movq -0x38(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq %r14, %rdx
leaq -0xb0(%rbp), %rcx
movq %r15, %r8
movl %r13d, %r9d
leaq -0x100(%rbp), %rax
pushq %rax
leaq -0xf8(%rbp), %rax
pushq %rax
callq 0x8193
popq %rcx
popq %rdx
movq %r14, %rdi
movl %eax, %r14d
callq 0x4092
cmpl $0x1, -0xf8(%rbp)
setne %al
orb %al, %r14b
je 0x345b
callq 0x20c0
subq -0x68(%rbp), %rax
cvtsi2sd %rax, %xmm0
divsd 0x6c17(%rip), %xmm0     # 0xa050
movsd %xmm0, 0x20(%r15)
imulq $0x50, %r12, %rdi
addq -0x40(%rbp), %rdi
pushq $0xa
popq %rcx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
incl %r12d
movb $0x1, %bl
movl %r12d, -0x2c(%rbp)
jmp 0x3463
xorl %ebx, %ebx
pushq $0x1
popq %rax
movl %eax, -0x30(%rbp)
leaq -0x90(%rbp), %r14
movq %r14, %rdi
callq 0x4092
testb %bl, %bl
xorpd %xmm0, %xmm0
movq -0x48(%rbp), %rbx
jne 0x3203
cmpl $0x1, -0x30(%rbp)
movl -0x60(%rbp), %ebx
leaq -0x160(%rbp), %r14
leaq -0xf8(%rbp), %r15
je 0x3557
leaq -0x120(%rbp), %r13
movq %r13, %rdi
movq -0xb8(%rbp), %rsi
leaq 0x6bd2(%rip), %rdx      # 0xa087
callq 0x3f83
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x403c
leaq -0x90(%rbp), %r13
movq %r13, %rdi
movq %r15, %rsi
leaq 0x6bc4(%rip), %rdx      # 0xa0a0
callq 0x4013
movq %r15, %rdi
callq 0x2090
leaq -0x120(%rbp), %rdi
callq 0x2090
leaq -0x1b0(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x2160
movq -0x40(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq %r15, %rdx
callq 0x4fac
movq -0x50(%rbp), %r13
movq %r15, %rdi
callq 0x2090
movq -0xc8(%rbp), %rdi
callq 0x4092
movq %r13, %rdi
callq 0x20f0
movq -0xd0(%rbp), %rdi
callq 0x4092
movq -0x48(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
callq 0x2090
incl %ebx
leaq -0xb0(%rbp), %rdi
callq 0x4092
movq -0xd8(%rbp), %rsp
movq %r14, %rdi
callq 0x2090
jmp 0x30d8
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x35a9
movq %rax, %rbx
jmp 0x35c1
movq %rax, %rbx
jmp 0x362a
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
callq 0x2090
leaq -0x120(%rbp), %rdi
jmp 0x35c8
movq %rax, %rbx
leaq -0x1b0(%rbp), %rdi
callq 0x2090
leaq -0x90(%rbp), %rdi
callq 0x2090
jmp 0x362a
jmp 0x35f3
movq %rax, %rbx
jmp 0x35e5
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x2090
leaq -0x140(%rbp), %rdi
callq 0x2090
jmp 0x3636
movq %rax, %rbx
jmp 0x3636
movq %rax, %rbx
leaq -0x178(%rbp), %rdi
jmp 0x3612
jmp 0x361b
jmp 0x361b
movq %rax, %rbx
leaq -0x190(%rbp), %rdi
callq 0x4092
jmp 0x361e
jmp 0x361b
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x4092
leaq -0xb0(%rbp), %rdi
callq 0x4092
leaq -0x160(%rbp), %rdi
callq 0x2090
movq %rbx, %rdi
callq 0x2200