// File: /workspace/github_cpp_makefile_star2_O2/dnegovan[P]Intruder-On-Donnar-V/CrewMember.cpp
// Function: CrewMember::talk()
void CrewMember::talk()
{
    //create otherCrew vector by removing this name from copy of full crew list
    otherCrew = crewList;
    auto iterator = std::find(otherCrew.begin(), otherCrew.end(), name);
    otherCrew.erase(iterator);

    int input = 0;

    std::cout << NARRATOR_COLOR "\n" << fullTitle << RESET << std::endl;

    //if the occupant is infected, use special dialogue (different txt file)
    std::string fileName;
    if (infected)
    {
        //use infected dialogue options
        fileName = name + "Infected.txt";
    }
    else
    {
        //use regular dialogue options
        fileName = name + ".txt";
    }

    //open dialogue file
    std::ifstream stream(fileName, std::ios::in);

    //diaplay greeting (1st line of file)
    std::string dialogue;
    getline(stream, dialogue);
    std::cout << DIALOGUE_COLOR << dialogue << RESET << "\n" << std::endl;
    stream.close();

    while (true)
    {
        //need to skip the first line, already showed it above
        stream.open(fileName);
        getline(stream, dialogue);

        //menu for asking about other crewmembers
        while (input < 1 || input > ALL_CREW)
        {
            for (int i = 0; i < (ALL_CREW - 1); i++)
            {
                std::cout << i + 1 << ". Ask about " << otherCrew[i] << "\n";
            }

            std::cout << ALL_CREW << ". Return" << std::endl;

            input = getInteger();
        }

        if (input == ALL_CREW)
        {
            //on the menu, 1 more than all other crew will be the cancel option
            return;
        }

        //get and then overwrite any lines between greeting and user's choice
        //repeats until desired option
        for (int i = 0; i < input; i++)
        {
            getline(stream, dialogue);
        }

        std::cout << std::endl;
        printString(dialogue, DIALOGUE_COLOR, 0);
        wait(MED);

        //reset for next loop
        input = 0;
        stream.close();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rdi, %r15
leaq 0x50(%rdi), %rbx
leaq 0xc2c6(%rip), %rsi      # 0x168e0
movq %rbx, %rdi
callq 0xa936
movq 0x50(%r15), %rdi
movq 0x58(%r15), %rsi
leaq 0x8(%r15), %r14
movq %r14, %rdx
callq 0x9cd8
movq %rbx, %rdi
movq %rax, %rsi
callq 0x97c0
movq 0xb980(%rip), %rdi      # 0x15fc8
leaq 0x5da9(%rip), %rsi      # 0x103f8
callq 0x31d0
leaq 0x28(%r15), %rsi
movq %rax, %rdi
callq 0x31b0
leaq 0x5a4c(%rip), %rsi      # 0x100b3
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
cmpb $0x1, 0x49(%r15)
jne 0xa6a6
leaq 0x5d6a(%rip), %rdx      # 0x103ff
leaq -0x2b8(%rbp), %rdi
movq %r14, %rsi
callq 0xaa00
jmp 0xa6bc
leaq 0x62bd(%rip), %rdx      # 0x1096a
leaq -0x2b8(%rbp), %rdi
movq %r14, %rsi
callq 0xaa00
leaq -0x70(%rbp), %rdi
leaq -0x2b8(%rbp), %r14
movq %r14, %rsi
callq 0x3200
movq %r14, %rdi
callq 0x3368
leaq -0x2b8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
pushq $0x8
popq %rdx
callq 0x32c0
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x2b8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3030
movq 0xb8b7(%rip), %rdi      # 0x15fc8
leaq 0x5cf4(%rip), %rsi      # 0x1040c
callq 0x31d0
leaq -0x50(%rbp), %rsi
movq %rax, %rdi
callq 0x31b0
leaq 0x5983(%rip), %rsi      # 0x100b3
movq %rax, %rdi
callq 0x31d0
leaq 0x61e5(%rip), %rsi      # 0x10924
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
leaq -0x2b8(%rbp), %rdi
callq 0x3040
movq 0xb866(%rip), %r15      # 0x15fc8
leaq 0x61bb(%rip), %r13      # 0x10924
leaq -0x2b8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
pushq $0x8
popq %rdx
callq 0x3190
leaq -0x2b8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3030
xorl %r14d, %r14d
leal -0x6(%r14), %eax
cmpl $-0x6, %eax
ja 0xa813
pushq $0x1
popq %r14
xorl %r12d, %r12d
cmpq $0x80, %r12
je 0xa7e4
movq %r15, %rdi
movl %r14d, %esi
callq 0x32f0
movq %rax, %rdi
leaq 0x5c55(%rip), %rsi      # 0x10412
callq 0x31d0
movq (%rbx), %rsi
addq %r12, %rsi
movq %rax, %rdi
callq 0x31b0
addq $0x20, %r12
incl %r14d
movq %rax, %rdi
movq %r13, %rsi
callq 0x31d0
jmp 0xa79f
movq %r15, %rdi
pushq $0x5
popq %rsi
callq 0x32f0
movq %rax, %rdi
leaq 0x5ae5(%rip), %rsi      # 0x102de
callq 0x31d0
movq %rax, %rdi
callq 0x30f0
callq 0xaed4
movl %eax, %r14d
jmp 0xa78f
cmpl $0x5, %r14d
je 0xa8aa
subl $0x1, %r14d
jb 0xa835
leaq -0x2b8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3030
jmp 0xa81d
movq %r15, %rdi
callq 0x30f0
leaq -0x90(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3250
leaq -0xb0(%rbp), %r12
movq %r12, %rdi
leaq 0x5bae(%rip), %rsi      # 0x1040c
leaq -0x29(%rbp), %rdx
callq 0x30b0
xorps %xmm0, %xmm0
leaq -0x90(%rbp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0xbb41
movq %r12, %rdi
callq 0x3368
movq %r14, %rdi
callq 0x3368
movsd 0x5b5c(%rip), %xmm0     # 0x103f0
callq 0xbaf9
leaq -0x2b8(%rbp), %rdi
callq 0x3040
jmp 0xa769
leaq -0x50(%rbp), %rdi
callq 0x3368
leaq -0x2b8(%rbp), %rdi
callq 0x3070
leaq -0x70(%rbp), %rdi
callq 0x3368
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa8de
jmp 0xa8de
movq %rax, %rbx
jmp 0xa925
jmp 0xa90d
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x3368
jmp 0xa8f9
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x3368
jmp 0xa910
jmp 0xa90d
jmp 0xa90d
jmp 0xa90d
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3368
leaq -0x2b8(%rbp), %rdi
callq 0x3070
leaq -0x70(%rbp), %rdi
callq 0x3368
movq %rbx, %rdi
callq 0x3300