// File: /workspace/github_cpp_makefile_star2_O1/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 0x14906
callq 0xeca8
testb %al, %al
jne 0x14906
movq 0x776d(%rip), %rbx      # 0x1bfc8
leaq 0x1831(%rip), %rsi      # 0x16093
movl $0x5, %edx
movq %rbx, %rdi
callq 0x3210
leaq 0x1a09(%rip), %rsi      # 0x1627f
movl $0x33, %edx
movq %rbx, %rdi
callq 0x3210
movq 0x8(%r14), %rsi
leaq -0x68(%rbp), %r15
movq %r15, %rdi
callq 0xec70
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x3210
movq %rax, %rbx
leaq 0x1a07(%rip), %rsi      # 0x162b3
movl $0xd, %edx
movq %rax, %rdi
callq 0x3210
leaq 0x17ee(%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 0x14906
callq 0x31c0
movq 0x30(%r14), %rax
movq 0x38(%r14), %r15
cmpq %r15, %rax
je 0x14b76
subq %rax, %r15
movq 0x76a7(%rip), %r12      # 0x1bfc8
leaq 0x1a69(%rip), %rbx      # 0x16391
movq %r14, -0x38(%rbp)
shrq $0x5, %r15
movl $0x5, %edx
movq %r12, %rdi
leaq 0x1754(%rip), %rsi      # 0x16093
callq 0x3210
movl $0x16, %edx
movq %r12, %rdi
leaq 0x2ac4(%rip), %rsi      # 0x17417
callq 0x3210
movl $0x5, %edx
movq %r12, %rdi
leaq 0x1763(%rip), %rsi      # 0x160ca
callq 0x3210
leal -0x1(%r15), %eax
movl %eax, -0x2c(%rbp)
movq %r15, -0x48(%rbp)
cmpl $0x2, %r15d
movq %r12, %r13
jl 0x149b8
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 0x1498a
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 0x175d(%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 0x1699(%rip), %rsi      # 0x160ae
callq 0x3210
movl $0x1, %edx
movq %r12, %rdi
leaq 0x1f1b(%rip), %rsi      # 0x16944
callq 0x3210
testl %ebx, %ebx
jle 0x14aa2
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 0x1933(%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 0x16ad(%rip), %rsi      # 0x16141
callq 0x3210
addq $0x20, %r15
cmpq %r13, %rbx
jne 0x14a3b
movq %r12, %rdi
movl -0x30(%rbp), %esi
callq 0x3310
movq %rax, %r13
movl $0x1e, %edx
movq %rax, %rdi
leaq 0x1686(%rip), %rsi      # 0x16145
callq 0x3210
movq %r13, %rdi
movl -0x2c(%rbp), %esi
callq 0x3310
movq %rax, %r13
movl $0x19, %edx
movq %rax, %rdi
leaq 0x18bb(%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 0xf8fa
testl %eax, %eax
movq -0x48(%rbp), %rbx
jle 0x14a06
cmpl -0x2c(%rbp), %eax
jg 0x14a06
cmpl %ebx, %eax
jle 0x14b40
cmpl -0x30(%rbp), %eax
movq -0x38(%rbp), %r14
jne 0x14b5c
movq -0x40(%rbp), %rdi
callq 0xd66a
jmp 0x14b53
movq -0x38(%rbp), %r14
movq (%r14), %rcx
movq %r14, %rdi
movq -0x40(%rbp), %rsi
movl %eax, %edx
callq *0x20(%rcx)
leaq 0x1837(%rip), %rbx      # 0x16391
jmp 0x14b68
cmpl -0x2c(%rbp), %eax
leaq 0x182b(%rip), %rbx      # 0x16391
je 0x14be0
movq 0x38(%r14), %r15
subq 0x30(%r14), %r15
jne 0x1492c
movq 0x744b(%rip), %rbx      # 0x1bfc8
leaq 0x150f(%rip), %rsi      # 0x16093
movl $0x5, %edx
movq %rbx, %rdi
callq 0x3210
leaq 0x2868(%rip), %rsi      # 0x17400
movl $0x16, %edx
movq %rbx, %rdi
callq 0x3210
leaq 0x1502(%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 0x14c04
callq 0x31c0
movq %rbx, %rdi
callq 0x3320