// File: /workspace/github_cpp_makefile_star2_O3/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 0x11225
movl $0x0, (%rdx)
leaq 0x8(%rsp), %rcx
movl $0x6, (%rcx)
jmp 0x11236
movl $0x0, (%rdx)
leaq 0x8(%rsp), %rcx
movl $0x3, (%rcx)
movq %r12, %rsi
movl $0x1, %r8d
callq 0x10336
testb %al, %al
je 0x114ae
movq 0x20(%r13), %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x1023c
testb %al, %al
je 0x114ae
movl (%r12), %ecx
movb $0x1, %al
decl %ecx
cmpl $0x5, %ecx
ja 0x114b0
leaq 0x13a83(%rip), %rdx     # 0x24d00
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x1, (%r15)
movslq (%r14), %rcx
jne 0x11439
testl %ecx, %ecx
je 0x1145c
movq 0x88(%rbx), %rdx
subq 0x80(%rbx), %rdx
jmp 0x11453
movslq (%r14), %rcx
testq %rcx, %rcx
je 0x11355
movq 0xb8(%rbx), %rdx
subq 0xb0(%rbx), %rdx
jmp 0x11348
cmpl $0x1, (%r15)
movslq (%r14), %rcx
jne 0x1142b
testl %ecx, %ecx
je 0x1145c
movq 0xa0(%rbx), %rdx
subq 0x98(%rbx), %rdx
jmp 0x11453
movslq (%r14), %rcx
testq %rcx, %rcx
je 0x11355
movq 0x88(%rbx), %rdx
subq 0x80(%rbx), %rdx
jmp 0x11348
cmpl $0x1, (%r15)
movslq (%r14), %rcx
jne 0x11447
testl %ecx, %ecx
je 0x1145c
movq 0xb8(%rbx), %rdx
subq 0xb0(%rbx), %rdx
jmp 0x11453
movslq (%r14), %rcx
testq %rcx, %rcx
je 0x11355
movq 0xa0(%rbx), %rdx
subq 0x98(%rbx), %rdx
sarq $0x3, %rdx
cmpq %rcx, %rdx
jae 0x114b0
movq 0x1dc94(%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, %r14
leaq 0x138c5(%rip), %rsi     # 0x24c52
movl $0x25, %edx
movq %rax, %rdi
callq 0x31e0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
leaq 0x13876(%rip), %rsi     # 0x24c3e
movl $0x12, %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
movq %rax, %rbx
movq (%rax), %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
jmp 0x114ae
testl %ecx, %ecx
je 0x1145c
movq 0x40(%rbx), %rdx
subq 0x38(%rbx), %rdx
jmp 0x11453
testl %ecx, %ecx
je 0x1145c
movq 0x70(%rbx), %rdx
subq 0x68(%rbx), %rdx
jmp 0x11453
testl %ecx, %ecx
je 0x1145c
movq 0x58(%rbx), %rdx
subq 0x50(%rbx), %rdx
sarq $0x3, %rdx
cmpq %rcx, %rdx
jae 0x114b0
movq 0x1db8d(%rip), %rbx     # 0x2eff0
movq %rbx, %rdi
callq 0x30a0
movq %rax, %r14
leaq 0x137dd(%rip), %rsi     # 0x24c52
movl $0x25, %edx
movq %rax, %rdi
callq 0x31e0
movq %r14, %rdi
callq 0x30a0
leaq 0x137ad(%rip), %rsi     # 0x24c3e
movl $0x12, %edx
movq %rbx, %rdi
callq 0x31e0
movq %rbx, %rdi
callq 0x30a0
movq %rax, %rdi
callq 0x30a0
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq