// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
movq %rdi, %r14
movl 0x30(%rdi), %r15d
leaq 0x436e(%rip), %rsi      # 0x17192
leaq -0x370(%rbp), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0x3340
leaq -0x38(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x58(%rbp), %r13
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
testl %r15d, %r15d
jle 0x12ea1
leal -0x2(,%r15,4), %eax
cmpl $0x2, %eax
movl $0x1, %r12d
cmovgel %eax, %r12d
leaq -0x48(%rbp), %r15
movq -0x370(%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3350
decl %r12d
jne 0x12e76
movq -0x370(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %edx
leaq -0x370(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3350
movq 0x90f5(%rip), %rdi      # 0x1bfc8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %esi
movq 0x90da(%rip), %rbx      # 0x1bfc8
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3140
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3140
cmpl $0x6, 0x30(%r14)
jne 0x13066
movq 0x908e(%rip), %rdi      # 0x1bfc8
leaq 0x3152(%rip), %rsi      # 0x16093
movl $0x5, %edx
callq 0x3210
movq 0x9076(%rip), %rdi      # 0x1bfc8
leaq 0x4245(%rip), %rsi      # 0x1719e
movl $0x15, %edx
callq 0x3210
leaq -0x158(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq %rsi, %rdx
leaq -0x168(%rbp), %rdi
callq 0xd9b2
leaq -0x138(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x30fc(%rip), %rsi      # 0x16093
leaq 0x30fa(%rip), %rdx      # 0x16098
leaq -0x148(%rbp), %rdi
callq 0xe724
leaq -0x168(%rbp), %rdi
leaq -0x148(%rbp), %rsi
movsd 0x3048(%rip), %xmm0     # 0x16008
callq 0x10be3
movq -0x148(%rbp), %rdi
cmpq %r15, %rdi
je 0x12fd6
callq 0x31c0
movq -0x168(%rbp), %rdi
cmpq %r14, %rdi
je 0x12fe7
callq 0x31c0
leaq -0x118(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
leaq -0x128(%rbp), %rdi
callq 0xd9b2
leaq -0xf8(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x3078(%rip), %rsi      # 0x16093
leaq 0x3076(%rip), %rdx      # 0x16098
leaq -0x108(%rbp), %rdi
callq 0xe724
leaq -0x128(%rbp), %rdi
leaq -0x108(%rbp), %rsi
movsd 0x2fc4(%rip), %xmm0     # 0x16008
callq 0x10be3
movq -0x108(%rbp), %rdi
cmpq %r15, %rdi
je 0x1305a
callq 0x31c0
movq -0x128(%rbp), %rdi
jmp 0x13191
movq 0x8f5b(%rip), %rdi      # 0x1bfc8
leaq 0x394f(%rip), %rsi      # 0x169c3
movl $0x5, %edx
callq 0x3210
movq 0x8f43(%rip), %rdi      # 0x1bfc8
leaq 0x4128(%rip), %rsi      # 0x171b4
movl $0xa, %edx
callq 0x3210
leaq -0xd8(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq %rsi, %rdx
leaq -0xe8(%rbp), %rdi
callq 0xd9b2
leaq -0xb8(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x38f9(%rip), %rsi      # 0x169c3
leaq 0x38f7(%rip), %rdx      # 0x169c8
leaq -0xc8(%rbp), %rdi
callq 0xe724
leaq -0xe8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
movsd 0x2f15(%rip), %xmm0     # 0x16008
callq 0x10be3
movq -0xc8(%rbp), %rdi
cmpq %r15, %rdi
je 0x13109
callq 0x31c0
movq -0xe8(%rbp), %rdi
cmpq %r14, %rdi
je 0x1311a
callq 0x31c0
leaq -0x98(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa8(%rbp), %rdi
callq 0xd9b2
leaq -0x78(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x3878(%rip), %rsi      # 0x169c3
leaq 0x3876(%rip), %rdx      # 0x169c8
leaq -0x88(%rbp), %rdi
callq 0xe724
leaq -0xa8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movsd 0x2e94(%rip), %xmm0     # 0x16008
callq 0x10be3
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x1318a
callq 0x31c0
movq -0xa8(%rbp), %rdi
cmpq %r14, %rdi
je 0x1319b
callq 0x31c0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %esi
movq 0x8e0f(%rip), %rbx      # 0x1bfc8
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3140
movsd 0x354f(%rip), %xmm0     # 0x16720
callq 0x10b95
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %esi
movq 0x8dd4(%rip), %rdi      # 0x1bfc8
callq 0x3030
movq %rax, %rdi
callq 0x3140
leaq -0x370(%rbp), %rdi
callq 0x3040
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x1321b
callq 0x31c0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x1322d
callq 0x31c0
leaq -0x370(%rbp), %rdi
callq 0x3050
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x1327a
callq 0x31c0
jmp 0x1327a
movq %rax, %rbx
movq -0x108(%rbp), %rdi
cmpq %r15, %rdi
je 0x13286
callq 0x31c0
jmp 0x13286
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
jmp 0x132d1
movq %rax, %rbx
movq -0x128(%rbp), %rdi
jmp 0x132d1
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
cmpq %r15, %rdi
je 0x132be
callq 0x31c0
jmp 0x132be
movq %rax, %rbx
movq -0x148(%rbp), %rdi
cmpq %r15, %rdi
je 0x132ca
callq 0x31c0
jmp 0x132ca
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
jmp 0x132d1
movq %rax, %rbx
movq -0x168(%rbp), %rdi
cmpq %r14, %rdi
je 0x132e2
callq 0x31c0
jmp 0x132e2
jmp 0x132df
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x132f0
callq 0x31c0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x13302
callq 0x31c0
leaq -0x370(%rbp), %rdi
callq 0x3050
movq %rbx, %rdi
callq 0x3320