// File: /workspace/github_cpp_makefile_star2_O2/MichaelXanth[P]RPG_Game/Living/Heroes/Hero.cpp
// Function: Hero::isValidForSale(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, int&, int&, int const&)
bool Hero::isValidForSale(string testSelections[], int& column, int& row, const int& sellState) //checks if items is valid for sale
{
    if(sellState == 2)
    {
        if(!isValid(testSelections[0].c_str(),column,0,6))
            return false;
    }
    else
    {
        if(!isValid(testSelections[0].c_str(),column,0,3))
            return false;
    }

    if(!isNumeric(testSelections[1].c_str(),row))
        return false;

    switch(column)
    {
        case 1:
            if(sellState == 1)
            {
                if(row == 0 || row > weaponsArray.size())
                {
                    cerr << endl << "\033[31mError:\033[0m The input is invalid." << endl;
                    cerr << "Please, try again!" << endl << endl;
                    return false;
                }
            }
            else
            {
                if(row == 0 || row > iceSpellsArray.size())
                {
                    cerr << endl << "\033[31mError:\033[0m The input is invalid." << endl;
                    cerr << "Please, try again!" << endl << endl;
                    return false;
                }
            }

            break;

        case 2:
            if(sellState == 1)
            {
                if(row == 0 || row > armorsArray.size())
                {
                    cerr << endl << "\033[31mError:\033[0m The input is invalid." << endl;
                    cerr << "Please, try again!" << endl << endl;
                    return false;
                }
            }
            else
            {
                if(row == 0 || row > fireSpellsArray.size())
                {
                    cerr << endl << "\033[31mError:\033[0m The input is invalid." << endl;
                    cerr << "Please, try again!" << endl << endl;
                    return false;
                }
            }

            break;

        case 3:
            if(sellState == 1)
            {
                if(row == 0 || row > potionsArray.size())
                {
                    cerr << endl << "\033[31mError:\033[0m The input is invalid." << endl;
                    cerr << "Please, try again!" << endl << endl;
                    return false;
                }
            }
            else
            {
                if(row == 0 || row > lightingSpellsArray.size())
                {
                    cerr << endl << "\033[31mError:\033[0m The input is invalid." << endl;
                    cerr << "Please, try again!" << endl << endl;
                    return false;
                }
            }

            break;

        case 4:
            if(row == 0 || row > weaponsArray.size())
            {
                cerr << endl << "\033[31mError:\033[0m The input is invalid." << endl;
                cerr << "Please, try again!" << endl << endl;
                return false;
            }

            break;

        case 5:
            if(row == 0 || row > armorsArray.size())
            {
                cerr << endl << "\033[31mError:\033[0m The input is invalid." << endl;
                cerr << "Please, try again!" << endl << endl;
                return false;
            }

            break;

        case 6:
            if(row == 0 || row > potionsArray.size())
            {
                cerr << endl << "\033[31mError:\033[0m The input is invalid." << endl;
                cerr << "Please, try again!" << endl << endl;
                return false;
            }

            break;
    }
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %r8, %r15
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
cmpl $0x2, (%r8)
movq (%rsi), %rdi
leaq 0xc(%rsp), %rdx
jne 0xd6d8
andl $0x0, (%rdx)
leaq 0x8(%rsp), %rcx
movl $0x6, (%rcx)
jmp 0xd6e6
andl $0x0, (%rdx)
leaq 0x8(%rsp), %rcx
movl $0x3, (%rcx)
pushq $0x1
popq %r8
movq %r12, %rsi
callq 0xcb5c
testb %al, %al
je 0xd827
movq 0x20(%r13), %rdi
pushq $0x1
popq %rdx
movq %r14, %rsi
callq 0xcac0
testb %al, %al
je 0xd827
movl (%r12), %ecx
movb $0x1, %al
decl %ecx
cmpl $0x5, %ecx
ja 0xd829
leaq 0xe5d7(%rip), %rdx      # 0x1bd00
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x1, (%r15)
movslq (%r14), %rcx
jne 0xd7bf
testl %ecx, %ecx
jne 0xd76c
jmp 0xd7e2
movslq (%r14), %rcx
testq %rcx, %rcx
jne 0xd789
jmp 0xd7e2
cmpl $0x1, (%r15)
movslq (%r14), %rcx
jne 0xd7b1
testl %ecx, %ecx
jne 0xd7a1
jmp 0xd7e2
movslq (%r14), %rcx
testq %rcx, %rcx
je 0xd7e2
movq 0x88(%rbx), %rdx
subq 0x80(%rbx), %rdx
jmp 0xd7d9
cmpl $0x1, (%r15)
movslq (%r14), %rcx
jne 0xd7cd
testl %ecx, %ecx
je 0xd7e2
movq 0xb8(%rbx), %rdx
subq 0xb0(%rbx), %rdx
jmp 0xd7d9
movslq (%r14), %rcx
testq %rcx, %rcx
je 0xd7e2
movq 0xa0(%rbx), %rdx
subq 0x98(%rbx), %rdx
jmp 0xd7d9
testl %ecx, %ecx
je 0xd7e2
movq 0x40(%rbx), %rdx
subq 0x38(%rbx), %rdx
jmp 0xd7d9
testl %ecx, %ecx
je 0xd7e2
movq 0x70(%rbx), %rdx
subq 0x68(%rbx), %rdx
jmp 0xd7d9
testl %ecx, %ecx
je 0xd7e2
movq 0x58(%rbx), %rdx
subq 0x50(%rbx), %rdx
sarq $0x3, %rdx
cmpq %rcx, %rdx
jae 0xd829
movq 0x19807(%rip), %rbx     # 0x26ff0
movq %rbx, %rdi
callq 0x30d0
leaq 0xe45a(%rip), %rsi      # 0x1bc52
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30d0
leaq 0xe42f(%rip), %rsi      # 0x1bc3e
movq %rbx, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30d0
movq %rax, %rdi
callq 0x30d0
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop