// File: /workspace/github_cpp_makefile_star2_O3/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 0x781c
leaq 0x6935(%rip), %rcx      # 0xfb51
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 0x9255
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x925c
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 0x928f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0x30(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x68cd(%rip), %rsi      # 0xfb6b
leaq 0x68eb(%rip), %rdx      # 0xfb90
callq 0x290e
leaq 0x108(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x68d3(%rip), %rsi      # 0xfb91
leaq 0x68f5(%rip), %rdx      # 0xfbba
leaq 0xf8(%rsp), %rdi
callq 0x290e
leaq 0xc0(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x6117(%rip), %rdx      # 0xf3fc
leaq 0xb0(%rsp), %rdi
movq %rdx, %rsi
callq 0x290e
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x60f4(%rip), %rdx      # 0xf3fc
leaq 0x90(%rsp), %rdi
movq %rdx, %rsi
callq 0x290e
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x60d1(%rip), %rdx      # 0xf3fc
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 0x93d5
callq 0x7d1e
leaq 0x1a8(%rsp), %rax
movq %rax, 0x198(%rsp)
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
addq %rsi, %rdx
leaq 0x198(%rsp), %rdi
callq 0x6a38
leaq 0x198(%rsp), %rsi
callq 0x7dc0
movq 0x198(%rsp), %rdi
leaq 0x1a8(%rsp), %rax
cmpq %rax, %rdi
je 0x93c1
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x2210
cmpb $0x1, (%rbx)
jne 0x9428
callq 0x86ec
leaq 0xf8(%rsp), %rsi
jmp 0x9449
leaq 0xb0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2140
testb $0x1, %r14b
je 0x940e
movq 0x20(%rbx), %rdi
xorl %esi, %esi
callq 0xa7ee
movq 0x10(%rbx), %rdi
movb $0x1, %r14b
movq 0xf0(%rsp), %rsi
callq 0xa7ee
jmp 0x9459
movb $0x1, %r14b
leaq 0xb0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x2140
jmp 0x9459
movq 0x20(%rbx), %rdi
xorl %esi, %esi
callq 0xa7ee
movq 0x10(%rbx), %rdi
movq 0xf0(%rsp), %rsi
callq 0xa7ee
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 0x6a38
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x70(%rsp), %rdx
movq %r12, %rcx
callq 0x82c0
movq 0x1b8(%rsp), %rdi
leaq 0x1c8(%rsp), %rax
cmpq %rax, %rdi
je 0x94bc
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x2210
callq 0x7d1e
testb $0x1, %r13b
jne 0x9523
leaq 0x188(%rsp), %rax
movq %rax, 0x178(%rsp)
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
addq %rsi, %rdx
leaq 0x178(%rsp), %rdi
callq 0x6a38
leaq 0x178(%rsp), %rsi
callq 0x7dc0
movq 0x178(%rsp), %rdi
leaq 0x188(%rsp), %rax
cmpq %rax, %rdi
je 0x9523
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x2210
movq %r15, %rdi
leaq 0x5ea7(%rip), %rsi      # 0xf3d4
callq 0x20c0
movl %eax, %ebp
testl %eax, %eax
je 0x99c6
movq %r15, %rdi
leaq 0x6675(%rip), %rsi      # 0xfbbb
callq 0x20c0
testl %eax, %eax
je 0x9762
movq %r15, %rdi
leaq 0x6667(%rip), %rsi      # 0xfbc4
callq 0x20c0
testl %eax, %eax
je 0x976f
movq %r15, %rdi
leaq 0x6655(%rip), %rsi      # 0xfbc9
callq 0x20c0
testl %eax, %eax
je 0x977c
movq %r15, %rdi
leaq 0x5e71(%rip), %rsi      # 0xf3fc
callq 0x20c0
testl %eax, %eax
je 0x935a
movq %r15, %rdi
leaq 0x662d(%rip), %rsi      # 0xfbcf
callq 0x20c0
testl %eax, %eax
je 0x935a
movq %r15, %rdi
leaq 0x661b(%rip), %rsi      # 0xfbd4
callq 0x20c0
testl %eax, %eax
je 0x9ab3
movq %r15, %rdi
leaq 0x660a(%rip), %rsi      # 0xfbda
callq 0x20c0
testl %eax, %eax
je 0x9abf
movq %r15, %rdi
leaq 0x65fb(%rip), %rsi      # 0xfbe2
callq 0x20c0
testl %eax, %eax
je 0x978c
movq %r15, %rdi
leaq 0x65ec(%rip), %rsi      # 0xfbea
callq 0x20c0
testl %eax, %eax
je 0x978c
movq %r15, %rdi
leaq 0x65de(%rip), %rsi      # 0xfbf3
callq 0x20c0
testl %eax, %eax
je 0x97b4
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 0x6a38
movq %rbp, %rdi
leaq 0x158(%rsp), %rsi
callq 0xa264
movl %eax, %ebp
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x968d
movq 0x168(%rsp), %rsi
incq %rsi
callq 0x2210
testb %bpl, %bpl
je 0x9803
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 0x6a38
movq %rbp, %rdi
leaq 0x138(%rsp), %rsi
callq 0xa6d4
movl %eax, %ebp
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x9701
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x2210
testb %bpl, %bpl
je 0x9826
leaq 0xd0(%rsp), %rbp
movq %rbp, %rdi
leaq 0x653e(%rip), %rsi      # 0xfc5a
movq %r15, %rdx
callq 0x6852
movq %rbp, %rdi
leaq 0x653c(%rip), %rsi      # 0xfc6a
callq 0x23d0
leaq 0x20(%rsp), %rbp
movq %rbp, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x987e
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x9885
xorl %r14d, %r14d
callq 0x86ec
jmp 0x935a
xorl %r14d, %r14d
callq 0x88c0
jmp 0x935a
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x83fc
jmp 0x935a
movq 0x20(%rbx), %rdi
callq 0xa6e6
movss %xmm0, 0x2c(%rbx)
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x8a28
testb %al, %al
je 0x935a
jmp 0x9acb
movq 0x20(%rbx), %rdi
callq 0xa672
testb %al, %al
leaq 0x6469(%rip), %rcx      # 0xfc2f
leaq 0x642d(%rip), %rax      # 0xfbfa
cmovneq %rax, %rcx
movq 0x78(%rsp), %rdx
movl $0x2a, %r8d
movl $0x34, %eax
cmovneq %rax, %r8
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
callq 0x2320
movq 0x10(%rbx), %rdi
movq 0x20(%rbx), %rsi
callq 0xeaf8
jmp 0x935a
movq 0x78(%rsp), %rdx
movl $0x24, %r8d
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
leaq 0x6478(%rip), %rcx      # 0xfc94
callq 0x2320
jmp 0x935a
leaq 0xd0(%rsp), %rbp
movq %rbp, %rdi
leaq 0x6443(%rip), %rsi      # 0xfc7b
movq %r15, %rdx
callq 0x6852
movq %rbp, %rdi
leaq 0x643e(%rip), %rsi      # 0xfc88
callq 0x23d0
leaq 0x20(%rsp), %rbp
movq %rbp, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x9953
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x995a
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 0x98c3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x98e8
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 0x6a38
movq 0x20(%rbx), %rdx
movq %rbp, %rdi
leaq 0x118(%rsp), %rsi
callq 0xeaca
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x935a
movq 0x128(%rsp), %rsi
jmp 0x99b9
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 0x9998
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x935a
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x935a
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 0xeaf8
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x9a0f
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x9a34
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xb0(%rsp), %rdi
cmpq %r12, %rdi
je 0x9a51
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xf8(%rsp), %rdi
cmpq %r15, %rdi
je 0x9a6e
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x9a85
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x50(%rsp), %rdi
cmpq %rbx, %rdi
je 0x9a9c
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 0x9ad2
movq 0x8(%rsp), %rax
movb $0x0, (%rax)
xorl %eax, %eax
jmp 0x9ad2
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 0x8ff6
jmp 0x99ed
movq %rax, %rbx
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x9c83
movq 0x128(%rsp), %rsi
jmp 0x9c76
jmp 0x9b2c
jmp 0x9c80
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x9c83
movq 0xe0(%rsp), %rsi
jmp 0x9c76
jmp 0x9c80
movq %rax, %rbx
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x9c83
movq 0x148(%rsp), %rsi
jmp 0x9c76
movq %rax, %rbx
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x9c83
movq 0x168(%rsp), %rsi
jmp 0x9c76
jmp 0x9c80
movq %rax, %rbx
leaq 0x60(%rsp), %r14
leaq 0x40(%rsp), %r15
leaq 0x108(%rsp), %r12
leaq 0xc0(%rsp), %r13
jmp 0x9cbf
movq %rax, %rbx
jmp 0x9ce4
movq %rax, %rbx
jmp 0x9d01
movq %rax, %rbx
jmp 0x9d1e
movq %rax, %rbx
jmp 0x9d35
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9d4c
movq 0x40(%rsp), %rsi
jmp 0x9d44
movq %rax, %rbx
movq 0x198(%rsp), %rdi
leaq 0x1a8(%rsp), %rax
cmpq %rax, %rdi
je 0x9c83
movq 0x1a8(%rsp), %rsi
jmp 0x9c76
movq %rax, %rbx
movq 0x178(%rsp), %rdi
leaq 0x188(%rsp), %rax
cmpq %rax, %rdi
je 0x9c83
movq 0x188(%rsp), %rsi
jmp 0x9c76
movq %rax, %rbx
movq 0x1b8(%rsp), %rdi
leaq 0x1c8(%rsp), %rax
cmpq %rax, %rdi
je 0x9c83
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x2210
jmp 0x9c83
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 0x9cbf
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x9ce4
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xb0(%rsp), %rdi
cmpq %r13, %rdi
je 0x9d01
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0xf8(%rsp), %rdi
cmpq %r12, %rdi
je 0x9d1e
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x9d35
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2210
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x9d4c
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x2390