// File: /workspace/github_cpp_makefile_star2_O2/dnegovan[P]Intruder-On-Donnar-V/Space.cpp
// Function: Space::searchRoom(Player&)
void Space::searchRoom(Player& markNelson)
{
    if (occupant)
    {
        if (!occupant->getAlive())
        {
            std::cout << NARRATOR_COLOR
                      << "\nAs you scan the room, your eyes move quickly past "
                      << occupant->getName() << "'s dead body." << RESET
                      << std::endl;
        }
    }

    while (true)
    {
        //cast from unsigned int to avoid compiler warnings
        int size = static_cast<int>(roomItems.size());

        if (roomItems.empty())
        {
            std::cout << NARRATOR_COLOR << "\nThere's nothing here."
                      << RESET << std::endl;
            return;
        }
        //Show what's in the room
        std::cout << NARRATOR_COLOR << "\nThis room contains: \n" << ITEM_COLOR;
        for (int i = 0; i < size - 1; i++)
        {
            std::cout << roomItems[i] << ", ";
        }
        std::cout << roomItems[size - 1] << ".\n";

        //menu for which item to take, or cancel
        int input = 0;
        while (input < 1 || input > (size + 2))
        {
            std::cout << RESET << "\n";
            for (int i = 0; i < size; i++)
            {
                std::cout << i+1 << ". Take " << roomItems[i] << ".\n";
            }

            //the last two options will always be size +1 and size +2
            std::cout << size + 1 << ". Show neutralization formula\n"
                      << size + 2 << ". Return to previous menu"
                      << std::endl;

            input = getInteger();
        }

        //execute user choice
        if (input >= 1 && input <= size)
        {
            //they want an item in the room
            takeItem(markNelson, input);
        }
        else if (input == (size + 1))
        {
            markNelson.pack.displayFormula();
        }
        else if (input == (size + 2))
        {
            //exit menu
            return;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, -0x38(%rbp)
movq %rdi, %r14
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0xe83f
callq 0xa5da
testb %al, %al
jne 0xe83f
movq 0x77f1(%rip), %rdi      # 0x15fc8
leaq 0x18ba(%rip), %rsi      # 0x10098
callq 0x31d0
leaq 0x1a70(%rip), %rsi      # 0x1025a
movq %rax, %rdi
callq 0x31d0
movq %rax, %rbx
movq 0x8(%r14), %rsi
leaq -0x60(%rbp), %r15
movq %r15, %rdi
callq 0xa5b4
movq %rbx, %rdi
movq %r15, %rsi
callq 0x31b0
leaq 0x1a77(%rip), %rsi      # 0x1028e
movq %rax, %rdi
callq 0x31d0
leaq 0x188d(%rip), %rsi      # 0x100b3
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
leaq -0x60(%rbp), %rdi
callq 0x3368
movq 0x7782(%rip), %r15      # 0x15fc8
movq 0x38(%r14), %rbx
movq 0x30(%r14), %r12
movq %rbx, %r13
subq %r12, %r13
movq %r15, %rdi
leaq 0x183a(%rip), %rsi      # 0x10098
callq 0x31d0
cmpq %r12, %rbx
je 0xea05
shrq $0x5, %r13
movq %rax, %rdi
leaq 0x2b78(%rip), %rsi      # 0x113f2
callq 0x31d0
movq %rax, %rdi
leaq 0x1846(%rip), %rsi      # 0x100cf
callq 0x31d0
movq %r13, -0x40(%rbp)
leal -0x1(%r13), %ebx
testl %ebx, %ebx
movl $0x0, %r12d
cmovgl %ebx, %r12d
shlq $0x5, %r12
xorl %r13d, %r13d
cmpq %r13, %r12
je 0xe8d2
movq 0x30(%r14), %rsi
addq %r13, %rsi
movq %r15, %rdi
callq 0x31b0
movq %rax, %rdi
leaq 0x1aa5(%rip), %rsi      # 0x1036c
callq 0x31d0
addq $0x20, %r13
jmp 0xe8a9
movslq %ebx, %rsi
shlq $0x5, %rsi
addq 0x30(%r14), %rsi
movq %r15, %rdi
callq 0x31b0
movq %rax, %rdi
leaq 0x1857(%rip), %rsi      # 0x10146
callq 0x31d0
movq -0x40(%rbp), %rcx
leal 0x2(%rcx), %eax
movl %eax, -0x2c(%rbp)
leal 0x1(%rcx), %eax
movl %eax, -0x30(%rbp)
xorl %eax, %eax
testl %ecx, %ecx
movl $0x0, %r13d
cmovgl %ecx, %r13d
shlq $0x5, %r13
testl %eax, %eax
jle 0xe923
cmpl -0x2c(%rbp), %eax
jle 0xe9ce
movq %r15, %rdi
leaq 0x1786(%rip), %rsi      # 0x100b3
callq 0x31d0
movq %rax, %rdi
leaq 0x1fe8(%rip), %rsi      # 0x10924
callq 0x31d0
pushq $0x1
popq %rbx
xorl %r12d, %r12d
movq %r15, %rdi
cmpq %r12, %r13
je 0xe98b
movl %ebx, %esi
callq 0x32f0
movq %rax, %rdi
leaq 0x1a0f(%rip), %rsi      # 0x1036f
callq 0x31d0
movq 0x30(%r14), %rsi
addq %r12, %rsi
movq %rax, %rdi
callq 0x31b0
movq %rax, %rdi
leaq 0x17c8(%rip), %rsi      # 0x10146
callq 0x31d0
addq $0x20, %r12
incl %ebx
jmp 0xe947
movl -0x30(%rbp), %esi
callq 0x32f0
movq %rax, %rdi
leaq 0x17ad(%rip), %rsi      # 0x1014a
callq 0x31d0
movq %rax, %rdi
movl -0x2c(%rbp), %esi
callq 0x32f0
movq %rax, %rdi
leaq 0x19c0(%rip), %rsi      # 0x10377
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
callq 0xaed4
jmp 0xe916
cmpl -0x40(%rbp), %eax
jle 0xe9e6
cmpl -0x30(%rbp), %eax
jne 0xe9fa
movq -0x38(%rbp), %rdi
callq 0x9582
jmp 0xe846
movq (%r14), %rcx
movq %r14, %rdi
movq -0x38(%rbp), %rsi
movl %eax, %edx
callq *0x20(%rcx)
jmp 0xe846
cmpl -0x2c(%rbp), %eax
jne 0xe846
jmp 0xea2b
leaq 0x29cf(%rip), %rsi      # 0x113db
movq %rax, %rdi
callq 0x31d0
leaq 0x1698(%rip), %rsi      # 0x100b3
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x3368
movq %rbx, %rdi
callq 0x3300