// File: /workspace/github_cpp_makefile_star2_O2/dnegovan[P]Intruder-On-Donnar-V/Game.cpp
// Function: Game::printEnding()
void Game::printEnding()
{
    //enum is in the same order as file.  formula to find 1st line of ending
    int line = markNelson.state * 4 - 2;

    std::ifstream stream("endings.txt", std::ios::in);
    std::string endingText1;
    std::string endingText2;

    //get each line until we have the right one, then stop
    for (int i = 0; i < line; i++)
    {
        getline(stream, endingText1);
    }
    //each ending is two lines, have first using loop above, so grab second one
    getline(stream, endingText2);

    std::cout << std::endl << std::endl;

    //check for best ending, different color if so
    if (markNelson.state == SAVED_WIFE)
    {
        std::cout << NARRATOR_COLOR << "PARASITE ERADICATED!\n";
        printString(endingText1, NARRATOR_COLOR, SHORT);
        printString(endingText2, NARRATOR_COLOR, SHORT);
    }
    else
    {
        std::cout << RED << "GAME OVER\n";
        printString(endingText1, RED, SHORT);
        printString(endingText2, RED, SHORT);
    }

    //long dramatic pause before play again menu
    std::cout << std::endl;
    wait(LONG);
    std::cout << std::endl;

    stream.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x350, %rsp            # imm = 0x350
movq %rdi, %rbx
movl 0x30(%rdi), %eax
leal -0x2(,%rax,4), %r15d
leaq 0x3d5d(%rip), %rsi      # 0x11172
leaq -0x370(%rbp), %r14
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x3310
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %r12d, %r12d
movb %r12b, (%rax)
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %r12b, (%rax)
testl %r15d, %r15d
cmovgl %r15d, %r12d
leaq -0x68(%rbp), %r15
subl $0x1, %r12d
jb 0xd468
movq %r14, %rdi
movq %r15, %rsi
callq 0x3030
jmp 0xd455
leaq -0x370(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3030
movq 0x8b49(%rip), %rdi      # 0x15fc8
callq 0x30f0
movq %rax, %rdi
callq 0x30f0
cmpl $0x6, 0x30(%rbx)
jne 0xd563
movq 0x8b2b(%rip), %rdi      # 0x15fc8
leaq 0x2bf4(%rip), %rsi      # 0x10098
callq 0x31d0
leaq 0x3cce(%rip), %rsi      # 0x1117e
movq %rax, %rdi
callq 0x31d0
leaq -0x128(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3250
leaq 0x2bc9(%rip), %rsi      # 0x10098
leaq -0x108(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x30b0
leaq -0x128(%rbp), %rdi
leaq -0x108(%rbp), %rsi
movsd 0x2b13(%rip), %xmm0     # 0x10008
callq 0xbb41
leaq -0x108(%rbp), %rdi
callq 0x3368
leaq -0x128(%rbp), %rdi
callq 0x3368
leaq -0x168(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3250
leaq 0x2b6f(%rip), %rsi      # 0x10098
leaq -0xe8(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x30b0
leaq -0x168(%rbp), %rbx
leaq -0xe8(%rbp), %rsi
movsd 0x2ab9(%rip), %xmm0     # 0x10008
movq %rbx, %rdi
callq 0xbb41
leaq -0xe8(%rbp), %rdi
jmp 0xd62b
movq 0x8a5e(%rip), %rdi      # 0x15fc8
leaq 0x3432(%rip), %rsi      # 0x109a3
callq 0x31d0
leaq 0x3c17(%rip), %rsi      # 0x11194
movq %rax, %rdi
callq 0x31d0
leaq -0xc8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3250
leaq 0x3407(%rip), %rsi      # 0x109a3
leaq -0xa8(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x30b0
leaq -0xc8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movsd 0x2a46(%rip), %xmm0     # 0x10008
callq 0xbb41
leaq -0xa8(%rbp), %rdi
callq 0x3368
leaq -0xc8(%rbp), %rdi
callq 0x3368
leaq -0x148(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3250
leaq 0x33ad(%rip), %rsi      # 0x109a3
leaq -0x88(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x30b0
leaq -0x148(%rbp), %rbx
leaq -0x88(%rbp), %rsi
movsd 0x29ec(%rip), %xmm0     # 0x10008
movq %rbx, %rdi
callq 0xbb41
leaq -0x88(%rbp), %rdi
callq 0x3368
movq %rbx, %rdi
callq 0x3368
movq 0x8989(%rip), %rdi      # 0x15fc8
callq 0x30f0
movsd 0x30b4(%rip), %xmm0     # 0x10700
callq 0xbaf9
movq 0x8970(%rip), %rdi      # 0x15fc8
callq 0x30f0
leaq -0x370(%rbp), %rdi
callq 0x3040
leaq -0x48(%rbp), %rdi
callq 0x3368
leaq -0x68(%rbp), %rdi
callq 0x3368
leaq -0x370(%rbp), %rdi
callq 0x3070
addq $0x350, %rsp            # imm = 0x350
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x3368
jmp 0xd6bc
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
callq 0x3368
jmp 0xd6c8
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
jmp 0xd709
movq %rax, %rbx
leaq -0x168(%rbp), %rdi
jmp 0xd709
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x3368
jmp 0xd6f6
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
callq 0x3368
jmp 0xd702
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
jmp 0xd709
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
callq 0x3368
jmp 0xd715
jmp 0xd712
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x3368
leaq -0x68(%rbp), %rdi
callq 0x3368
leaq -0x370(%rbp), %rdi
callq 0x3070
movq %rbx, %rdi
callq 0x3300
nop