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

    std::cout << NARRATOR_COLOR << "\nThe crew's lockers are located here.\n"
              << RESET;
    int lockerInput = 0;
    while (lockerInput < 1 || lockerInput > 2)
    {
        std::cout << "1. Open Captain's locker\n"
                  << "2. Return" << std::endl;

        lockerInput = getInteger();
    }

    if (lockerInput == 2)
    {
        return;   //exit room search
    }
    else
    {
        if (!markNelson.pack.checkFor(keyCard))
        {
            std::cout << NARRATOR_COLOR << "\nYou need a key card to open it."
                      << RESET << std::endl;
            //exit since user can't open the locker yet
            return;
        }
        else
        {
            std::cout << NARRATOR_COLOR
                      << "\nYou use your key card to open the locker"
                      << std::endl;
        }
    }

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

        if (roomItems.empty())
        {
            std::cout << NARRATOR_COLOR << "\nYour locker is empty."
                      << RESET << std::endl;
            return;
        }
        //Show what's in the locker
        std::cout << NARRATOR_COLOR << "\nThese items are in your locker: \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 + 1))
        {
            std::cout << RESET << "\n";
            for (int i = 0; i < size; i++)
            {
                std::cout << i+1 << ". Take " << roomItems[i] << ".\n";
            }
            std::cout << size + 1 << ". Return to previous menu"
                      << std::endl;
            input = getInteger();
        }

        //execute user choice
        if (input >= 1 && input <= size)
        {
            takeItem(markNelson, input);
        }
        else
        {
            std::cout << RESET;
            //exit menu
            return;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, -0x38(%rbp)
movq %rdi, %r14
movq 0x8(%rdi), %rdi
callq 0xa5da
testb %al, %al
jne 0x9fa9
movq 0xc078(%rip), %rdi      # 0x15fc8
leaq 0x6141(%rip), %rsi      # 0x10098
callq 0x31d0
leaq 0x62f7(%rip), %rsi      # 0x1025a
movq %rax, %rdi
callq 0x31d0
movq %rax, %rbx
movq 0x8(%r14), %rsi
leaq -0x80(%rbp), %r15
movq %r15, %rdi
callq 0xa5b4
movq %rbx, %rdi
movq %r15, %rsi
callq 0x31b0
leaq 0x62fe(%rip), %rsi      # 0x1028e
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
leaq -0x80(%rbp), %rdi
callq 0x3368
movq 0xc018(%rip), %rbx      # 0x15fc8
leaq 0x60e1(%rip), %rsi      # 0x10098
movq %rbx, %rdi
callq 0x31d0
leaq 0x62d6(%rip), %rsi      # 0x1029c
movq %rax, %rdi
callq 0x31d0
leaq 0x60de(%rip), %rsi      # 0x100b3
movq %rax, %rdi
callq 0x31d0
xorl %eax, %eax
leaq 0x62dd(%rip), %r15      # 0x102c3
leaq 0x62f0(%rip), %r12      # 0x102dd
leal -0x3(%rax), %ecx
cmpl $-0x3, %ecx
ja 0xa01a
movq %rbx, %rdi
movq %r15, %rsi
callq 0x31d0
movq %rax, %rdi
movq %r12, %rsi
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
callq 0xaed4
jmp 0x9fed
cmpl $0x2, %eax
je 0xa24d
leaq 0xc3f6(%rip), %rsi      # 0x16420
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
callq 0x3250
movq -0x38(%rbp), %rdi
movq %rbx, %rsi
callq 0x970a
movl %eax, %ebx
leaq -0x60(%rbp), %rdi
callq 0x3368
movq 0xbf74(%rip), %rdi      # 0x15fc8
leaq 0x603d(%rip), %rsi      # 0x10098
callq 0x31d0
testb %bl, %bl
je 0xa209
leaq 0x6299(%rip), %rsi      # 0x10308
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
movq 0xbf42(%rip), %r15      # 0x15fc8
movq 0x38(%r14), %rbx
movq 0x30(%r14), %r12
movq %rbx, %r13
subq %r12, %r13
movq %r15, %rdi
leaq 0x5ffa(%rip), %rsi      # 0x10098
callq 0x31d0
cmpq %r12, %rbx
je 0xa212
shrq $0x5, %r13
movq %rax, %rdi
leaq 0x628f(%rip), %rsi      # 0x10349
callq 0x31d0
movq %rax, %rdi
leaq 0x6006(%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 0xa112
movq 0x30(%r14), %rsi
addq %r13, %rsi
movq %r15, %rdi
callq 0x31b0
movq %rax, %rdi
leaq 0x6265(%rip), %rsi      # 0x1036c
callq 0x31d0
addq $0x20, %r13
jmp 0xa0e9
movslq %ebx, %rsi
shlq $0x5, %rsi
addq 0x30(%r14), %rsi
movq %r15, %rdi
callq 0x31b0
movq %rax, %rdi
leaq 0x6017(%rip), %rsi      # 0x10146
callq 0x31d0
movq -0x40(%rbp), %rcx
leal 0x1(%rcx), %eax
movl %eax, -0x2c(%rbp)
xorl %eax, %eax
testl %ecx, %ecx
movl $0x0, %r13d
cmovgl %ecx, %r13d
shlq $0x5, %r13
testl %eax, %eax
jle 0xa15d
cmpl -0x2c(%rbp), %eax
jle 0xa1f0
movq %r15, %rdi
leaq 0x5f4c(%rip), %rsi      # 0x100b3
callq 0x31d0
movq %rax, %rdi
leaq 0x67ae(%rip), %rsi      # 0x10924
callq 0x31d0
pushq $0x1
popq %r12
xorl %ebx, %ebx
movq %r15, %rdi
cmpq %rbx, %r13
je 0xa1c7
movl %r12d, %esi
callq 0x32f0
movq %rax, %rdi
leaq 0x61d4(%rip), %rsi      # 0x1036f
callq 0x31d0
movq 0x30(%r14), %rsi
addq %rbx, %rsi
movq %rax, %rdi
callq 0x31b0
movq %rax, %rdi
leaq 0x5f8d(%rip), %rsi      # 0x10146
callq 0x31d0
addq $0x20, %rbx
incl %r12d
jmp 0xa181
movl -0x2c(%rbp), %esi
callq 0x32f0
movq %rax, %rdi
leaq 0x619e(%rip), %rsi      # 0x10377
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
callq 0xaed4
jmp 0xa150
cmpl -0x40(%rbp), %eax
jg 0xa23a
movq (%r14), %rcx
movq %r14, %rdi
movq -0x38(%rbp), %rsi
movl %eax, %edx
callq *0x20(%rcx)
jmp 0xa086
leaq 0x60d7(%rip), %rsi      # 0x102e7
jmp 0xa219
leaq 0x6119(%rip), %rsi      # 0x10332
movq %rax, %rdi
callq 0x31d0
leaq 0x5e8b(%rip), %rsi      # 0x100b3
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
jmp 0xa24d
movq 0xbd87(%rip), %rdi      # 0x15fc8
leaq 0x5e6b(%rip), %rsi      # 0x100b3
callq 0x31d0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
jmp 0xa26c
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x3368
movq %rbx, %rdi
callq 0x3300
nop