// File: /workspace/github_cpp_makefile_star2_O1/sagardoshi[P]NegotiationsEncounter/src/Encounter.cpp
// Function: Encounter::runEncounter(bool&)
bool Encounter::runEncounter(bool &didWin) {
    string title = "YOU ARE NEGOTIATING WITH " + getCapsName();
    string promptWithUI = "Negotiate! (type \"help\" for the menu)";
    string promptWithoutUI = "Hit <RETURN> to see the negotiating table";
    string promptToPrint = "";

    string entry = "";
    string echo = "";
    bool firstLoop = true;
    bool uiOnScreen = true;

    while (true) {

        ////////////////////////////////////////////////////////////////////////
        // FIRST HANDLE UI AND PRINTOUTS
        ////////////////////////////////////////////////////////////////////////

        if (firstLoop) {
            firstLoop = false;
            clearScreen();                // To remove incorrect title
            printTitle(title);            // first need an immediate print

            // Special settings just for prologue's first loop
            if (isPrologue) {
                printStrategy();          // Just on firstLoop
                promptToPrint = promptWithoutUI;
            } else {
                printUI();                // After prologue, print UI, normally
                promptToPrint = promptWithUI;
            }
        }
        else {                            // For every time apart from the first
            promptToPrint = promptWithUI; // Assume UI visible
            if (uiOnScreen) printUI();
            else {                        // If on a menu screen
                uiOnScreen = true;
                promptToPrint = promptWithoutUI;
            }
        }

        // Print prompt, take user input, and convert number to item string
        userEntry(entry, echo, promptToPrint);


        // For the next screen, clear current view and start with title of next
        clearScreen();                    // Critical in this position
        if (!firstLoop) printTitle(title);



        ////////////////////////////////////////////////////////////////////////
        // NEXT HANDLE POSSIBLE USER ENTRIES
        ////////////////////////////////////////////////////////////////////////

        ///// IMMEDIATE QUIT
        if      (entry == "quit") {
            player->takeBackOffer(table); // In case quit typed halfway through
            return false;
        }

        ///// FOR NEXT THREE, HIDE UI AND PRINT ACCORDINGLY
        else if (entry == "strategy") {
            uiOnScreen = false;
            printStrategy();
        }
        else if (entry == "help") {
            uiOnScreen = false;
            printHelp();
        }
        else if (entry == "turns") {
            uiOnScreen = false;
            printTurns();
        }

        ///// EMPTY STRING RETURNS TO DEFAULT UI VIEW
        else if (entry == "" || entry == "back") continue; // loop empty input

        ///// NEXT TWO HANDLE IMMEDIATE ENCOUNTER ENDS
        else if (entry == "super") { // Superuser access, not shown in menu
            didWin = true;
            handleEnd(didWin);
            return true;
        }
        else if (entry == "forfeit") {
            didWin = false; // don't check for encounter end; just assume loss
            handleEnd(didWin);
            return true;
        }
        else if (entry == "propose" || entry == "proposal") {
            // Save current value, in case it's encounter-ending
            offerInvValue = table->getInvValue();

            // Check if nego done, and break if so
            if (encounterIsOver(didWin)) {
                handleEnd(didWin);
                return true;
            }
        }

        ///// NEXT THREE HANDLE PLACING AND TAKING ITEMS FROM THE TABLE
        else if (entry == "cancel") {
            if (table->isEmpty()) {
                echo = "There's nothing on the table for you to take back.\n\n";
            } else echo = "You take your offer back from the table.\n\n";
            player->takeBackOffer(table);
        }
        else if (player->knowsOfItem(entry)) {
            // Finally! Item exists, and player has it
            if (player->hasItem(entry)) {
                echo = "You place your " + entry + " on the table.\n\n";
                player->placeItemOnTable(entry, table);
            // Item exists, but player doesn't currently have it in inventory
            } else echo = "You have no " + entry + " to give.\n\n";
        }
        // Erroneous entry... there is no such thing in the economy
        else echo = "You have no such thing. Try again.\n\n";
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rsi, 0x8(%rsp)
movq %rdi, %rbx
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x76c4
leaq 0x6a1f(%rip), %rcx      # 0xfb11
movl $0x19, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2250
leaq 0x60(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x912b
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x9132
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x40(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x9165
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0x30(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x69b7(%rip), %rsi      # 0xfb2b
leaq 0x69d5(%rip), %rdx      # 0xfb50
callq 0x290e
leaq 0x108(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x69bd(%rip), %rsi      # 0xfb51
leaq 0x69df(%rip), %rdx      # 0xfb7a
leaq 0xf8(%rsp), %rdi
callq 0x290e
leaq 0xc0(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x61fd(%rip), %rdx      # 0xf3b8
leaq 0xb0(%rsp), %rdi
movq %rdx, %rsi
callq 0x290e
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x61da(%rip), %rdx      # 0xf3b8
leaq 0x90(%rsp), %rdi
movq %rdx, %rsi
callq 0x290e
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x61b7(%rip), %rdx      # 0xf3b8
leaq 0x70(%rsp), %rdi
movq %rdx, %rsi
callq 0x290e
leaq 0x38(%rbx), %rax
movq %rax, 0xf0(%rsp)
movb $0x1, %r13b
leaq 0x1b8(%rsp), %r12
leaq 0x90(%rsp), %r15
movb $0x1, %r14b
testb $0x1, %r13b
je 0x92ab
callq 0x7bd8
leaq 0x1a8(%rsp), %rax
movq %rax, 0x198(%rsp)
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
addq %rsi, %rdx
leaq 0x198(%rsp), %rdi
callq 0x687c
leaq 0x198(%rsp), %rsi
callq 0x7c7a
movq 0x198(%rsp), %rdi
leaq 0x1a8(%rsp), %rax
cmpq %rax, %rdi
je 0x9297
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x2210
cmpb $0x1, (%rbx)
jne 0x92fb
callq 0x85c2
leaq 0xf8(%rsp), %rsi
jmp 0x931c
leaq 0xb0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2140
testb $0x1, %r14b
je 0x92e1
movq 0x20(%rbx), %rdi
xorl %esi, %esi
callq 0xa6c2
movq 0x10(%rbx), %rdi
movq 0xf0(%rsp), %rsi
callq 0xa6c2
jmp 0x932c
movb $0x1, %r14b
leaq 0xb0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x2140
jmp 0x932c
movq 0x20(%rbx), %rdi
xorl %esi, %esi
callq 0xa6c2
movq 0x10(%rbx), %rdi
movq 0xf0(%rsp), %rsi
callq 0xa6c2
leaq 0x30(%rsp), %rsi
leaq 0xb0(%rsp), %rdi
callq 0x2140
xorl %r13d, %r13d
leaq 0x1c8(%rsp), %rax
movq %rax, 0x1b8(%rsp)
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x687c
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x70(%rsp), %rdx
movq %r12, %rcx
callq 0x8190
movq 0x1b8(%rsp), %rdi
leaq 0x1c8(%rsp), %rax
cmpq %rax, %rdi
je 0x938f
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x2210
callq 0x7bd8
testb $0x1, %r13b
jne 0x93f6
leaq 0x188(%rsp), %rax
movq %rax, 0x178(%rsp)
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
addq %rsi, %rdx
leaq 0x178(%rsp), %rdi
callq 0x687c
leaq 0x178(%rsp), %rsi
callq 0x7c7a
movq 0x178(%rsp), %rdi
leaq 0x188(%rsp), %rax
cmpq %rax, %rdi
je 0x93f6
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x2210
movq %r15, %rdi
leaq 0x5f90(%rip), %rsi      # 0xf390
callq 0x20c0
movl %eax, %ebp
testl %eax, %eax
je 0x9899
movq %r15, %rdi
leaq 0x6762(%rip), %rsi      # 0xfb7b
callq 0x20c0
testl %eax, %eax
je 0x9635
movq %r15, %rdi
leaq 0x6754(%rip), %rsi      # 0xfb84
callq 0x20c0
testl %eax, %eax
je 0x9642
movq %r15, %rdi
leaq 0x6742(%rip), %rsi      # 0xfb89
callq 0x20c0
testl %eax, %eax
je 0x964f
movq %r15, %rdi
leaq 0x5f5a(%rip), %rsi      # 0xf3b8
callq 0x20c0
testl %eax, %eax
je 0x9230
movq %r15, %rdi
leaq 0x671a(%rip), %rsi      # 0xfb8f
callq 0x20c0
testl %eax, %eax
je 0x9230
movq %r15, %rdi
leaq 0x6708(%rip), %rsi      # 0xfb94
callq 0x20c0
testl %eax, %eax
je 0x9986
movq %r15, %rdi
leaq 0x66f7(%rip), %rsi      # 0xfb9a
callq 0x20c0
testl %eax, %eax
je 0x9992
movq %r15, %rdi
leaq 0x66e8(%rip), %rsi      # 0xfba2
callq 0x20c0
testl %eax, %eax
je 0x965f
movq %r15, %rdi
leaq 0x66d9(%rip), %rsi      # 0xfbaa
callq 0x20c0
testl %eax, %eax
je 0x965f
movq %r15, %rdi
leaq 0x66cb(%rip), %rsi      # 0xfbb3
callq 0x20c0
testl %eax, %eax
je 0x9687
movq 0x10(%rbx), %rbp
leaq 0x168(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
addq %rsi, %rdx
leaq 0x158(%rsp), %rdi
callq 0x687c
movq %rbp, %rdi
leaq 0x158(%rsp), %rsi
callq 0xa138
movl %eax, %ebp
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x9560
movq 0x168(%rsp), %rsi
incq %rsi
callq 0x2210
testb %bpl, %bpl
je 0x96d6
movq 0x10(%rbx), %rbp
leaq 0x148(%rsp), %rax
movq %rax, 0x138(%rsp)
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
addq %rsi, %rdx
leaq 0x138(%rsp), %rdi
callq 0x687c
movq %rbp, %rdi
leaq 0x138(%rsp), %rsi
callq 0xa5a8
movl %eax, %ebp
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x95d4
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x2210
testb %bpl, %bpl
je 0x96f9
leaq 0xd0(%rsp), %rbp
movq %rbp, %rdi
leaq 0x662b(%rip), %rsi      # 0xfc1a
movq %r15, %rdx
callq 0x6696
movq %rbp, %rdi
leaq 0x6629(%rip), %rsi      # 0xfc2a
callq 0x23d0
leaq 0x20(%rsp), %rbp
movq %rbp, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x9751
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x9758
xorl %r14d, %r14d
callq 0x85c2
jmp 0x9230
xorl %r14d, %r14d
callq 0x8796
jmp 0x9230
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x82cc
jmp 0x9230
movq 0x20(%rbx), %rdi
callq 0xa5ba
movss %xmm0, 0x2c(%rbx)
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x88fe
testb %al, %al
je 0x9230
jmp 0x999e
movq 0x20(%rbx), %rdi
callq 0xa546
testb %al, %al
leaq 0x6556(%rip), %rcx      # 0xfbef
leaq 0x651a(%rip), %rax      # 0xfbba
cmovneq %rax, %rcx
movl $0x2a, %r8d
movl $0x34, %eax
cmovneq %rax, %r8
movq 0x78(%rsp), %rdx
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
callq 0x2320
movq 0x10(%rbx), %rdi
movq 0x20(%rbx), %rsi
callq 0xe9bc
jmp 0x9230
movq 0x78(%rsp), %rdx
movl $0x24, %r8d
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
leaq 0x6565(%rip), %rcx      # 0xfc54
callq 0x2320
jmp 0x9230
leaq 0xd0(%rsp), %rbp
movq %rbp, %rdi
leaq 0x6530(%rip), %rsi      # 0xfc3b
movq %r15, %rdx
callq 0x6696
movq %rbp, %rdi
leaq 0x652b(%rip), %rsi      # 0xfc48
callq 0x23d0
leaq 0x20(%rsp), %rbp
movq %rbp, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x9826
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x982d
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2280
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x9796
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x97bb
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x10(%rbx), %rbp
leaq 0x128(%rsp), %rax
movq %rax, 0x118(%rsp)
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
addq %rsi, %rdx
leaq 0x118(%rsp), %rdi
callq 0x687c
movq 0x20(%rbx), %rdx
movq %rbp, %rdi
leaq 0x118(%rsp), %rsi
callq 0xe98e
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x9230
movq 0x128(%rsp), %rsi
jmp 0x988c
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2280
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x986b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x9230
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x9230
movq 0x10(%rbx), %rdi
movq 0x20(%rbx), %rsi
leaq 0x60(%rsp), %rbx
leaq 0x40(%rsp), %r14
leaq 0x108(%rsp), %r15
leaq 0xc0(%rsp), %r12
callq 0xe9bc
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x98e2
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x9907
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xb0(%rsp), %rdi
cmpq %r12, %rdi
je 0x9924
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xf8(%rsp), %rdi
cmpq %r15, %rdi
je 0x9941
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x9958
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x50(%rsp), %rdi
cmpq %rbx, %rdi
je 0x996f
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2210
testl %ebp, %ebp
setne %al
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rax
movb $0x1, (%rax)
movb $0x1, %al
jmp 0x99a5
movq 0x8(%rsp), %rax
movb $0x0, (%rax)
xorl %eax, %eax
jmp 0x99a5
movq 0x8(%rsp), %rax
movb (%rax), %al
movzbl %al, %esi
movq %rbx, %rdi
leaq 0x60(%rsp), %rbx
leaq 0x40(%rsp), %r14
leaq 0x108(%rsp), %r15
leaq 0xc0(%rsp), %r12
callq 0x8ecc
jmp 0x98c0
movq %rax, %rbx
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x9b56
movq 0x128(%rsp), %rsi
jmp 0x9b49
jmp 0x99ff
jmp 0x9b53
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x9b56
movq 0xe0(%rsp), %rsi
jmp 0x9b49
jmp 0x9b53
movq %rax, %rbx
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x9b56
movq 0x148(%rsp), %rsi
jmp 0x9b49
movq %rax, %rbx
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x9b56
movq 0x168(%rsp), %rsi
jmp 0x9b49
jmp 0x9b53
movq %rax, %rbx
leaq 0x60(%rsp), %r14
leaq 0x40(%rsp), %r15
leaq 0x108(%rsp), %r12
leaq 0xc0(%rsp), %r13
jmp 0x9b92
movq %rax, %rbx
jmp 0x9bb7
movq %rax, %rbx
jmp 0x9bd4
movq %rax, %rbx
jmp 0x9bf1
movq %rax, %rbx
jmp 0x9c08
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9c1f
movq 0x40(%rsp), %rsi
jmp 0x9c17
movq %rax, %rbx
movq 0x198(%rsp), %rdi
leaq 0x1a8(%rsp), %rax
cmpq %rax, %rdi
je 0x9b56
movq 0x1a8(%rsp), %rsi
jmp 0x9b49
movq %rax, %rbx
movq 0x178(%rsp), %rdi
leaq 0x188(%rsp), %rax
cmpq %rax, %rdi
je 0x9b56
movq 0x188(%rsp), %rsi
jmp 0x9b49
movq %rax, %rbx
movq 0x1b8(%rsp), %rdi
leaq 0x1c8(%rsp), %rax
cmpq %rax, %rdi
je 0x9b56
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x9b56
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
leaq 0x60(%rsp), %r14
leaq 0x40(%rsp), %r15
leaq 0x108(%rsp), %r12
leaq 0xc0(%rsp), %r13
je 0x9b92
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x9bb7
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xb0(%rsp), %rdi
cmpq %r13, %rdi
je 0x9bd4
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xf8(%rsp), %rdi
cmpq %r12, %rdi
je 0x9bf1
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x9c08
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x9c1f
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x2390
nop