// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movq %rsi, -0x38(%rbp)
movq %rdi, %r13
movq 0x8(%rdi), %rdi
callq 0xeaf8
testb %al, %al
jne 0xe0f6
movq 0xdf6c(%rip), %rbx      # 0x1bfc8
leaq 0x8030(%rip), %rsi      # 0x16093
movl $0x5, %edx
movq %rbx, %rdi
callq 0x3210
leaq 0x8208(%rip), %rsi      # 0x1627f
movl $0x33, %edx
movq %rbx, %rdi
callq 0x3210
movq 0x8(%r13), %rsi
leaq -0x90(%rbp), %r15
movq %r15, %rdi
callq 0xeac0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x3210
movq %rax, %rbx
leaq 0x8203(%rip), %rsi      # 0x162b3
movl $0xd, %edx
movq %rax, %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 -0x80(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xe0f6
callq 0x31c0
movq 0xdecb(%rip), %rbx      # 0x1bfc8
leaq 0x7f8f(%rip), %rsi      # 0x16093
movl $0x5, %edx
movq %rbx, %rdi
callq 0x3210
leaq 0x81a9(%rip), %rsi      # 0x162c1
movl $0x26, %edx
movq %rbx, %rdi
callq 0x3210
leaq 0x7f82(%rip), %rsi      # 0x160ae
movl $0x4, %edx
movq %rbx, %rdi
callq 0x3210
leaq 0x81a8(%rip), %r15      # 0x162e8
leaq 0x81bb(%rip), %r12      # 0x16302
movl $0x19, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3210
movl $0x9, %edx
movq %rbx, %rdi
movq %r12, %rsi
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
callq 0xf6ef
leal -0x3(%rax), %ecx
cmpl $-0x2, %ecx
jb 0xe147
cmpl $0x2, %eax
je 0xe519
leaq -0x60(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0xe27d(%rip), %rsi      # 0x1c430
movq 0xe27e(%rip), %rdx      # 0x1c438
addq %rsi, %rdx
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
callq 0xd7ca
movq -0x38(%rbp), %rdi
movq %rbx, %rsi
callq 0xd686
movl %eax, %ebx
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0xe1e5
callq 0x31c0
movq 0xdddc(%rip), %r14      # 0x1bfc8
leaq 0x7ea0(%rip), %rsi      # 0x16093
movl $0x5, %edx
movq %r14, %rdi
callq 0x3210
testb %bl, %bl
je 0xe4ca
leaq 0x811e(%rip), %rsi      # 0x1632d
movl $0x29, %edx
movq %r14, %rdi
callq 0x3210
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3140
movq 0x30(%r13), %rax
movq 0x38(%r13), %r14
cmpq %r14, %rax
je 0xe46b
subq %rax, %r14
movq 0xdd6a(%rip), %r15      # 0x1bfc8
movq %r13, -0x48(%rbp)
shrq $0x5, %r14
movl $0x5, %edx
movq %r15, %rdi
leaq 0x7e1e(%rip), %rsi      # 0x16093
callq 0x3210
movl $0x22, %edx
movq %r15, %rdi
leaq 0x80e5(%rip), %rsi      # 0x1636e
callq 0x3210
movl $0x5, %edx
movq %r15, %rdi
leaq 0x7e2d(%rip), %rsi      # 0x160ca
callq 0x3210
leal -0x1(%r14), %eax
movl %eax, -0x2c(%rbp)
movq %r14, -0x40(%rbp)
cmpl $0x2, %r14d
movq %r15, %r12
leaq 0x80d6(%rip), %rbx      # 0x16391
jl 0xe2f5
movl -0x2c(%rbp), %r14d
movl $0x8, %r15d
movq 0x30(%r13), %rax
movq -0x8(%rax,%r15), %rsi
movq (%rax,%r15), %rdx
movq %r12, %rdi
callq 0x3210
movl $0x2, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3210
addq $0x20, %r15
decq %r14
jne 0xe2c7
movslq -0x2c(%rbp), %rax
movq 0x30(%r13), %rcx
shlq $0x5, %rax
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
movq %r12, %rdi
callq 0x3210
movl $0x2, %edx
movq %rax, %rdi
leaq 0x7e20(%rip), %rsi      # 0x16141
callq 0x3210
movq -0x40(%rbp), %rbx
leal 0x1(%rbx), %r14d
movl %ebx, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, -0x50(%rbp)
movq %r12, %r15
movl %r14d, -0x2c(%rbp)
movl $0x4, %edx
movq %r15, %rdi
leaq 0x7d5f(%rip), %rsi      # 0x160ae
callq 0x3210
movl $0x1, %edx
movq %r15, %rdi
leaq 0x85e1(%rip), %rsi      # 0x16944
callq 0x3210
testl %ebx, %ebx
movq -0x50(%rbp), %r12
jle 0xe3d9
movl $0x8, %ebx
xorl %r13d, %r13d
incq %r13
movq %r15, %rdi
movl %r13d, %esi
callq 0x3310
movq %r15, %r14
movq %rax, %r15
movl $0x7, %edx
movq %rax, %rdi
leaq 0x7ff9(%rip), %rsi      # 0x16394
callq 0x3210
movq -0x48(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x8(%rax,%rbx), %rsi
movq (%rax,%rbx), %rdx
movq %r15, %rdi
movq %r14, %r15
callq 0x3210
movl $0x2, %edx
movq %rax, %rdi
leaq 0x7d76(%rip), %rsi      # 0x16141
callq 0x3210
addq $0x20, %rbx
cmpq %r13, %r12
jne 0xe378
movq %r15, %rdi
movl -0x2c(%rbp), %r14d
movl %r14d, %esi
callq 0x3310
movq %rax, %r13
movl $0x19, %edx
movq %rax, %rdi
leaq 0x7fa2(%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 -0x40(%rbp), %rbx
jle 0xe340
cmpl %r14d, %eax
jg 0xe340
cmpl %ebx, %eax
jg 0xe528
movq -0x48(%rbp), %r13
movq (%r13), %rcx
movq %r13, %rdi
movq -0x38(%rbp), %rsi
movl %eax, %edx
callq *0x20(%rcx)
movq 0x38(%r13), %r14
subq 0x30(%r13), %r14
jne 0xe262
leaq 0x7c21(%rip), %rsi      # 0x16093
movl $0x5, %edx
movq 0xdb4a(%rip), %rbx      # 0x1bfc8
movq %rbx, %rdi
callq 0x3210
leaq 0x7eca(%rip), %rsi      # 0x16357
movl $0x16, %edx
movq %rbx, %rdi
callq 0x3210
leaq 0x7c0d(%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
jmp 0xe50c
leaq 0x7e3b(%rip), %rsi      # 0x1630c
movl $0x20, %edx
movq %r14, %rdi
callq 0x3210
leaq 0x7bc9(%rip), %rsi      # 0x160ae
movl $0x4, %edx
movq %r14, %rdi
callq 0x3210
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3140
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xda99(%rip), %rdi      # 0x1bfc8
leaq 0x7b78(%rip), %rsi      # 0x160ae
movl $0x4, %edx
callq 0x3210
jmp 0xe519
movq %rax, %rbx
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
jne 0xe560
jmp 0xe565
movq %rax, %rbx
leaq -0x80(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xe565
callq 0x31c0
movq %rbx, %rdi
callq 0x3320
nop