// File: 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
movq %rsp, %rbp
subq $0x3b0, %rsp            # imm = 0x3B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x328(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x8740
movl $0x17, -0x1c(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x320(%rbp)
callq 0x3520
movq -0x320(%rbp), %rdx
leaq 0x975c(%rip), %rsi      # 0x1c3c8
leaq -0x40(%rbp), %rdi
callq 0x3b80
jmp 0x12c77
leaq -0x41(%rbp), %rdi
callq 0x3350
leaq -0x79(%rbp), %rdi
movq %rdi, -0x330(%rbp)
callq 0x3520
movq -0x330(%rbp), %rdx
leaq 0x972a(%rip), %rsi      # 0x1c3c8
leaq -0x78(%rbp), %rdi
callq 0x3b80
jmp 0x12ca9
leaq -0x79(%rbp), %rdi
callq 0x3350
movl $0x0, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x338(%rbp)
callq 0x3520
movq -0x338(%rbp), %rdx
leaq 0x96e4(%rip), %rsi      # 0x1c3c8
leaq -0xa8(%rbp), %rdi
callq 0x3b80
jmp 0x12cf2
leaq -0xa9(%rbp), %rdi
callq 0x3350
movl $0x0, -0xb0(%rbp)
movq -0x10(%rbp), %rax
testq %rax, %rax
sete -0xb1(%rbp)
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x340(%rbp)
callq 0x3520
movq -0x340(%rbp), %rdx
leaq 0x9691(%rip), %rsi      # 0x1c3c8
leaq -0xd8(%rbp), %rdi
callq 0x3b80
jmp 0x12d45
leaq -0xd9(%rbp), %rdi
callq 0x3350
movl $0x0, -0xe0(%rbp)
leaq -0x101(%rbp), %rdi
movq %rdi, -0x348(%rbp)
callq 0x3520
movq -0x348(%rbp), %rdx
leaq 0x964c(%rip), %rsi      # 0x1c3c8
leaq -0x100(%rbp), %rdi
callq 0x3b80
jmp 0x12d8a
leaq -0x101(%rbp), %rdi
callq 0x3350
leaq -0x129(%rbp), %rdi
movq %rdi, -0x350(%rbp)
callq 0x3520
movq -0x350(%rbp), %rdx
leaq 0x9fd2(%rip), %rsi      # 0x1cd89
leaq -0x128(%rbp), %rdi
callq 0x3b80
jmp 0x12dc5
leaq -0x129(%rbp), %rdi
callq 0x3350
testb $0x1, -0xb1(%rbp)
jne 0x12dea
leaq 0x9faf(%rip), %rax      # 0x1cd90
movq %rax, -0x358(%rbp)
jmp 0x12dfa
leaq 0x9fa9(%rip), %rax      # 0x1cd9a
movq %rax, -0x358(%rbp)
jmp 0x12dfa
movq -0x358(%rbp), %rsi
leaq -0x128(%rbp), %rdi
callq 0x32d0
jmp 0x12e0f
leaq 0x9f8e(%rip), %rsi      # 0x1cda4
leaq -0x128(%rbp), %rdi
callq 0x32d0
jmp 0x12e24
leaq -0x150(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x3170
jmp 0x12e39
movq -0x328(%rbp), %rdi
addq $0x38, %rdi
callq 0x8760
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x328(%rbp), %rdi
addq $0x38, %rdi
callq 0x87c0
movq %rax, -0x160(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x8790
testb $0x1, %al
jne 0x12e8b
jmp 0x133ef
leaq -0x18(%rbp), %rdi
callq 0x87f0
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x3050
jmp 0x12ea2
leaq -0x18(%rbp), %rdi
callq 0x87f0
movl 0x20(%rax), %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %esi
leaq -0x180(%rbp), %rdi
callq 0x8620
jmp 0x12ec8
leaq -0xa8(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x3390
leaq -0x180(%rbp), %rdi
callq 0x3200
cmpq $0x0, -0x10(%rbp)
jne 0x12ef8
xorl %eax, %eax
movl %eax, -0x35c(%rbp)
jmp 0x12f1d
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x8890
movq %rax, -0x368(%rbp)
jmp 0x12f0e
movq -0x368(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x35c(%rbp)
movl -0x35c(%rbp), %eax
movl %eax, -0xb0(%rbp)
movl -0xb0(%rbp), %esi
leaq -0x1a0(%rbp), %rdi
callq 0x8620
jmp 0x12f3d
leaq -0xd8(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
movq %rsi, -0x378(%rbp)
callq 0x3390
movq -0x378(%rbp), %rdi
callq 0x3200
movq -0x328(%rbp), %rdi
addq $0x8, %rdi
leaq -0x40(%rbp), %rsi
callq 0x8890
movq %rax, -0x370(%rbp)
jmp 0x12f80
movq -0x370(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xe0(%rbp)
movl -0xe0(%rbp), %esi
leaq -0x1c0(%rbp), %rdi
callq 0x8620
jmp 0x12fa3
leaq -0x100(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x3390
leaq -0x1c0(%rbp), %rdi
callq 0x3200
cmpl $0x0, -0x84(%rbp)
jle 0x133d6
movl -0x84(%rbp), %eax
addl -0x80(%rbp), %eax
movl %eax, -0x80(%rbp)
testb $0x1, -0xb1(%rbp)
jne 0x131b8
cmpl $0xa, -0xb0(%rbp)
jge 0x1315d
leaq 0x9ad2(%rip), %rsi      # 0x1cace
leaq -0x200(%rbp), %rdi
leaq -0xd8(%rbp), %rdx
callq 0x8970
jmp 0x13011
leaq 0x9ae3(%rip), %rdx      # 0x1cafb
leaq -0x1e0(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x8440
jmp 0x1302d
leaq -0x78(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x33e0
jmp 0x1303f
leaq -0x1e0(%rbp), %rdi
callq 0x3200
leaq -0x200(%rbp), %rdi
callq 0x3200
jmp 0x131b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x3350
jmp 0x136ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x3350
jmp 0x136f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa9(%rbp), %rdi
callq 0x3350
jmp 0x136ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd9(%rbp), %rdi
callq 0x3350
jmp 0x136e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x101(%rbp), %rdi
callq 0x3350
jmp 0x136d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x129(%rbp), %rdi
callq 0x3350
jmp 0x136c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x136bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x136b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1314c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x3200
leaq -0x200(%rbp), %rdi
callq 0x3200
jmp 0x136b1
leaq 0x9997(%rip), %rdx      # 0x1cafb
leaq -0x220(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x8c30
jmp 0x13179
leaq -0x78(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x33e0
jmp 0x1318b
leaq -0x220(%rbp), %rdi
callq 0x3200
jmp 0x131b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x3200
jmp 0x136b1
jmp 0x131cc
leaq 0x990c(%rip), %rsi      # 0x1cacb
leaq -0x78(%rbp), %rdi
callq 0x32d0
jmp 0x131ca
jmp 0x131cc
leaq -0x78(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x33e0
jmp 0x131db
leaq -0x40(%rbp), %rdi
callq 0x3470
movq %rax, %rcx
movl $0x17, %eax
subq %rcx, %rax
movl %eax, -0x224(%rbp)
cmpl $0x0, -0x224(%rbp)
jle 0x1323d
movl $0x0, -0x228(%rbp)
movl -0x228(%rbp), %eax
cmpl -0x224(%rbp), %eax
jge 0x1323b
leaq 0x98b1(%rip), %rsi      # 0x1cace
leaq -0x78(%rbp), %rdi
callq 0x32d0
jmp 0x13228
jmp 0x1322a
movl -0x228(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x228(%rbp)
jmp 0x13208
jmp 0x1323d
leaq 0x9b68(%rip), %rsi      # 0x1cdac
leaq -0x78(%rbp), %rdi
callq 0x32d0
jmp 0x1324f
cmpl $0xa, -0x84(%rbp)
jge 0x13276
leaq 0x986f(%rip), %rsi      # 0x1cace
leaq -0x248(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x8970
jmp 0x13274
jmp 0x1328d
leaq -0x248(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3170
jmp 0x1328b
jmp 0x1328d
leaq -0x78(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x33e0
jmp 0x1329f
leaq -0x248(%rbp), %rdi
callq 0x3200
testb $0x1, -0xb1(%rbp)
je 0x132c4
leaq 0x9af7(%rip), %rax      # 0x1cdb2
movq %rax, -0x380(%rbp)
jmp 0x132d4
leaq 0x9aee(%rip), %rax      # 0x1cdb9
movq %rax, -0x380(%rbp)
jmp 0x132d4
movq -0x380(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x32d0
jmp 0x132e6
leaq 0x9abf(%rip), %rsi      # 0x1cdac
leaq -0x78(%rbp), %rdi
callq 0x32d0
jmp 0x132f8
movl -0xe0(%rbp), %eax
subl $0xa, %eax
leaq 0x97c6(%rip), %rax      # 0x1cace
leaq 0x90b9(%rip), %rsi      # 0x1c3c8
cmovlq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x32d0
jmp 0x1331e
leaq 0x9ad3(%rip), %rsi      # 0x1cdf8
leaq -0x288(%rbp), %rdi
leaq -0x100(%rbp), %rdx
callq 0x8970
jmp 0x1333a
leaq 0x9a7f(%rip), %rdx      # 0x1cdc0
leaq -0x268(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x8440
jmp 0x13356
leaq -0x78(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x33e0
jmp 0x13368
leaq -0x268(%rbp), %rdi
callq 0x3200
leaq -0x288(%rbp), %rdi
callq 0x3200
jmp 0x133d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x3200
jmp 0x136b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x133c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x3200
leaq -0x288(%rbp), %rdi
callq 0x3200
jmp 0x136b1
jmp 0x133d8
leaq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x8810
movq %rax, -0x290(%rbp)
jmp 0x12e5b
leaq -0x2b1(%rbp), %rdi
movq %rdi, -0x388(%rbp)
callq 0x3520
movq -0x388(%rbp), %rdx
leaq 0x8fb7(%rip), %rsi      # 0x1c3c7
leaq -0x2b0(%rbp), %rdi
callq 0x3b80
jmp 0x1341e
leaq -0x2b1(%rbp), %rdi
callq 0x3350
cmpl $0x0, -0x80(%rbp)
je 0x1359c
testb $0x1, -0xb1(%rbp)
jne 0x1344d
leaq 0x9999(%rip), %rax      # 0x1cddd
movq %rax, -0x390(%rbp)
jmp 0x1345d
leaq 0x998f(%rip), %rax      # 0x1cde3
movq %rax, -0x390(%rbp)
jmp 0x1345d
movq -0x390(%rbp), %rsi
leaq -0x2b0(%rbp), %rdi
callq 0x32d0
jmp 0x13472
movq -0x328(%rbp), %rdi
callq 0x12a90
movss %xmm0, -0x394(%rbp)
jmp 0x13488
movss -0x394(%rbp), %xmm0
movq -0x328(%rbp), %rsi
leaq -0x318(%rbp), %rdi
xorl %edx, %edx
callq 0x11f30
jmp 0x134a7
leaq 0x993b(%rip), %rsi      # 0x1cde9
leaq -0x2f8(%rbp), %rdi
leaq -0x318(%rbp), %rdx
callq 0x11340
jmp 0x134c3
leaq 0x8efd(%rip), %rdx      # 0x1c3c7
leaq -0x2d8(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x8440
jmp 0x134df
leaq -0x2b0(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x33e0
jmp 0x134f4
leaq -0x2d8(%rbp), %rdi
callq 0x3200
leaq -0x2f8(%rbp), %rdi
callq 0x3200
leaq -0x318(%rbp), %rdi
callq 0x3200
jmp 0x135b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x2b1(%rbp), %rdi
callq 0x3350
jmp 0x136b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x136a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1358b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1357f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x3200
leaq -0x2f8(%rbp), %rdi
callq 0x3200
leaq -0x318(%rbp), %rdi
callq 0x3200
jmp 0x136a5
leaq 0x9858(%rip), %rsi      # 0x1cdfb
leaq -0x2b0(%rbp), %rdi
callq 0x3400
jmp 0x135b1
jmp 0x135b3
movb -0xb1(%rbp), %cl
leaq 0x8e07(%rip), %rax      # 0x1c3c7
leaq 0x8e01(%rip), %rsi      # 0x1c3c8
testb $0x1, %cl
cmovneq %rax, %rsi
leaq -0x150(%rbp), %rdi
callq 0x32d0
jmp 0x135dc
movq 0x139dd(%rip), %rdi     # 0x26fc0
leaq -0x128(%rbp), %rsi
callq 0x32b0
movq %rax, -0x3a0(%rbp)
jmp 0x135f8
movq -0x3a0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x32b0
movq %rax, -0x3a8(%rbp)
jmp 0x13611
movq -0x3a8(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x32b0
movq %rax, -0x3b0(%rbp)
jmp 0x1362d
movq -0x3b0(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x32b0
jmp 0x13642
leaq -0x2b0(%rbp), %rdi
callq 0x3200
leaq -0x150(%rbp), %rdi
callq 0x3200
leaq -0x128(%rbp), %rdi
callq 0x3200
leaq -0x100(%rbp), %rdi
callq 0x3200
leaq -0xd8(%rbp), %rdi
callq 0x3200
leaq -0xa8(%rbp), %rdi
callq 0x3200
leaq -0x78(%rbp), %rdi
callq 0x3200
leaq -0x40(%rbp), %rdi
callq 0x3200
addq $0x3b0, %rsp            # imm = 0x3B0
popq %rbp
retq
leaq -0x2b0(%rbp), %rdi
callq 0x3200
leaq -0x150(%rbp), %rdi
callq 0x3200
leaq -0x128(%rbp), %rdi
callq 0x3200
leaq -0x100(%rbp), %rdi
callq 0x3200
leaq -0xd8(%rbp), %rdi
callq 0x3200
leaq -0xa8(%rbp), %rdi
callq 0x3200
leaq -0x78(%rbp), %rdi
callq 0x3200
leaq -0x40(%rbp), %rdi
callq 0x3200
movq -0x50(%rbp), %rdi
callq 0x3510
nopl (%rax,%rax)