// File: 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
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, 0x8(%rax)
je 0x1d7d1
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x16010
testb $0x1, %al
jne 0x1d7cf
movq 0xb8a6(%rip), %rdi      # 0x28fc8
leaq 0x198f(%rip), %rsi      # 0x1f0b8
callq 0x3210
movq %rax, %rdi
leaq 0x1b42(%rip), %rsi      # 0x1f27a
callq 0x3210
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, -0x70(%rbp)
movq 0x8(%rax), %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x68(%rbp)
callq 0x15fc0
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x31e0
movq %rax, -0x60(%rbp)
jmp 0x1d76c
movq -0x60(%rbp), %rdi
leaq 0x1b37(%rip), %rsi      # 0x1f2ae
callq 0x3210
movq %rax, -0x78(%rbp)
jmp 0x1d782
movq -0x78(%rbp), %rdi
leaq 0x1946(%rip), %rsi      # 0x1f0d3
callq 0x3210
movq %rax, -0x80(%rbp)
jmp 0x1d798
movq -0x80(%rbp), %rdi
movq 0xb80d(%rip), %rsi      # 0x28fb0
callq 0x3240
jmp 0x1d7aa
leaq -0x30(%rbp), %rdi
callq 0x3448
jmp 0x1d7cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3448
jmp 0x1da6d
jmp 0x1d7d1
jmp 0x1d7d3
movq -0x58(%rbp), %rdi
addq $0x30, %rdi
callq 0x13490
movq -0x58(%rbp), %rdi
movl %eax, -0x40(%rbp)
addq $0x30, %rdi
callq 0x13450
testb $0x1, %al
jne 0x1d7f6
jmp 0x1d83b
movq 0xb7cb(%rip), %rdi      # 0x28fc8
leaq 0x18b4(%rip), %rsi      # 0x1f0b8
callq 0x3210
movq %rax, %rdi
leaq 0x2be8(%rip), %rsi      # 0x203fb
callq 0x3210
movq %rax, %rdi
leaq 0x18b1(%rip), %rsi      # 0x1f0d3
callq 0x3210
movq %rax, %rdi
movq 0xb77f(%rip), %rsi      # 0x28fb0
callq 0x3240
jmp 0x1da64
movq 0xb786(%rip), %rdi      # 0x28fc8
leaq 0x186f(%rip), %rsi      # 0x1f0b8
callq 0x3210
movq %rax, %rdi
leaq 0x2bba(%rip), %rsi      # 0x20412
callq 0x3210
movq %rax, %rdi
leaq 0x1888(%rip), %rsi      # 0x1f0ef
callq 0x3210
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl -0x40(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1d8ba
movq -0x58(%rbp), %rdi
addq $0x30, %rdi
movslq -0x44(%rbp), %rsi
callq 0x134b0
movq %rax, %rsi
movq 0xb72d(%rip), %rdi      # 0x28fc8
callq 0x31e0
movq %rax, %rdi
leaq 0x1ae2(%rip), %rsi      # 0x1f38c
callq 0x3210
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1d873
movq -0x58(%rbp), %rdi
addq $0x30, %rdi
movl -0x40(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x134b0
movq %rax, %rsi
movq 0xb6ee(%rip), %rdi      # 0x28fc8
callq 0x31e0
movq %rax, %rdi
leaq 0x187d(%rip), %rsi      # 0x1f166
callq 0x3210
movl $0x0, -0x48(%rbp)
movb $0x1, %al
cmpl $0x1, -0x48(%rbp)
movb %al, -0x81(%rbp)
jl 0x1d917
movl -0x48(%rbp), %eax
movl -0x40(%rbp), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
setg %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x1d926
jmp 0x1da13
movq 0xb69b(%rip), %rdi      # 0x28fc8
leaq 0x179f(%rip), %rsi      # 0x1f0d3
callq 0x3210
movq %rax, %rdi
leaq 0x2001(%rip), %rsi      # 0x1f944
callq 0x3210
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x1d9b9
movl -0x4c(%rbp), %esi
addl $0x1, %esi
movq 0xb664(%rip), %rdi      # 0x28fc8
callq 0x33b0
movq %rax, %rdi
leaq 0x1a1c(%rip), %rsi      # 0x1f38f
callq 0x3210
movq -0x58(%rbp), %rdi
movq %rax, -0x90(%rbp)
addq $0x30, %rdi
movslq -0x4c(%rbp), %rsi
callq 0x134b0
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x17bd(%rip), %rsi      # 0x1f166
callq 0x3210
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1d94f
movl -0x40(%rbp), %esi
addl $0x1, %esi
movq 0xb602(%rip), %rdi      # 0x28fc8
callq 0x33b0
movq %rax, %rdi
leaq 0x1795(%rip), %rsi      # 0x1f16a
callq 0x3210
movq %rax, %rdi
movl -0x40(%rbp), %esi
addl $0x2, %esi
callq 0x33b0
movq %rax, %rdi
leaq 0x19a5(%rip), %rsi      # 0x1f397
callq 0x3210
movq %rax, %rdi
movq 0xb5af(%rip), %rsi      # 0x28fb0
callq 0x3240
callq 0x175c0
movl %eax, -0x48(%rbp)
jmp 0x1d8f5
cmpl $0x1, -0x48(%rbp)
jl 0x1da34
movl -0x48(%rbp), %eax
cmpl -0x40(%rbp), %eax
jg 0x1da34
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x48(%rbp), %edx
movq (%rdi), %rax
callq *0x20(%rax)
jmp 0x1da5f
movl -0x48(%rbp), %eax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1da4c
movq -0x10(%rbp), %rdi
callq 0x13060
jmp 0x1da5d
movl -0x48(%rbp), %eax
movl -0x40(%rbp), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jne 0x1da5b
jmp 0x1da64
jmp 0x1da5d
jmp 0x1da5f
jmp 0x1d7d3
addq $0x90, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x33c0
nopw %cs:(%rax,%rax)