// File: /workspace/github_cpp_makefile_star2_O2/sagardoshi[P]NegotiationsEncounter/src/Inventory.cpp
// Function: Inventory::printInv(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, int>>>*)
void Inventory::printInv(map<string, int>* mapPtr) {

    // Local vars for iterator
    map<string, int>::iterator it;

    const int MAX_ITEM_LEN = 23;
    string itemName = "";
    string itemText = "";

    int numItemsHeld = 0;
    int amount = 0;
    string amountText = "";

    int itemOrder = 0;
    bool printingTable = (mapPtr == NULL); // == if invMap passed
    string itemOrderText = "";

    int itemValue = 0;
    string itemValueText = "";

    // Print appropriate header

    string header  = "----- ";
           header += (!printingTable ? "YOUR LOOT" : "THE TABLE");
           header += " -----\n";
    string footer = header;

    // Depending on whether within proposal, print list of items one by one
    // Skip items with <= 0 inventory
    for (it = inventory.begin(); it != inventory.end(); it++) {
        itemName = it->first;
        amount = it->second;
        amountText = to_string(amount);
        itemOrder = ((mapPtr == NULL) ? 0 : (*mapPtr)[itemName]);
        itemOrderText = to_string(itemOrder);
        itemValue = economy[itemName];
        itemValueText = to_string(itemValue);


        if (amount > 0) {
            numItemsHeld += amount;

            // First add itemOrder, if appropriate, keeping aligned
            if (!printingTable) {
                if (itemOrder < 10) itemText += " " + itemOrderText + ": ";
                else itemText += itemOrderText + ": ";
            } else itemText += "    "; // This only prints for table, not inv

            // Then add itemName with extra spaces at end for alignment
            itemText += itemName;
            int gap = MAX_ITEM_LEN - itemName.length();
            if (gap > 0) {
                for (int i = 0; i < gap; i++) itemText += " ";
            }

            itemText += " ... ";

            // Next add amount, with extra spaces for alignment
            itemText += (amount < 10 ? " " + amountText : amountText);
            itemText += (printingTable ? " given" : " owned");

            itemText += " ... ";

            // Finally add itemValue, again with spaces for alignment
            itemText += (itemValue < 10 ? " " : "");
            itemText += "£" + itemValueText + " base market value per unit\n";
        }
        // Now loop
    }

    string total = "\n";
    // Print totals or empty notice
    if (numItemsHeld) {
        total += (!printingTable ? " Loot" : "Table");
        total += " Market Value: £" + toPreciseString(getInvValue()) + "\n";
    } else total = "\n[Empty]\n\n";

    // Space between two inventories
    footer += (printingTable ? "\n" : "");

    cout << header << itemText << total << footer; // Flush everything
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rsi, %r14
movq %rdi, %r15
leaq 0x3742(%rip), %rbx      # 0xc3b8
leaq 0x98(%rsp), %rdi
leaq 0x138(%rsp), %rdx
movq %rbx, %rsi
callq 0x3860
leaq 0x138(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
movq %rbx, %rsi
callq 0x3860
leaq 0x370b(%rip), %rsi      # 0xc3b8
leaq 0xd8(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x3860
leaq 0x36ef(%rip), %rsi      # 0xc3b8
leaq 0xb8(%rsp), %rdi
leaq 0x118(%rsp), %rdx
callq 0x3860
leaq 0x36d3(%rip), %rsi      # 0xc3b8
leaq 0x118(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x3860
leaq 0x407b(%rip), %rsi      # 0xcd79
leaq 0x78(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
callq 0x3860
testq %r14, %r14
leaq 0x4070(%rip), %rax      # 0xcd8a
leaq 0x405f(%rip), %rsi      # 0xcd80
cmoveq %rax, %rsi
leaq 0x78(%rsp), %rdi
callq 0x33b0
leaq 0x405e(%rip), %rsi      # 0xcd94
leaq 0x78(%rsp), %rdi
callq 0x33b0
leaq 0xf8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x32b0
leaq 0x40(%r15), %rax
movq %rax, 0x70(%rsp)
leaq 0x8(%r15), %rax
movq %rax, 0x68(%rsp)
movq %r14, 0x10(%rsp)
testq %r14, %r14
leaq 0x402f(%rip), %rax      # 0xcda2
leaq 0x402f(%rip), %rcx      # 0xcda9
cmoveq %rax, %rcx
movq %rcx, 0x60(%rsp)
movq %r15, 0x58(%rsp)
movq 0x50(%r15), %rax
movl $0x0, 0xc(%rsp)
leaq 0x18(%rsp), %r14
leaq 0x138(%rsp), %r13
cmpq 0x70(%rsp), %rax
je 0x9023
movq %rax, %r12
leaq 0x20(%rax), %rsi
leaq 0x98(%rsp), %rdi
callq 0x3170
movl 0x40(%r12), %ebx
movq %r14, %rdi
movl %ebx, %esi
callq 0x5b3f
leaq 0xd8(%rsp), %rdi
movq %r14, %rsi
callq 0x3270
movq %r14, %rdi
callq 0x3130
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8e03
leaq 0x98(%rsp), %rsi
callq 0x5bb4
movl (%rax), %r15d
jmp 0x8e06
xorl %r15d, %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x5b3f
leaq 0xb8(%rsp), %rdi
movq %r14, %rsi
callq 0x3270
movq %r14, %rdi
callq 0x3130
movq 0x68(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x5bb4
movl (%rax), %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0x5b3f
leaq 0x118(%rsp), %rdi
movq %r14, %rsi
callq 0x3270
movq %r14, %rdi
callq 0x3130
testl %ebx, %ebx
jle 0x8eb9
cmpq $0x0, 0x10(%rsp)
je 0x8ec1
cmpl $0x9, %r15d
jg 0x8ed2
leaq 0x38(%rsp), %r15
movq %r15, %rdi
leaq 0x3c3e(%rip), %rsi      # 0xcabe
leaq 0xb8(%rsp), %rdx
callq 0x5c1a
movq %r14, %rdi
movq %r15, %rsi
leaq 0x3c51(%rip), %rdx      # 0xcaeb
callq 0x5a9a
movq %r13, %rdi
movq %r14, %rsi
callq 0x33d0
movq %r14, %rdi
callq 0x3130
leaq 0x38(%rsp), %rdi
jmp 0x8ef7
movq %r12, %r15
jmp 0x9016
movq %r13, %rdi
leaq 0x3bf0(%rip), %rsi      # 0xcabb
callq 0x33b0
jmp 0x8efc
movq %r14, %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x3c07(%rip), %rdx      # 0xcaeb
callq 0x5cda
movq %r13, %rdi
movq %r14, %rsi
callq 0x33d0
movq %r14, %rdi
callq 0x3130
movq %r13, %rdi
leaq 0x98(%rsp), %rsi
callq 0x33d0
movl 0xa0(%rsp), %r15d
pushq $0x17
popq %rax
subl %r15d, %eax
testl %eax, %eax
jle 0x8f3b
addl $-0x17, %r15d
testl %r15d, %r15d
je 0x8f3b
movq %r13, %rdi
leaq 0x3b8d(%rip), %rsi      # 0xcabe
callq 0x33b0
incl %r15d
jmp 0x8f22
movq %r13, %rdi
leaq 0x3e57(%rip), %rsi      # 0xcd9c
callq 0x33b0
movq %r12, %r15
cmpl $0x9, %ebx
jg 0x8f6b
movq %r14, %rdi
leaq 0x3b62(%rip), %rsi      # 0xcabe
leaq 0xd8(%rsp), %rdx
callq 0x5c1a
jmp 0x8f7b
movq %r14, %rdi
leaq 0xd8(%rsp), %rsi
callq 0x32b0
movq %r13, %rdi
movq %r14, %rsi
callq 0x33d0
movq %r14, %rdi
callq 0x3130
movq %r13, %rdi
movq 0x60(%rsp), %rsi
callq 0x33b0
movq %r13, %rdi
leaq 0x3df7(%rip), %rsi      # 0xcd9c
callq 0x33b0
cmpl $0xa, %ebp
leaq 0x3404(%rip), %rsi      # 0xc3b8
leaq 0x3b03(%rip), %rax      # 0xcabe
cmovlq %rax, %rsi
movq %r13, %rdi
callq 0x33b0
leaq 0x38(%rsp), %r12
movq %r12, %rdi
leaq 0x3e12(%rip), %rsi      # 0xcde8
leaq 0x118(%rsp), %rdx
callq 0x5c1a
movq %r14, %rdi
movq %r12, %rsi
leaq 0x3dc0(%rip), %rdx      # 0xcdb0
callq 0x5a9a
movq %r13, %rdi
movq %r14, %rsi
callq 0x33d0
addl %ebx, 0xc(%rsp)
movq %r14, %rdi
callq 0x3130
leaq 0x38(%rsp), %rdi
callq 0x3130
movq %r15, %rdi
callq 0x31a0
jmp 0x8da1
leaq 0x338d(%rip), %rbx      # 0xc3b7
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rdx
movq %rbx, %rsi
callq 0x3860
cmpl $0x0, 0xc(%rsp)
movq 0x10(%rsp), %r14
movq 0x58(%rsp), %r15
je 0x90f1
testq %r14, %r14
leaq 0x3d78(%rip), %rax      # 0xcdd3
leaq 0x3d6b(%rip), %rsi      # 0xcdcd
cmoveq %rax, %rsi
leaq 0x18(%rsp), %rdi
callq 0x33b0
movq %r15, %rdi
callq 0x8b94
leaq 0x158(%rsp), %rdi
xorl %edx, %edx
callq 0x87f8
leaq 0x3d4b(%rip), %rsi      # 0xcdd9
leaq 0x178(%rsp), %rdi
leaq 0x158(%rsp), %rdx
callq 0x8472
leaq 0x330d(%rip), %rdx      # 0xc3b7
leaq 0x38(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x5a9a
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x33d0
leaq 0x38(%rsp), %rdi
callq 0x3130
leaq 0x178(%rsp), %rdi
callq 0x3130
leaq 0x158(%rsp), %rdi
callq 0x3130
jmp 0x9102
leaq 0x3cf3(%rip), %rsi      # 0xcdeb
leaq 0x18(%rsp), %rdi
callq 0x33c0
testq %r14, %r14
leaq 0x32ac(%rip), %rsi      # 0xc3b8
cmoveq %rbx, %rsi
leaq 0xf8(%rsp), %rdi
callq 0x33b0
movq 0x9ea4(%rip), %rdi      # 0x12fc8
leaq 0x78(%rsp), %rsi
callq 0x3200
leaq 0x138(%rsp), %rsi
movq %rax, %rdi
callq 0x3200
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x3200
leaq 0xf8(%rsp), %rsi
movq %rax, %rdi
callq 0x3200
leaq 0x18(%rsp), %rdi
callq 0x3130
leaq 0xf8(%rsp), %rdi
callq 0x3130
leaq 0x78(%rsp), %rdi
callq 0x3130
leaq 0x118(%rsp), %rdi
callq 0x3130
leaq 0xb8(%rsp), %rdi
callq 0x3130
leaq 0xd8(%rsp), %rdi
callq 0x3130
leaq 0x138(%rsp), %rdi
callq 0x3130
leaq 0x98(%rsp), %rdi
callq 0x3130
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3130
jmp 0x91e1
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
callq 0x3130
jmp 0x91f3
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0x3130
jmp 0x9255
jmp 0x9277
jmp 0x9230
movq %rax, %rbx
jmp 0x9291
movq %rax, %rbx
jmp 0x929e
movq %rax, %rbx
jmp 0x92ab
movq %rax, %rbx
jmp 0x92b8
movq %rax, %rbx
jmp 0x92c5
jmp 0x9252
movq %rax, %rbx
jmp 0x9287
jmp 0x9252
jmp 0x9243
jmp 0x925e
jmp 0x9277
jmp 0x9252
jmp 0x9277
jmp 0x9277
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3130
jmp 0x9261
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x9266
jmp 0x9277
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3130
jmp 0x927a
jmp 0x9277
jmp 0x9277
jmp 0x9277
jmp 0x9277
jmp 0x9277
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x3130
leaq 0x78(%rsp), %rdi
callq 0x3130
leaq 0x118(%rsp), %rdi
callq 0x3130
leaq 0xb8(%rsp), %rdi
callq 0x3130
leaq 0xd8(%rsp), %rdi
callq 0x3130
leaq 0x138(%rsp), %rdi
callq 0x3130
leaq 0x98(%rsp), %rdi
callq 0x3130
movq %rbx, %rdi
callq 0x3380