// File: /workspace/github_cpp_makefile_star2_O3/cb92[P]Battleship/utils.cpp
// Function: getInt(int, int)
int getInt(int min, int max)
{
	std::string retString;
	std::getline(std::cin, retString);
	bool isGoodInput=false;
	int nIter=0;
	char tempChar;
	bool isNeg=false;
	int retInt=0;

	while (!isGoodInput)
	{
		isGoodInput = true;
		// prompt fot input again if input was bad
		if (nIter>0)
		{
			std::cout<<"Bad input! Please enter an integer between "<<min;
			std::cout<<" and "<<max<<"."<<std::endl;
			std::getline(std::cin, retString);
		}
		if (retString.length()>0) 
		{
			// process the string, char by char, to see if it's a numeric
			for (int i=0; i<retString.length(); i++)
			{
				tempChar = static_cast<char>(retString[i]);
				// if the first character is a negatve, note it, and continue
				if (i==0 & tempChar=='-')
				{
					isNeg=true;
				}
				// if char is numeric, update the integer to be returned
				else 
				{
					if (tempChar>=ASCII_INT_MIN && tempChar<=ASCII_INT_MAX)
					{
						retInt = retInt*10+(static_cast<int>(tempChar)-
																ASCII_INT_MIN);
					}
					else // if any non-ints encountered, break loop
					{
						isGoodInput = false;
						break;
					}
				}
			}
		}
		// zero length inputs are bad inputs
		else
		{
			isGoodInput=false;
		}

		// if negative, mutiply by -1
		if (isGoodInput && isNeg)
		{
			retInt = (-1)*retInt;
		}
		// check that int is between limits
		if (isGoodInput && (retInt<min || retInt>max))
		{
			isGoodInput = false;
		}

		// if input was bad, reset trackers and start over again
		if (!isGoodInput) 
		{
			retInt=0;
			isNeg=false;
		}
			
		nIter++;
	}

	return retInt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebx
movl %edi, %r14d
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x3be3(%rip), %rdi      # 0x8fe0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %edx
movq 0x3bc8(%rip), %rdi      # 0x8fe0
leaq -0x48(%rbp), %rsi
callq 0x2210
xorl %r15d, %r15d
movq 0x3ba5(%rip), %r12      # 0x8fd0
testl %r15d, %r15d
je 0x54de
movl $0x2b, %edx
movq %r12, %rdi
leaq 0x106b(%rip), %rsi      # 0x64ae
callq 0x2150
movq %r12, %rdi
movl %r14d, %esi
callq 0x21e0
movl $0x5, %edx
movq %r12, %rdi
leaq 0x1078(%rip), %rsi      # 0x64da
callq 0x2150
movq %r12, %rdi
movl %ebx, %esi
callq 0x21e0
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x101d(%rip), %rsi      # 0x64a0
callq 0x2150
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20b0
movq 0x3b29(%rip), %rcx      # 0x8fe0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %edx
movq 0x3b0b(%rip), %rdi      # 0x8fe0
leaq -0x48(%rbp), %rsi
callq 0x2210
movq -0x40(%rbp), %rsi
testq %rsi, %rsi
je 0x552e
xorl %edi, %edi
movq -0x48(%rbp), %r8
xorl %edx, %edx
xorl %ecx, %ecx
movb (%r8,%rdi), %r9b
testq %rdi, %rdi
sete %r10b
cmpb $0x2d, %r9b
sete %r11b
movb $0x1, %al
testb %r11b, %r10b
je 0x550f
movb $0x1, %cl
jmp 0x5524
addb $-0x30, %r9b
cmpb $0x9, %r9b
ja 0x5536
leal (%rdx,%rdx,4), %edx
movzbl %r9b, %r9d
leal (%r9,%rdx,2), %edx
incq %rdi
cmpq %rdi, %rsi
jne 0x54f1
jmp 0x5538
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x5538
xorl %eax, %eax
movl %edx, %r13d
negl %r13d
testb %cl, %al
cmovel %edx, %r13d
cmpl %r14d, %r13d
setl %cl
cmpl %ebx, %r13d
setg %dl
orb %cl, %dl
xorb $0x1, %dl
incl %r15d
testb %dl, %al
je 0x542b
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5579
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2140
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x558d
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x55a9
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2140
movq %rbx, %rdi
callq 0x21f0