// File: /workspace/github_cpp_makefile_star2_O1/allasandeep[P]LocationBoundaryFinder/prog2.cc
// Function: getRegionData(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, pg_conn*)
void getRegionData(string str, PGconn *db)
{
	char query[100];
	char temp[str.length() + 1];
	//Converting the string to lowercase
	std::transform(str.begin(), str.end(), str.begin(), ::tolower);
	//Copying the string to char*
	strcpy(temp , str.c_str());
	//Deleting the spacing in the char*
	delSpaces(temp);
	PGresult * result = nullptr;
	//Psql Query by concatinating with c++ variables
	sprintf(query,"select *from region where lower(iname) = '%s';",temp);
	//Executing the query and storing the result in result.
	result = PQexec(db,query);
	//Number of tuples in the result
	int nrows = PQntuples(result);

	//Checking 
	if( PGRES_TUPLES_OK != PQresultStatus(result)) 
	{
		//Error	
		cerr << "Query is not successfull" << endl;
		cerr << PQresultErrorMessage(result) << endl;
	}

	if(nrows > 0)
	{
		for(int r = 0; r < nrows; r++)
		{			
			string sID(PQgetvalue(result,r,0));
			int stateId = stoi(sID.substr(0,2));
			char queryTemp[50];
			PGresult * resultTemp = nullptr;
			//Psql Query by concatinating with c++ variables
			sprintf(queryTemp,"select iname from region where id = %d;",stateId);
			//Executing the query and storing the result in result.
			resultTemp = PQexec(db,queryTemp);
			string stateName = PQgetvalue(resultTemp,0,0);
			PQclear(resultTemp);
			string outputString = toDecimalDegree(PQgetvalue(result, r, 0),PQgetvalue(result, r, 1),PQgetvalue(result, r, 3),PQgetvalue(result, r, 4),PQgetvalue(result, r, 5),PQgetvalue(result, r, 6), stateName);
			cout<<outputString<<endl;
			cout<<endl;
		}
	}
	else
		cout<<"No tuples found with the given name"<<endl;

	//Clearing the result
	PQclear(result);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, -0x40(%rbp)
movq %rdi, %r14
movq %rsp, -0xa8(%rbp)
movq 0x8(%rdi), %rax
movq %rsp, %rbx
addq $0x10, %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
movq 0x8(%rdi), %r15
testq %r15, %r15
je 0x2606
movq (%r14), %r12
xorl %r13d, %r13d
movsbl (%r12,%r13), %edi
callq 0x21d0
movb %al, (%r12,%r13)
incq %r13
cmpq %r13, %r15
jne 0x25f0
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x20d0
xorl %ecx, %ecx
movq %rbx, %rax
movzbl (%rax), %edx
cmpl $0x20, %edx
je 0x262b
movslq %ecx, %rsi
testl %edx, %edx
je 0x2630
leal 0x1(%rsi), %ecx
movb %dl, (%rbx,%rsi)
incq %rax
jmp 0x2616
movb $0x0, (%rbx,%rsi)
leaq 0x1a87(%rip), %rsi      # 0x40c2
leaq -0x180(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2250
movq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x2280
movq %rax, %rbx
movq %rax, %rdi
callq 0x2190
movl %eax, -0x2c(%rbp)
movq %rbx, -0x38(%rbp)
movq %rbx, %rdi
callq 0x2290
cmpl $0x2, %eax
je 0x272b
movq 0x396b(%rip), %rbx      # 0x5ff0
leaq 0x1a65(%rip), %rsi      # 0x40f1
movl $0x18, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x20e0
movq -0x38(%rbp), %rdi
callq 0x2070
testq %rax, %rax
je 0x26ed
movq %rax, %r14
movq %rax, %rdi
callq 0x20c0
movq 0x3910(%rip), %rdi      # 0x5ff0
movq %r14, %rsi
movq %rax, %rdx
callq 0x2200
jmp 0x2704
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2270
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x20e0
cmpl $0x0, -0x2c(%rbp)
jle 0x2a01
xorl %esi, %esi
movq -0x38(%rbp), %rdi
movl %esi, -0x30(%rbp)
xorl %edx, %edx
callq 0x20a0
leaq -0xd8(%rbp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
leaq -0x110(%rbp), %r14
movq %r14, %rdx
callq 0x363e
movl $0x2, %ecx
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2210
movq -0x110(%rbp), %r14
callq 0x2240
movq %rax, %r12
movl (%rax), %r15d
movl $0x0, (%rax)
movq %r14, %rdi
leaq -0x60(%rbp), %rsi
movl $0xa, %edx
callq 0x21e0
cmpq %r14, -0x60(%rbp)
je 0x2a62
movq %rax, %rbx
movslq %ebx, %rax
cmpq %rbx, %rax
jne 0x2a6e
movl (%r12), %eax
cmpl $0x22, %eax
je 0x2a6e
testl %eax, %eax
jne 0x27ca
movl %r15d, (%r12)
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0x27ec
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x2060
leaq -0x110(%rbp), %r14
movq %r14, %rdi
leaq 0x190d(%rip), %rsi      # 0x410a
movl %ebx, %edx
xorl %eax, %eax
callq 0x2250
movq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x2280
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x20a0
leaq -0x60(%rbp), %rdi
movq %rax, %rsi
leaq -0xa0(%rbp), %rdx
callq 0x363e
movq %rbx, %rdi
callq 0x20f0
movq -0x38(%rbp), %r12
movq %r12, %rdi
movl -0x30(%rbp), %r13d
movl %r13d, %esi
xorl %edx, %edx
callq 0x20a0
movq %rax, -0xb8(%rbp)
movq %r12, %rdi
movl %r13d, %esi
movl $0x1, %edx
callq 0x20a0
movq %rax, -0xb0(%rbp)
movq %r12, %rdi
movl %r13d, %esi
movl $0x3, %edx
callq 0x20a0
movq %rax, %rbx
movq %r12, %rdi
movl %r13d, %esi
movl $0x4, %edx
callq 0x20a0
movq %rax, %r14
movq %r12, %rdi
movl %r13d, %esi
movl $0x5, %edx
callq 0x20a0
movq %rax, %r15
movq %r12, %rdi
movl %r13d, %esi
movl $0x6, %edx
callq 0x20a0
movq %rax, %r12
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rdi
callq 0x372c
leaq -0xa0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
movq %rbx, %rcx
movq %r14, %r8
movq %r15, %r9
leaq -0x80(%rbp), %rax
pushq %rax
pushq %r12
callq 0x2b37
addq $0x10, %rsp
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x291e
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2060
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
movq 0x3695(%rip), %rdi      # 0x5fc8
callq 0x2200
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x20e0
movq 0x365f(%rip), %rcx      # 0x5fc8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %esi
movq 0x3641(%rip), %rdi      # 0x5fc8
callq 0x2110
movq %rax, %rdi
callq 0x20e0
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x29b6
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2060
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x29cf
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2060
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x29f1
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x2060
movl -0x30(%rbp), %esi
incl %esi
cmpl %esi, -0x2c(%rbp)
jne 0x2737
jmp 0x2a43
movq 0x35c0(%rip), %rbx      # 0x5fc8
leaq 0x1723(%rip), %rsi      # 0x4132
movl $0x23, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x20e0
movq -0x38(%rbp), %rdi
callq 0x20f0
movq -0xa8(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1778(%rip), %rdi      # 0x41e1
callq 0x2080
leaq 0x176c(%rip), %rdi      # 0x41e1
callq 0x2150
jmp 0x2a80
jmp 0x2a80
jmp 0x2a80
movq %rax, %rbx
jmp 0x2b0d
jmp 0x2af1
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x2af4
movq -0x70(%rbp), %rsi
jmp 0x2ae7
movq %rax, %rbx
cmpl $0x0, (%r12)
jne 0x2aae
movl %r15d, (%r12)
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0x2b0d
movq -0x100(%rbp), %rsi
jmp 0x2b05
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x2af4
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2060
jmp 0x2af4
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x2b0d
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2060
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x2b2f
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x2060
movq %rbx, %rdi
callq 0x2160