// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r15
movq %rcx, %r14
movq %rsi, %r13
movq (%rsi), %rax
leaq -0x30(%rbp), %r9
andl $0x0, (%r9)
movq %rdx, %r12
movq %rdi, %rbx
leaq -0x2c(%rbp), %rcx
movl $0x6, (%rcx)
pushq $0x1
popq %r8
movq %rax, %rdi
movq %rdx, %rsi
movq %r9, %rdx
callq 0xcb5c
testb %al, %al
je 0x12ccd
movq 0x20(%r13), %rdi
pushq $0x1
popq %rdx
movq %r14, %rsi
callq 0xcac0
testb %al, %al
je 0x12ccd
movl (%r15), %eax
testl %eax, %eax
sete %dl
movl (%r12), %ecx
cmpl $0x4, %ecx
setge %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x12c3b
movl 0x1d4(%rbx), %r15d
movl 0x1d8(%rbx), %r14d
movl 0x1dc(%rbx), %ebx
movq 0x143d4(%rip), %rdi     # 0x26ff0
callq 0x30d0
testl %r15d, %r15d
jne 0x12c85
testl %r14d, %r14d
jne 0x12c85
testl %ebx, %ebx
jne 0x12c85
leaq 0xb560(%rip), %rsi      # 0x1e196
jmp 0x12cbd
cmpl $0x1, %eax
sete %al
cmpl $0x4, %ecx
setl %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x12c8e
movl 0x1c8(%rbx), %r15d
movl 0x1cc(%rbx), %r14d
movl 0x1d0(%rbx), %ebx
movq 0x14387(%rip), %rdi     # 0x26ff0
callq 0x30d0
testl %r15d, %r15d
jne 0x12cb6
testl %r14d, %r14d
jne 0x12cb6
testl %ebx, %ebx
jne 0x12cb6
leaq 0xb58e(%rip), %rsi      # 0x1e211
jmp 0x12cbd
leaq 0xb4d0(%rip), %rsi      # 0x1e15c
jmp 0x12cbd
movb $0x1, %al
decl %ecx
cmpl $0x5, %ecx
ja 0x12ccf
leaq 0xb412(%rip), %rdx      # 0x1e0b0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl (%r14), %ecx
decl %ecx
cmpl 0x1d0(%rbx), %ecx
jb 0x12ccf
jmp 0x12d27
leaq 0xb519(%rip), %rsi      # 0x1e1d6
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30d0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%r14), %ecx
decl %ecx
cmpl 0x1dc(%rbx), %ecx
jb 0x12ccf
jmp 0x12d27
movl (%r14), %ecx
decl %ecx
cmpl 0x1c8(%rbx), %ecx
jb 0x12ccf
jmp 0x12d27
movl (%r14), %ecx
decl %ecx
cmpl 0x1d4(%rbx), %ecx
jb 0x12ccf
jmp 0x12d27
movl (%r14), %ecx
decl %ecx
cmpl 0x1cc(%rbx), %ecx
jb 0x12ccf
jmp 0x12d27
movl (%r14), %ecx
decl %ecx
cmpl 0x1d8(%rbx), %ecx
jb 0x12ccf
movq 0x142c2(%rip), %rbx     # 0x26ff0
leaq 0x8f1c(%rip), %rsi      # 0x1bc51
movq %rbx, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30d0
leaq 0x8ef2(%rip), %rsi      # 0x1bc3e
movq %rbx, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30d0
jmp 0x12cc5
nop