// File: /workspace/github_cpp_makefile_star2_O1/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, %r12
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %rbx
movq (%rsi), %rdi
leaq -0x30(%rbp), %rdx
movl $0x0, (%rdx)
leaq -0x2c(%rbp), %rcx
movl $0x6, (%rcx)
movq %r15, %rsi
movl $0x1, %r8d
callq 0x103de
testb %al, %al
je 0x19395
movq 0x20(%r13), %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x102dc
testb %al, %al
je 0x19395
movl (%r12), %eax
testl %eax, %eax
sete %dl
movl (%r15), %ecx
cmpl $0x4, %ecx
setge %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x192ab
movl 0x1d4(%rbx), %r12d
movl 0x1d8(%rbx), %r15d
movl 0x1dc(%rbx), %r14d
movq 0x15d9b(%rip), %rbx     # 0x2eff0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq %rax, %rbx
testl %r12d, %r12d
jne 0x19321
testl %r15d, %r15d
jne 0x19321
testl %r14d, %r14d
jne 0x19321
leaq 0xdec5(%rip), %rsi      # 0x27166
movl $0x3f, %edx
jmp 0x19366
cmpl $0x1, %eax
sete %al
cmpl $0x4, %ecx
setl %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x1932f
movl 0x1c8(%rbx), %r12d
movl 0x1cc(%rbx), %r15d
movl 0x1d0(%rbx), %r14d
movq 0x15d16(%rip), %rbx     # 0x2eff0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq %rax, %rbx
testl %r12d, %r12d
jne 0x1935a
testl %r15d, %r15d
jne 0x1935a
testl %r14d, %r14d
jne 0x1935a
leaq 0xdec7(%rip), %rsi      # 0x271e1
movl $0x40, %edx
jmp 0x19366
leaq 0xde04(%rip), %rsi      # 0x2712c
movl $0x39, %edx
jmp 0x19366
movb $0x1, %al
decl %ecx
cmpl $0x5, %ecx
ja 0x19397
leaq 0xdd39(%rip), %rdx      # 0x27078
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl (%r14), %ecx
decl %ecx
cmpl 0x1d0(%rbx), %ecx
jb 0x19397
jmp 0x193ef
leaq 0xde45(%rip), %rsi      # 0x271a6
movl $0x3a, %edx
movq %rbx, %rdi
callq 0x31e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
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 0x19397
jmp 0x193ef
movl (%r14), %ecx
decl %ecx
cmpl 0x1c8(%rbx), %ecx
jb 0x19397
jmp 0x193ef
movl (%r14), %ecx
decl %ecx
cmpl 0x1d4(%rbx), %ecx
jb 0x19397
jmp 0x193ef
movl (%r14), %ecx
decl %ecx
cmpl 0x1cc(%rbx), %ecx
jb 0x19397
jmp 0x193ef
movl (%r14), %ecx
decl %ecx
cmpl 0x1d8(%rbx), %ecx
jb 0x19397
movq 0x15bfa(%rip), %rbx     # 0x2eff0
leaq 0xb854(%rip), %rsi      # 0x24c51
movl $0x26, %edx
movq %rbx, %rdi
callq 0x31e0
movq %rbx, %rdi
callq 0x30a0
leaq 0xb825(%rip), %rsi      # 0x24c3e
movl $0x12, %edx
movq %rbx, %rdi
callq 0x31e0
movq %rbx, %rdi
callq 0x30a0
movq %rax, %rdi
callq 0x30a0
jmp 0x19395
nop