// File: MichaelXanth[P]RPG_Game/Market/Market.cpp
// Function: Market::isValidForPurchase(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, int&, int&, int const&)
bool Market::isValidForPurchase(string testSelections[], int& column, int& row, const int& buyState)
{
    if (!isValid(testSelections[0].c_str(),column,0,6))
        return false;

    if (!isNumeric(testSelections[1].c_str(),row))
        return false;

    if (buyState == 0 && column > 3) {
        if (weaponsForSale || potionsForSale || armorsForSale)
            cerr << endl << "\033[35mWarning:\033[0m There are no more available Item slots." << endl;
        else
            cerr << endl << "\033[35mWarning:\033[0m Sorry, there are no available Items for sale." << endl;
        return false;
    }

    if (buyState == 1 && column < 4) {
        if (lightingSpellsForSale || fireSpellsForSale || iceSpellsForSale)
            cerr << endl << "\033[35mWarning:\033[0m There are no more available Spell slots." << endl;
        else
            cerr << endl << "\033[35mWarning:\033[0m Sorry, there are no available Spells for sale." << endl;
        return false;
    }

    switch(column)
    {
        case 1:
            if (row == 0 || row > iceSpellsForSale) {
                cerr << "\n\033[31mError:\033[0m The input is invalid." << endl;
                cerr << "Please, try again!" << endl << endl;
                return false;
            }

            break;

        case 2:
            if (row == 0 || row > fireSpellsForSale) {
                cerr << "\n\033[31mError:\033[0m The input is invalid." << endl;
                cerr << "Please, try again!" << endl << endl;
                return false;
            }

            break;

        case 3:
            if (row == 0 || row > lightingSpellsForSale) {
                cerr << "\n\033[31mError:\033[0m The input is invalid." << endl;
                cerr << "Please, try again!" << endl << endl;
                return false;
            }

            break;

        case 4:
            if (row == 0 || row > weaponsForSale){
                cerr << "\n\033[31mError:\033[0m The input is invalid." << endl;
                cerr << "Please, try again!" << endl << endl;
                return false;
            }

            break;

        case 5:
            if (row == 0 || row > armorsForSale) {
                cerr << "\n\033[31mError:\033[0m The input is invalid." << endl;
                cerr << "Please, try again!" << endl << endl;
                return false;
            }

            break;

        case 6:
            if (row == 0 || row > potionsForSale) {
                cerr << "\n\033[31mError:\033[0m The input is invalid." << endl;
                cerr << "Please, try again!" << endl << endl;
                return false;
            }

            break;
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4100
movq %rax, %rdi
movq -0x20(%rbp), %rsi
movl $0x0, -0x34(%rbp)
movl $0x6, -0x38(%rbp)
leaq -0x34(%rbp), %rdx
leaq -0x38(%rbp), %rcx
movl $0x1, %r8d
callq 0x1e340
xorb $-0x1, %al
testb $0x1, %al
jne 0x2ef8d
jmp 0x2ef96
movb $0x0, -0x1(%rbp)
jmp 0x2f428
movq -0x18(%rbp), %rdi
addq $0x20, %rdi
callq 0x4100
movq %rax, %rdi
movq -0x28(%rbp), %rsi
movl $0x1, %edx
callq 0x1e240
testb $0x1, %al
jne 0x2efc1
movb $0x0, -0x1(%rbp)
jmp 0x2f428
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x2f06f
movq -0x20(%rbp), %rax
cmpl $0x3, (%rax)
jle 0x2f06f
movq -0x40(%rbp), %rax
cmpl $0x0, 0x1d4(%rax)
jne 0x2f002
movq -0x40(%rbp), %rax
cmpl $0x0, 0x1d8(%rax)
jne 0x2f002
movq -0x40(%rbp), %rax
cmpl $0x0, 0x1dc(%rax)
je 0x2f035
movq 0x1efe7(%rip), %rdi     # 0x4dff0
movq 0x1efa8(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
leaq 0x1117d(%rip), %rsi     # 0x4019c
callq 0x4260
movq %rax, %rdi
movq 0x1ef8a(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x2f066
movq 0x1efb4(%rip), %rdi     # 0x4dff0
movq 0x1ef75(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
leaq 0x11184(%rip), %rsi     # 0x401d6
callq 0x4260
movq %rax, %rdi
movq 0x1ef57(%rip), %rsi     # 0x4dfb8
callq 0x4290
movb $0x0, -0x1(%rbp)
jmp 0x2f428
movq -0x30(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x2f11d
movq -0x20(%rbp), %rax
cmpl $0x4, (%rax)
jge 0x2f11d
movq -0x40(%rbp), %rax
cmpl $0x0, 0x1c8(%rax)
jne 0x2f0b0
movq -0x40(%rbp), %rax
cmpl $0x0, 0x1cc(%rax)
jne 0x2f0b0
movq -0x40(%rbp), %rax
cmpl $0x0, 0x1d0(%rax)
je 0x2f0e3
movq 0x1ef39(%rip), %rdi     # 0x4dff0
movq 0x1eefa(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
leaq 0x11149(%rip), %rsi     # 0x40216
callq 0x4260
movq %rax, %rdi
movq 0x1eedc(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x2f114
movq 0x1ef06(%rip), %rdi     # 0x4dff0
movq 0x1eec7(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
leaq 0x11151(%rip), %rsi     # 0x40251
callq 0x4260
movq %rax, %rdi
movq 0x1eea9(%rip), %rsi     # 0x4dfb8
callq 0x4290
movb $0x0, -0x1(%rbp)
jmp 0x2f428
movq -0x20(%rbp), %rax
movl (%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x5, %eax
ja 0x2f424
movq -0x48(%rbp), %rax
leaq 0x10fc9(%rip), %rcx     # 0x40108
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f163
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl 0x1d0(%rcx), %eax
jbe 0x2f1bf
movq 0x1ee86(%rip), %rdi     # 0x4dff0
leaq 0xebb4(%rip), %rsi      # 0x3dd25
callq 0x4260
movq %rax, %rdi
movq 0x1ee38(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq 0x1ee64(%rip), %rdi     # 0x4dff0
leaq 0xeb7f(%rip), %rsi      # 0x3dd12
callq 0x4260
movq %rax, %rdi
movq 0x1ee16(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x1ee07(%rip), %rsi     # 0x4dfb8
callq 0x4290
movb $0x0, -0x1(%rbp)
jmp 0x2f428
jmp 0x2f424
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f1df
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl 0x1cc(%rcx), %eax
jbe 0x2f23b
movq 0x1ee0a(%rip), %rdi     # 0x4dff0
leaq 0xeb38(%rip), %rsi      # 0x3dd25
callq 0x4260
movq %rax, %rdi
movq 0x1edbc(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq 0x1ede8(%rip), %rdi     # 0x4dff0
leaq 0xeb03(%rip), %rsi      # 0x3dd12
callq 0x4260
movq %rax, %rdi
movq 0x1ed9a(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x1ed8b(%rip), %rsi     # 0x4dfb8
callq 0x4290
movb $0x0, -0x1(%rbp)
jmp 0x2f428
jmp 0x2f424
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f25b
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl 0x1c8(%rcx), %eax
jbe 0x2f2b7
movq 0x1ed8e(%rip), %rdi     # 0x4dff0
leaq 0xeabc(%rip), %rsi      # 0x3dd25
callq 0x4260
movq %rax, %rdi
movq 0x1ed40(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq 0x1ed6c(%rip), %rdi     # 0x4dff0
leaq 0xea87(%rip), %rsi      # 0x3dd12
callq 0x4260
movq %rax, %rdi
movq 0x1ed1e(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x1ed0f(%rip), %rsi     # 0x4dfb8
callq 0x4290
movb $0x0, -0x1(%rbp)
jmp 0x2f428
jmp 0x2f424
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f2d7
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl 0x1d4(%rcx), %eax
jbe 0x2f333
movq 0x1ed12(%rip), %rdi     # 0x4dff0
leaq 0xea40(%rip), %rsi      # 0x3dd25
callq 0x4260
movq %rax, %rdi
movq 0x1ecc4(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq 0x1ecf0(%rip), %rdi     # 0x4dff0
leaq 0xea0b(%rip), %rsi      # 0x3dd12
callq 0x4260
movq %rax, %rdi
movq 0x1eca2(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x1ec93(%rip), %rsi     # 0x4dfb8
callq 0x4290
movb $0x0, -0x1(%rbp)
jmp 0x2f428
jmp 0x2f424
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f353
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl 0x1dc(%rcx), %eax
jbe 0x2f3ac
movq 0x1ec96(%rip), %rdi     # 0x4dff0
leaq 0xe9c4(%rip), %rsi      # 0x3dd25
callq 0x4260
movq %rax, %rdi
movq 0x1ec48(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq 0x1ec74(%rip), %rdi     # 0x4dff0
leaq 0xe98f(%rip), %rsi      # 0x3dd12
callq 0x4260
movq %rax, %rdi
movq 0x1ec26(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x1ec17(%rip), %rsi     # 0x4dfb8
callq 0x4290
movb $0x0, -0x1(%rbp)
jmp 0x2f428
jmp 0x2f424
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f3c9
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl 0x1d8(%rcx), %eax
jbe 0x2f422
movq 0x1ec20(%rip), %rdi     # 0x4dff0
leaq 0xe94e(%rip), %rsi      # 0x3dd25
callq 0x4260
movq %rax, %rdi
movq 0x1ebd2(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq 0x1ebfe(%rip), %rdi     # 0x4dff0
leaq 0xe919(%rip), %rsi      # 0x3dd12
callq 0x4260
movq %rax, %rdi
movq 0x1ebb0(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x1eba1(%rip), %rsi     # 0x4dfb8
callq 0x4290
movb $0x0, -0x1(%rbp)
jmp 0x2f428
jmp 0x2f424
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)