// File: /workspace/github_cpp_makefile_star2_O2/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 $0x168, %rsp            # imm = 0x168
movq %rsi, -0x40(%rbp)
movq %rdi, %r14
movq %rsp, -0x48(%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
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x252a
movsbl (%r15,%r13), %edi
callq 0x21c0
movb %al, (%r15,%r13)
incq %r13
jmp 0x2512
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x239c
leaq 0x1b7e(%rip), %rsi      # 0x40c2
leaq -0x190(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2230
movq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x2240
movq %rax, %rbx
movq %rax, %rdi
callq 0x2180
movl %eax, -0x2c(%rbp)
movq %rbx, -0x38(%rbp)
movq %rbx, %rdi
callq 0x2250
cmpl $0x2, %eax
je 0x25bd
movq 0x3a66(%rip), %rbx      # 0x5ff0
leaq 0x1b60(%rip), %rsi      # 0x40f1
movq %rbx, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x2200
movq -0x38(%rbp), %rdi
callq 0x2050
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2110
movq %rax, %rdi
callq 0x2200
cmpl $0x0, -0x2c(%rbp)
jle 0x276d
leaq -0x120(%rbp), %r14
leaq -0xe0(%rbp), %r15
xorl %esi, %esi
cmpl %esi, -0x2c(%rbp)
je 0x2788
movq -0x38(%rbp), %rdi
movl %esi, -0x30(%rbp)
xorl %edx, %edx
callq 0x2080
leaq -0xc0(%rbp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x2d5c
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
pushq $0x2
popq %rcx
callq 0x21f0
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2d97
movl %eax, %ebx
movq %r14, %rdi
callq 0x21a0
movq %r14, %rdi
leaq 0x1ad6(%rip), %rsi      # 0x410a
movl %ebx, %edx
xorl %eax, %eax
callq 0x2230
movq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x2240
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2080
leaq -0x80(%rbp), %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2d5c
movq %rbx, %rdi
callq 0x20e0
movq -0x38(%rbp), %r12
movq %r12, %rdi
movl -0x30(%rbp), %r13d
movl %r13d, %esi
xorl %edx, %edx
callq 0x2080
movq %rax, -0x60(%rbp)
movq %r12, %rdi
movl %r13d, %esi
pushq $0x1
popq %rdx
callq 0x2080
movq %rax, -0x58(%rbp)
movq %r12, %rdi
movl %r13d, %esi
pushq $0x3
popq %rdx
callq 0x2080
movq %rax, -0x50(%rbp)
movq %r12, %rdi
movl %r13d, %esi
pushq $0x4
popq %rdx
callq 0x2080
movq %rax, %r14
movq %r12, %rdi
movl %r13d, %esi
pushq $0x5
popq %rdx
callq 0x2080
movq %rax, %rbx
movq %r12, %rdi
movl %r13d, %esi
pushq $0x6
popq %rdx
callq 0x2080
movq %rax, %r12
leaq -0xa0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x2100
movq %r15, %rdi
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq %r14, %r8
movq %rbx, %r9
leaq -0xa0(%rbp), %rbx
pushq %rbx
pushq %r12
callq 0x27fa
popq %rax
popq %rcx
movq %rbx, %rdi
callq 0x21a0
movq 0x389c(%rip), %rbx      # 0x5fc0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2090
movq %rax, %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x2200
movq %r15, %rdi
callq 0x21a0
leaq -0x80(%rbp), %rdi
callq 0x21a0
leaq -0xc0(%rbp), %rdi
callq 0x21a0
movl -0x30(%rbp), %esi
incl %esi
leaq -0x120(%rbp), %r14
jmp 0x25d7
movq 0x384c(%rip), %rdi      # 0x5fc0
leaq 0x19b7(%rip), %rsi      # 0x4132
callq 0x2110
movq %rax, %rdi
callq 0x2200
movq -0x38(%rbp), %rdi
callq 0x20e0
movq -0x48(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
jmp 0x27d3
jmp 0x27da
jmp 0x27c4
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
jmp 0x27e1
jmp 0x27c4
jmp 0x27c4
movq %rax, %rbx
jmp 0x27e6
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x21a0
jmp 0x27dd
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x21a0
leaq -0xc0(%rbp), %rdi
callq 0x21a0
movq %rbx, %rdi
callq 0x2150