// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movq %rsi, -0x40(%rbp)
movq %rdi, %r14
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x146be
callq 0xeaf8
testb %al, %al
jne 0x146be
movq 0x79b5(%rip), %rbx      # 0x1bfc8
leaq 0x1a79(%rip), %rsi      # 0x16093
movl $0x5, %edx
movq %rbx, %rdi
callq 0x3210
leaq 0x1c51(%rip), %rsi      # 0x1627f
movl $0x33, %edx
movq %rbx, %rdi
callq 0x3210
movq 0x8(%r14), %rsi
leaq -0x68(%rbp), %r15
movq %r15, %rdi
callq 0xeac0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x3210
movq %rax, %rbx
leaq 0x1c4f(%rip), %rsi      # 0x162b3
movl $0xd, %edx
movq %rax, %rdi
callq 0x3210
leaq 0x1a36(%rip), %rsi      # 0x160ae
movl $0x4, %edx
movq %rbx, %rdi
callq 0x3210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3140
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x146be
callq 0x31c0
movq 0x30(%r14), %rax
movq 0x38(%r14), %r15
cmpq %r15, %rax
je 0x1492e
subq %rax, %r15
movq 0x78ef(%rip), %r12      # 0x1bfc8
leaq 0x1cb1(%rip), %rbx      # 0x16391
movq %r14, -0x38(%rbp)
shrq $0x5, %r15
movl $0x5, %edx
movq %r12, %rdi
leaq 0x199c(%rip), %rsi      # 0x16093
callq 0x3210
movl $0x16, %edx
movq %r12, %rdi
leaq 0x2d0c(%rip), %rsi      # 0x17417
callq 0x3210
movl $0x5, %edx
movq %r12, %rdi
leaq 0x19ab(%rip), %rsi      # 0x160ca
callq 0x3210
leal -0x1(%r15), %eax
movl %eax, -0x2c(%rbp)
movq %r15, -0x48(%rbp)
cmpl $0x2, %r15d
movq %r12, %r13
jl 0x14770
movl -0x2c(%rbp), %r15d
movl $0x8, %r12d
movq 0x30(%r14), %rax
movq -0x8(%rax,%r12), %rsi
movq (%rax,%r12), %rdx
movq %r13, %rdi
callq 0x3210
movl $0x2, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3210
addq $0x20, %r12
decq %r15
jne 0x14742
movslq -0x2c(%rbp), %rax
movq 0x30(%r14), %rcx
shlq $0x5, %rax
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
movq %r13, %rdi
callq 0x3210
movl $0x2, %edx
movq %rax, %rdi
leaq 0x19a5(%rip), %rsi      # 0x16141
callq 0x3210
movq -0x48(%rbp), %rbx
leal 0x2(%rbx), %eax
movl %eax, -0x2c(%rbp)
leal 0x1(%rbx), %eax
movl %eax, -0x30(%rbp)
movl %ebx, %r14d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movq %r13, %r12
movl $0x4, %edx
movq %r12, %rdi
leaq 0x18e1(%rip), %rsi      # 0x160ae
callq 0x3210
movl $0x1, %edx
movq %r12, %rdi
leaq 0x2163(%rip), %rsi      # 0x16944
callq 0x3210
testl %ebx, %ebx
jle 0x1485a
movl $0x8, %r15d
xorl %r13d, %r13d
incq %r13
movq %r12, %rdi
movl %r13d, %esi
callq 0x3310
movq %r14, %rbx
movq %r12, %r14
movq %rax, %r12
movl $0x7, %edx
movq %rax, %rdi
leaq 0x1b7b(%rip), %rsi      # 0x16394
callq 0x3210
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x8(%rax,%r15), %rsi
movq (%rax,%r15), %rdx
movq %r12, %rdi
movq %r14, %r12
movq %rbx, %r14
callq 0x3210
movl $0x2, %edx
movq %rax, %rdi
leaq 0x18f5(%rip), %rsi      # 0x16141
callq 0x3210
addq $0x20, %r15
cmpq %r13, %rbx
jne 0x147f3
movq %r12, %rdi
movl -0x30(%rbp), %esi
callq 0x3310
movq %rax, %r13
movl $0x1e, %edx
movq %rax, %rdi
leaq 0x18ce(%rip), %rsi      # 0x16145
callq 0x3210
movq %r13, %rdi
movl -0x2c(%rbp), %esi
callq 0x3310
movq %rax, %r13
movl $0x19, %edx
movq %rax, %rdi
leaq 0x1b03(%rip), %rsi      # 0x1639c
callq 0x3210
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3140
callq 0xf6ef
testl %eax, %eax
movq -0x48(%rbp), %rbx
jle 0x147be
cmpl -0x2c(%rbp), %eax
jg 0x147be
cmpl %ebx, %eax
jle 0x148f8
cmpl -0x30(%rbp), %eax
movq -0x38(%rbp), %r14
jne 0x14914
movq -0x40(%rbp), %rdi
callq 0xd478
jmp 0x1490b
movq -0x38(%rbp), %r14
movq (%r14), %rcx
movq %r14, %rdi
movq -0x40(%rbp), %rsi
movl %eax, %edx
callq *0x20(%rcx)
leaq 0x1a7f(%rip), %rbx      # 0x16391
jmp 0x14920
cmpl -0x2c(%rbp), %eax
leaq 0x1a73(%rip), %rbx      # 0x16391
je 0x14998
movq 0x38(%r14), %r15
subq 0x30(%r14), %r15
jne 0x146e4
movq 0x7693(%rip), %rbx      # 0x1bfc8
leaq 0x1757(%rip), %rsi      # 0x16093
movl $0x5, %edx
movq %rbx, %rdi
callq 0x3210
leaq 0x2ab0(%rip), %rsi      # 0x17400
movl $0x16, %edx
movq %rbx, %rdi
callq 0x3210
leaq 0x174a(%rip), %rsi      # 0x160ae
movl $0x4, %edx
movq %rbx, %rdi
callq 0x3210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3140
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x149bc
callq 0x31c0
movq %rbx, %rdi
callq 0x3320