// File: /workspace/github_cpp_makefile_star2_O1/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, -0x2c(%rbp)
movl %edi, %r14d
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x3bd2(%rip), %rdi      # 0x8fe0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %edx
movq 0x3bb7(%rip), %rdi      # 0x8fe0
leaq -0x50(%rbp), %rsi
callq 0x2210
xorl %r13d, %r13d
xorl %ebx, %ebx
xorl %r12d, %r12d
testl %r12d, %r12d
je 0x54fd
movl $0x2b, %edx
movq 0x3b81(%rip), %rdi      # 0x8fd0
leaq 0x1058(%rip), %rsi      # 0x64ae
callq 0x2150
movq 0x3b6e(%rip), %rdi      # 0x8fd0
movl %r14d, %esi
callq 0x21e0
movl $0x5, %edx
movq 0x3b5a(%rip), %rdi      # 0x8fd0
leaq 0x105d(%rip), %rsi      # 0x64da
callq 0x2150
movq 0x3b47(%rip), %rdi      # 0x8fd0
movl -0x2c(%rbp), %esi
callq 0x21e0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0xffd(%rip), %rsi       # 0x64a0
callq 0x2150
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20b0
movq 0x3b0a(%rip), %rcx      # 0x8fe0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %edx
movq 0x3aec(%rip), %rdi      # 0x8fe0
leaq -0x50(%rbp), %rsi
callq 0x2210
movq -0x48(%rbp), %rcx
testq %rcx, %rcx
je 0x554b
movq -0x50(%rbp), %rdx
xorl %esi, %esi
movb (%rdx,%rsi), %dil
testq %rsi, %rsi
sete %r8b
cmpb $0x2d, %dil
sete %r9b
movb $0x1, %al
testb %r9b, %r8b
je 0x552a
movb $0x1, %bl
jmp 0x5541
addb $-0x30, %dil
cmpb $0x9, %dil
ja 0x554b
leal (%r13,%r13,4), %r8d
movzbl %dil, %edi
leal (%rdi,%r8,2), %r13d
incq %rsi
cmpq %rsi, %rcx
jne 0x550c
jmp 0x554d
xorl %eax, %eax
movl %r13d, %ecx
negl %ecx
testb %bl, %al
cmovel %r13d, %ecx
cmpl %r14d, %ecx
setl %dl
cmpl -0x2c(%rbp), %ecx
setg %sil
orb %dl, %sil
andb %al, %sil
xorb $0x1, %sil
movzbl %bl, %ebx
incl %r12d
testb %al, %sil
movl $0x0, %eax
cmovel %eax, %ebx
movl %ecx, %r13d
cmovel %eax, %r13d
je 0x543a
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x55a6
movq -0x40(%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 0x55ba
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x55d6
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2140
movq %rbx, %rdi
callq 0x21f0