// File: /workspace/github_cpp_makefile_star2_O3/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 0x10336
testb %al, %al
je 0x193b5
movq 0x20(%r13), %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x1023c
testb %al, %al
je 0x193b5
movl (%r12), %eax
testl %eax, %eax
sete %dl
movl (%r15), %ecx
cmpl $0x4, %ecx
setge %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x192cb
movl 0x1d4(%rbx), %r12d
movl 0x1d8(%rbx), %r15d
movl 0x1dc(%rbx), %r14d
movq 0x15d7b(%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 0x19341
testl %r15d, %r15d
jne 0x19341
testl %r14d, %r14d
jne 0x19341
leaq 0xded5(%rip), %rsi      # 0x27196
movl $0x3f, %edx
jmp 0x19386
cmpl $0x1, %eax
sete %al
cmpl $0x4, %ecx
setl %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x1934f
movl 0x1c8(%rbx), %r12d
movl 0x1cc(%rbx), %r15d
movl 0x1d0(%rbx), %r14d
movq 0x15cf6(%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 0x1937a
testl %r15d, %r15d
jne 0x1937a
testl %r14d, %r14d
jne 0x1937a
leaq 0xded7(%rip), %rsi      # 0x27211
movl $0x40, %edx
jmp 0x19386
leaq 0xde14(%rip), %rsi      # 0x2715c
movl $0x39, %edx
jmp 0x19386
movb $0x1, %al
decl %ecx
cmpl $0x5, %ecx
ja 0x193b7
leaq 0xdd51(%rip), %rdx      # 0x270b0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl (%r14), %ecx
decl %ecx
cmpl 0x1d0(%rbx), %ecx
jb 0x193b7
jmp 0x1940f
leaq 0xde55(%rip), %rsi      # 0x271d6
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 0x193b7
jmp 0x1940f
movl (%r14), %ecx
decl %ecx
cmpl 0x1c8(%rbx), %ecx
jb 0x193b7
jmp 0x1940f
movl (%r14), %ecx
decl %ecx
cmpl 0x1d4(%rbx), %ecx
jb 0x193b7
jmp 0x1940f
movl (%r14), %ecx
decl %ecx
cmpl 0x1cc(%rbx), %ecx
jb 0x193b7
jmp 0x1940f
movl (%r14), %ecx
decl %ecx
cmpl 0x1d8(%rbx), %ecx
jb 0x193b7
movq 0x15bda(%rip), %rbx     # 0x2eff0
leaq 0xb834(%rip), %rsi      # 0x24c51
movl $0x26, %edx
movq %rbx, %rdi
callq 0x31e0
movq %rbx, %rdi
callq 0x30a0
leaq 0xb805(%rip), %rsi      # 0x24c3e
movl $0x12, %edx
movq %rbx, %rdi
callq 0x31e0
movq %rbx, %rdi
callq 0x30a0
movq %rax, %rdi
callq 0x30a0
jmp 0x193b5
nop