// File: dnegovan[P]Intruder-On-Donnar-V/Backpack.cpp
// Function: Backpack::discardMenu()
void Backpack::discardMenu()
{
    while (true)
    {
        //cast from unsigned int to avoid compiler warnings
        int size = static_cast<int>(contents.size());

        int input = 0;
        while (input < 1 || input > (size + 2))
        {
            std::cout << RESET << std::endl;
            for (int i = 0; i < size; i++)
            {
                //count menu numbers from 1 not 0
                std::cout << i+1 << ". Discard " << contents[i] << "\n";
            }
            std::cout << size + 1 << ". Show neutralization formula"
                      << std::endl
                      << size + 2 << ". Go back" << std::endl;
            input = getInteger();
        }


        if (input == size + 2)
        {
            //they chose cancel
            return;
        }

        if (input == size + 1)
        {
            displayFormula();
        }
        else
        {
            //save string to be deleted
            std::string toDelete = contents[input - 1];
            //store iterator of its location in pack
            auto iterator = contents.begin() + input - 1;

            //erase their selection if it's not important to the game
            if (std::find(importantItems.begin(), importantItems.end(),
                           toDelete) != importantItems.end())
            {
                std::cout << NARRATOR_COLOR << "\nYou might need that."
                          << std::endl;
            }
            else
            {
                contents.erase(iterator);
                std::cout << NARRATOR_COLOR << "\n"
                          << toDelete << " has been discarded.\n" << RESET;
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
callq 0x13490
movl %eax, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movb $0x1, %al
cmpl $0x1, -0x10(%rbp)
movb %al, -0x99(%rbp)
jl 0x12d12
movl -0x10(%rbp), %eax
movl -0xc(%rbp), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
setg %al
movb %al, -0x99(%rbp)
movb -0x99(%rbp), %al
testb $0x1, %al
jne 0x12d21
jmp 0x12e1c
movq 0x162a0(%rip), %rdi     # 0x28fc8
leaq 0xc3a4(%rip), %rsi      # 0x1f0d3
callq 0x3210
movq %rax, %rdi
movq 0x16272(%rip), %rsi     # 0x28fb0
callq 0x3240
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x12db3
movl -0x14(%rbp), %esi
addl $0x1, %esi
movq 0x16269(%rip), %rdi     # 0x28fc8
callq 0x33b0
movq %rax, %rdi
leaq 0xc387(%rip), %rsi      # 0x1f0f5
callq 0x3210
movq -0x98(%rbp), %rdi
movq %rax, -0xa8(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x134b0
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0xcba1(%rip), %rsi      # 0x1f944
callq 0x3210
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x12d4a
movl -0xc(%rbp), %esi
addl $0x1, %esi
movq 0x16208(%rip), %rdi     # 0x28fc8
callq 0x33b0
movq %rax, %rdi
leaq 0xc331(%rip), %rsi      # 0x1f100
callq 0x3210
movq %rax, %rdi
movq 0x161d2(%rip), %rsi     # 0x28fb0
callq 0x3240
movq %rax, %rdi
movl -0xc(%rbp), %esi
addl $0x2, %esi
callq 0x33b0
movq %rax, %rdi
leaq 0xc323(%rip), %rsi      # 0x1f11e
callq 0x3210
movq %rax, %rdi
movq 0x161a6(%rip), %rsi     # 0x28fb0
callq 0x3240
callq 0x175c0
movl %eax, -0x10(%rbp)
jmp 0x12cf0
movl -0x10(%rbp), %eax
movl -0xc(%rbp), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jne 0x12e32
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movl -0x10(%rbp), %eax
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x12e50
movq -0x98(%rbp), %rdi
callq 0x13060
jmp 0x1304f
movq -0x98(%rbp), %rdi
movl -0x10(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x134b0
movq %rax, %rsi
leaq -0x38(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x30f0
movq -0x98(%rbp), %rdi
callq 0x134d0
movq %rax, -0x50(%rbp)
movslq -0x10(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x13500
movq %rax, -0x48(%rbp)
leaq -0x48(%rbp), %rdi
movl $0x1, %esi
callq 0x13540
movq %rax, -0x40(%rbp)
leaq 0x164af(%rip), %rdi     # 0x29360
movq %rdi, -0xc0(%rbp)
callq 0x13610
movq -0xc0(%rbp), %rdi
movq %rax, -0x60(%rbp)
callq 0x13640
movq -0xb8(%rbp), %rdx
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x135c0
movq %rax, -0xb0(%rbp)
jmp 0x12eee
movq -0xb0(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq 0x16460(%rip), %rdi     # 0x29360
callq 0x13640
movq %rax, -0x80(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x13580
testb $0x1, %al
jne 0x12f1c
jmp 0x12f88
movq 0x160a5(%rip), %rdi     # 0x28fc8
leaq 0xc18e(%rip), %rsi      # 0x1f0b8
callq 0x3210
movq %rax, -0xc8(%rbp)
jmp 0x12f38
movq -0xc8(%rbp), %rdi
leaq 0xc1e2(%rip), %rsi      # 0x1f128
callq 0x3210
movq %rax, -0xd0(%rbp)
jmp 0x12f54
movq -0xd0(%rbp), %rdi
movq 0x1604e(%rip), %rsi     # 0x28fb0
callq 0x3240
jmp 0x12f69
jmp 0x13046
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x3448
jmp 0x13054
leaq -0x88(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x136e0
movq -0x98(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x13670
movq %rax, -0xd8(%rbp)
jmp 0x12fb4
movq -0xd8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq 0x15fff(%rip), %rdi     # 0x28fc8
leaq 0xc0e8(%rip), %rsi      # 0x1f0b8
callq 0x3210
movq %rax, -0xe0(%rbp)
jmp 0x12fde
movq -0xe0(%rbp), %rdi
leaq 0xc958(%rip), %rsi      # 0x1f944
callq 0x3210
movq %rax, -0xe8(%rbp)
jmp 0x12ffa
movq -0xe8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x31e0
movq %rax, -0xf0(%rbp)
jmp 0x13013
movq -0xf0(%rbp), %rdi
leaq 0xc11d(%rip), %rsi      # 0x1f13e
callq 0x3210
movq %rax, -0xf8(%rbp)
jmp 0x1302f
movq -0xf8(%rbp), %rdi
leaq 0xc096(%rip), %rsi      # 0x1f0d3
callq 0x3210
jmp 0x13044
jmp 0x13046
leaq -0x38(%rbp), %rdi
callq 0x3448
jmp 0x12cda
movq -0x70(%rbp), %rdi
callq 0x33c0
nopl (%rax)