// File: /workspace/github_cpp_makefile_star2_O2/Matlock42[P]Jeopardy/jgameClass.cpp
// Function: Game::showQuestion(int)
bool Game::showQuestion(int aPrompt)
{	
	int lCatagory, lPrice;
	int lPrompt;
	bool lCorrect;
	// split 2 digit prompt into category and price (and make base zero)
	lCatagory = (aPrompt / 10 % 10) - 1;	// tens digit
	lPrice = (aPrompt % 10) - 1;			// ones digit

	// make sure selection is a valid choice
	if( lCatagory >= 0 && lCatagory < this->mSize && lPrice >= 0 && lPrice < this->mSize)
	{
		// make sure it hasn't been played before
		if(!mQuestionSet[lCatagory][lPrice]->hasBeenPlayed())
		{
			// display the question from the questionSet
			mQuestionSet[lCatagory][lPrice]->askQuestion();
			cout << "\n\n";
			mQuestionSet[lCatagory][lPrice]->showAnswers();
		}
		else // has been played
		{
			cout << "This question has already been played.\n";
			return false;
		}
	}
	else // not a valid choice
	{
		cout << "Invalid input: out of bounds.\n";
		return false;
	}

	// validate the input
	bool lInputError = false;
	do
	{
		cout << "What is your answer: \n";
	    if (cin >> lPrompt) // Sanitize input to an integer
	    {
	    	lInputError = false;
	    } 
	    else
	    {
	        cout << "Entered value is not an Integer.\n\n";
	        cin.clear();
	        cin.ignore(numeric_limits<streamsize>::max(), '\n');
	        lInputError = true;
	    }
	    // ensure that the prompt is 1,2,3,4
	    if (lPrompt > 4 || lPrompt < 1)
	    {
	    	cout << "Not a valid answer.\n\n";
	    	lInputError = true;
	    }
	} while (lInputError);

	// Play the user's answer
	lCorrect = mQuestionSet[lCatagory][lPrice]->play(lPrompt);
	
	if(lCorrect)
	{
		cout << "That is correct!\n";
		// add to the score
		mScore += ((lPrice + 1) * 100);
	}
	else
	{
		cout << "That is incorrect.\n";
	}
	
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %eax
pushq $0xa
popq %rcx
cltd
idivl %ecx
movl %edx, %r14d
cltd
idivl %ecx
testl %edx, %edx
jle 0x3096
movq %rdi, %rbx
movl 0x8(%rdi), %eax
cmpl %eax, %r14d
jg 0x3096
testl %r14d, %r14d
jle 0x3096
cmpl %eax, %edx
jg 0x3096
decl %edx
leal -0x1(%r14), %eax
movq 0x10(%rbx), %rcx
movl %edx, %r12d
movq (%rcx,%r12,8), %rcx
movl %eax, %r13d
movq (%rcx,%r13,8), %rdi
callq 0x58d4
testb %al, %al
je 0x30ba
movq 0x6f33(%rip), %rdi      # 0x9fc0
leaq 0x30a3(%rip), %rsi      # 0x6137
jmp 0x30a4
movq 0x6f23(%rip), %rdi      # 0x9fc0
leaq 0x30bb(%rip), %rsi      # 0x615f
callq 0x2210
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, -0x38(%rbp)
movq 0x10(%rbx), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%r13,8), %rdi
callq 0x591a
movq 0x6eea(%rip), %r15      # 0x9fc0
leaq 0x30d8(%rip), %rsi      # 0x61b5
movq %r15, %rdi
callq 0x2210
movq %rbx, -0x50(%rbp)
movq 0x10(%rbx), %rax
movq %r12, -0x48(%rbp)
movq (%rax,%r12,8), %rax
movq %r13, -0x40(%rbp)
movq (%rax,%r13,8), %rdi
callq 0x5932
leaq 0x3075(%rip), %r12      # 0x617e
movq 0x6ec0(%rip), %r13      # 0x9fd0
leaq -0x2c(%rbp), %rbx
leaq 0x309d(%rip), %r14      # 0x61b8
movq %r15, %rdi
movq %r12, %rsi
callq 0x2210
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2120
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x3182
movq %r15, %rdi
leaq 0x304c(%rip), %rsi      # 0x6195
callq 0x2210
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
xorl %esi, %esi
callq 0x2350
movq %r13, %rdi
movabsq $0x7fffffffffffffff, %rsi # imm = 0x7FFFFFFFFFFFFFFF
pushq $0xa
popq %rdx
callq 0x2130
movl -0x2c(%rbp), %eax
addl $-0x5, %eax
cmpl $-0x5, %eax
ja 0x311b
jmp 0x318d
movl -0x2c(%rbp), %esi
leal -0x5(%rsi), %eax
cmpl $-0x4, %eax
jae 0x319a
movq %r15, %rdi
movq %r14, %rsi
callq 0x2210
jmp 0x311b
movq -0x50(%rbp), %rbx
movq 0x10(%rbx), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x58e0
movq 0x6e02(%rip), %rdi      # 0x9fc0
testb %al, %al
je 0x31d7
leaq 0x3005(%rip), %rsi      # 0x61ce
callq 0x2210
imull $0x64, -0x38(%rbp), %eax
addl %eax, 0x4(%rbx)
jmp 0x31e3
leaq 0x3002(%rip), %rsi      # 0x61e0
callq 0x2210
movb $0x1, %al
jmp 0x30ab