// File: /workspace/github_cpp_makefile_star2_O3/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 %rsp, -0xa8(%rbp)
movq 0x8(%rdi), %rax
movq %rsp, %rbx
addq $0x10, %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
movq (%rdi), %r15
movq 0x8(%rdi), %r12
testq %r12, %r12
je 0x2609
movq %rdi, %r14
xorl %r13d, %r13d
movsbl (%r15,%r13), %edi
callq 0x21d0
movb %al, (%r15,%r13)
incq %r13
cmpq %r13, %r12
jne 0x25f0
movq (%r14), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x20d0
xorl %ecx, %ecx
movq %rbx, %rax
movzbl (%rax), %edx
cmpl $0x20, %edx
je 0x262e
movslq %ecx, %rsi
testl %edx, %edx
je 0x2633
leal 0x1(%rsi), %ecx
movb %dl, (%rbx,%rsi)
incq %rax
jmp 0x2619
movb $0x0, (%rbx,%rsi)
leaq 0x1a84(%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 0x272e
movq 0x3968(%rip), %rbx      # 0x5ff0
leaq 0x1a62(%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 0x26f0
movq %rax, %r14
movq %rax, %rdi
callq 0x20c0
movq 0x390d(%rip), %rdi      # 0x5ff0
movq %r14, %rsi
movq %rax, %rdx
callq 0x2200
jmp 0x2707
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 0x2a04
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 0x3638
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 0x2a65
movq %rax, %rbx
movslq %ebx, %rax
cmpq %rbx, %rax
jne 0x2a71
movl (%r12), %eax
cmpl $0x22, %eax
je 0x2a71
testl %eax, %eax
jne 0x27cd
movl %r15d, (%r12)
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0x27ef
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x2060
leaq -0x110(%rbp), %r14
movq %r14, %rdi
leaq 0x190a(%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 0x3638
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 0x3726
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 0x2b3a
addq $0x10, %rsp
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x2921
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2060
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
movq 0x3692(%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 0x365c(%rip), %rcx      # 0x5fc8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %esi
movq 0x363e(%rip), %rdi      # 0x5fc8
callq 0x2110
movq %rax, %rdi
callq 0x20e0
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x29b9
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2060
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x29d2
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2060
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x29f4
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x2060
movl -0x30(%rbp), %esi
incl %esi
cmpl %esi, -0x2c(%rbp)
jne 0x273a
jmp 0x2a46
movq 0x35bd(%rip), %rbx      # 0x5fc8
leaq 0x1720(%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 0x1775(%rip), %rdi      # 0x41e1
callq 0x2080
leaq 0x1769(%rip), %rdi      # 0x41e1
callq 0x2150
jmp 0x2a83
jmp 0x2a83
jmp 0x2a83
movq %rax, %rbx
jmp 0x2b10
jmp 0x2af4
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x2af7
movq -0x70(%rbp), %rsi
jmp 0x2aea
movq %rax, %rbx
cmpl $0x0, (%r12)
jne 0x2ab1
movl %r15d, (%r12)
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0x2b10
movq -0x100(%rbp), %rsi
jmp 0x2b08
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x2af7
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2060
jmp 0x2af7
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x2b10
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2060
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x2b32
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x2060
movq %rbx, %rdi
callq 0x2160