// File: MichaelXanth[P]RPG_Game/Market/Market.cpp
// Function: Market::Purchase(Hero&, int const&)
void Market::Purchase(Hero& hero, const int& buyState)
{
    int  column, row;
    char confirmation;
    bool errFlag = false;
    string testSelections[2];

    cout << endl;
    cout << "-------------------------------" << endl << endl;
    cout << "(Type 0 to cancel)" << endl;

    if (buyState == 0) {
        cout << "Choose a Spell by selecting its position in the table(e.g.: \033[1;34m<\033[1;33mcolumn\033[1;34m> <\033[1;33mrow\033[1;34m>\033[0m): ";

        cout << "\n\n\n\n\n\n\n\n";
        cout << "\033[8A\033[77C";
    
    } else if (buyState == 1) {
        cout << "Choose an Item by selecting its position in the table(e.g.: \033[1;34m<\033[1;33mcolumn\033[1;34m> <\033[1;33mrow\033[1;34m>\033[0m): ";

        cout << "\n\n\n\n\n\n\n\n";
        cout << "\033[8A\033[77C";
    
    } else {
        cout << "Choose an Item or a Spell by selecting its position in the table(e.g.: \033[1;34m<\033[1;33mcolumn\033[1;34m> <\033[1;33mrow\033[1;34m>\033[0m): ";

        cout << "\n\n\n\n\n\n\n\n";
        cout << "\033[8A\033[88C";
    }

    cout << "\033[s";

    do {
        if (errFlag)
            usleep(1800000);

        cout << "\033[u";
        cout << "\033[J";
        cout << "\033[s";

        errFlag = true;

        cin >> testSelections[0];

        if (testSelections[0] == "0") {
            column = 0;
            break;
        }

        cin >> testSelections[1];
    } while(!isValidForPurchase(testSelections,column,row,buyState));

    if (column == 0) {
        cout << endl << "\033[1;32mInfo:\033[0m The purchase was canceled." << endl << endl;
        return;
    }

    switch(column)
    {
        case 1:
            cout << endl << "Are you sure you want to buy \"\033[1m\033[38;5;32m" << iceSpellsArray[iceSpellsIndexes[row - 1]]->GetName() << "\033[0m\" Ice Spell? [y/n]: ";

            do {
                cin >> confirmation;
            } while(confirmation != 'y' && confirmation != 'Y' && confirmation != 'n' && confirmation != 'N');

            if (confirmation == 'n' || confirmation == 'N')
                break;

            hero.ChangeMoney(-iceSpellsArray[iceSpellsIndexes[row - 1]]->GetPrice());
            hero.AddNewSpell(iceSpellsArray[iceSpellsIndexes[row - 1]]);
            iceSpellsArray.erase(iceSpellsArray.begin() + iceSpellsIndexes[row - 1]);
            RecalcMostItems();

            break;

        case 2:
            cout << endl << "Are you sure you want to buy \"\033[1m\033[1;31m" << fireSpellsArray[fireSpellsIndexes[row - 1]]->GetName() << "\033[0m\" Fire Spell? [y/n]: ";

            do {
                cin >> confirmation;
            } while(confirmation != 'y' && confirmation != 'Y' && confirmation != 'n' && confirmation != 'N');

            if (confirmation == 'n' || confirmation == 'N')
                break;

            hero.ChangeMoney(-fireSpellsArray[fireSpellsIndexes[row - 1]]->GetPrice());
            hero.AddNewSpell(fireSpellsArray[fireSpellsIndexes[row - 1]]);
            fireSpellsArray.erase(fireSpellsArray.begin() + fireSpellsIndexes[row - 1]);
            RecalcMostItems();

            break;

        case 3:
            cout << endl << "Are you sure you want to buy \"\033[1m\033[38;5;15m" << lightingSpellsArray[lightingSpellsIndexes[row - 1]]->GetName() << "\033[0m\" Lighting Spell? [y/n]: ";

            do {
                cin >> confirmation;
            } while(confirmation != 'y' && confirmation != 'Y' && confirmation != 'n' && confirmation != 'N');

            if (confirmation == 'n' || confirmation == 'N')
                break;

            hero.ChangeMoney(-lightingSpellsArray[lightingSpellsIndexes[row - 1]]->GetPrice());
            hero.AddNewSpell(lightingSpellsArray[lightingSpellsIndexes[row - 1]]);
            lightingSpellsArray.erase(lightingSpellsArray.begin() + lightingSpellsIndexes[row - 1]);
            RecalcMostItems();

            break;

        case 4:
            cout << endl << "Are you sure you want to buy \"\033[1m\033[38;5;166m" << weaponsArray[weaponsIndexes[row - 1]]->GetName() << "\033[0m\" Weapon? [y/n]: ";

            do {
                cin >> confirmation;
            } while(confirmation != 'y' && confirmation != 'Y' && confirmation != 'n' && confirmation != 'N');

            if (confirmation == 'n' || confirmation == 'N')
                break;

            hero.ChangeMoney(-weaponsArray[weaponsIndexes[row - 1]]->GetPrice());
            hero.AddNewItem(weaponsArray[weaponsIndexes[row - 1]]);
            weaponsArray.erase(weaponsArray.begin() + weaponsIndexes[row - 1]);
            RecalcMostItems();

            break;

        case 5:
            cout << endl << "Are you sure you want to buy \"\033[1m\033[38;5;28m" << armorsArray[armorsIndexes[row - 1]]->GetName() << "\033[0m\" Armor? [y/n]: ";

            do {
                cin >> confirmation;
            } while(confirmation != 'y' && confirmation != 'Y' && confirmation != 'n' && confirmation != 'N');

            if (confirmation == 'n' || confirmation == 'N')
                break;

            hero.ChangeMoney(-(armorsArray[armorsIndexes[row - 1]]->GetPrice()));
            hero.AddNewItem(armorsArray[armorsIndexes[row - 1]]);
            armorsArray.erase(armorsArray.begin() + armorsIndexes[row - 1]);
            RecalcMostItems();

            break;

        case 6:
            cout << endl << "Are you sure you want to buy \"\033[1m\033[38;5;90m" << potionsArray[potionsIndexes[row - 1]]->GetName() << "\033[0m\" Potion? [y/n]: ";

            do {
                cin >> confirmation;
            } while(confirmation != 'y' && confirmation != 'Y' && confirmation != 'n' && confirmation != 'N');

            if (confirmation == 'n' || confirmation == 'N')
                break;

            hero.ChangeMoney(-potionsArray[potionsIndexes[row - 1]]->GetPrice());
            hero.AddNewItem(potionsArray[potionsIndexes[row - 1]]);
            potionsArray.erase(potionsArray.begin() + potionsIndexes[row - 1]);
            RecalcMostItems();

            break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4a0, %rsp            # imm = 0x4A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x218(%rbp)
movb $0x0, -0x22(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, %rcx
addq $0x40, %rcx
movq %rcx, -0x210(%rbp)
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x4380
movq -0x220(%rbp), %rax
movq -0x210(%rbp), %rcx
addq $0x20, %rax
cmpq %rcx, %rax
movq %rax, -0x208(%rbp)
jne 0x3650f
movq 0x17a81(%rip), %rdi     # 0x4dfc8
movq 0x17a6a(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x36555
movq 0x17a6c(%rip), %rdi     # 0x4dfc8
leaq 0x9d2f(%rip), %rsi      # 0x40292
callq 0x4260
movq %rax, -0x228(%rbp)
jmp 0x36571
movq -0x228(%rbp), %rdi
movq 0x17a39(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, -0x230(%rbp)
jmp 0x3658d
movq -0x230(%rbp), %rdi
movq 0x17a1d(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x365a2
movq 0x17a1f(%rip), %rdi     # 0x4dfc8
leaq 0x9e2d(%rip), %rsi      # 0x403dd
callq 0x4260
movq %rax, -0x238(%rbp)
jmp 0x365be
movq -0x238(%rbp), %rdi
movq 0x179ec(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x365d3
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x36631
movq 0x179e5(%rip), %rdi     # 0x4dfc8
leaq 0x9e06(%rip), %rsi      # 0x403f0
callq 0x4260
jmp 0x365f1
movq 0x179d0(%rip), %rdi     # 0x4dfc8
leaq 0x9e66(%rip), %rsi      # 0x40465
callq 0x4260
jmp 0x36606
movq 0x179bb(%rip), %rdi     # 0x4dfc8
leaq 0x9e5a(%rip), %rsi      # 0x4046e
callq 0x4260
jmp 0x3661b
jmp 0x366be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x3791f
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x3667b
movq 0x17987(%rip), %rdi     # 0x4dfc8
leaq 0x9e30(%rip), %rsi      # 0x40478
callq 0x4260
jmp 0x3664f
movq 0x17972(%rip), %rdi     # 0x4dfc8
leaq 0x9e08(%rip), %rsi      # 0x40465
callq 0x4260
jmp 0x36664
movq 0x1795d(%rip), %rdi     # 0x4dfc8
leaq 0x9dfc(%rip), %rsi      # 0x4046e
callq 0x4260
jmp 0x36679
jmp 0x366bc
movq 0x17946(%rip), %rdi     # 0x4dfc8
leaq 0x9e64(%rip), %rsi      # 0x404ed
callq 0x4260
jmp 0x36690
movq 0x17931(%rip), %rdi     # 0x4dfc8
leaq 0x9dc7(%rip), %rsi      # 0x40465
callq 0x4260
jmp 0x366a5
movq 0x1791c(%rip), %rdi     # 0x4dfc8
leaq 0x9eba(%rip), %rsi      # 0x4056d
callq 0x4260
jmp 0x366ba
jmp 0x366bc
jmp 0x366be
movq 0x17903(%rip), %rdi     # 0x4dfc8
leaq 0x71b2(%rip), %rsi      # 0x3d87e
callq 0x4260
jmp 0x366d3
jmp 0x366d5
testb $0x1, -0x22(%rbp)
je 0x366e9
movl $0x1b7740, %edi         # imm = 0x1B7740
callq 0x4390
jmp 0x366e7
jmp 0x366e9
movq 0x178d8(%rip), %rdi     # 0x4dfc8
leaq 0x71b1(%rip), %rsi      # 0x3d8a8
callq 0x4260
jmp 0x366fe
movq 0x178c3(%rip), %rdi     # 0x4dfc8
leaq 0x9127(%rip), %rsi      # 0x3f833
callq 0x4260
jmp 0x36713
movq 0x178ae(%rip), %rdi     # 0x4dfc8
leaq 0x715d(%rip), %rsi      # 0x3d87e
callq 0x4260
jmp 0x36728
movb $0x1, -0x22(%rbp)
movq 0x178a5(%rip), %rdi     # 0x4dfd8
leaq -0x70(%rbp), %rsi
callq 0x4340
jmp 0x3673e
leaq 0x9e32(%rip), %rsi      # 0x40577
leaq -0x70(%rbp), %rdi
callq 0x3a0c0
movb %al, -0x239(%rbp)
jmp 0x36756
movb -0x239(%rbp), %al
testb $0x1, %al
jne 0x36762
jmp 0x3676b
movl $0x0, -0x1c(%rbp)
jmp 0x367b3
leaq -0x50(%rbp), %rsi
movq 0x17862(%rip), %rdi     # 0x4dfd8
callq 0x4340
jmp 0x3677d
jmp 0x3677f
movq -0x218(%rbp), %rdi
movq -0x18(%rbp), %r8
leaq -0x70(%rbp), %rsi
leaq -0x1c(%rbp), %rdx
leaq -0x20(%rbp), %rcx
callq 0x2ef30
movb %al, -0x23a(%rbp)
jmp 0x367a3
movb -0x23a(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x366d5
cmpl $0x0, -0x1c(%rbp)
jne 0x3682e
movq 0x17808(%rip), %rdi     # 0x4dfc8
movq 0x177f1(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, -0x248(%rbp)
jmp 0x367d5
movq -0x248(%rbp), %rdi
leaq 0x9d96(%rip), %rsi      # 0x40579
callq 0x4260
movq %rax, -0x250(%rbp)
jmp 0x367f1
movq -0x250(%rbp), %rdi
movq 0x177b9(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, -0x258(%rbp)
jmp 0x3680d
movq -0x258(%rbp), %rdi
movq 0x1779d(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x36822
movl $0x1, -0x80(%rbp)
jmp 0x378cf
movl -0x1c(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x260(%rbp)
subl $0x5, %eax
ja 0x378c8
movq -0x260(%rbp), %rax
leaq 0x98cd(%rip), %rcx      # 0x40120
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x17765(%rip), %rdi     # 0x4dfc8
movq 0x1774e(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, -0x268(%rbp)
jmp 0x36878
movq -0x268(%rbp), %rdi
leaq 0x9d1f(%rip), %rsi      # 0x405a5
callq 0x4260
movq %rax, -0x270(%rbp)
jmp 0x36894
movq -0x218(%rbp), %rdi
movq %rdi, %rax
addq $0xd8, %rax
movq %rax, -0x278(%rbp)
addq $0x168, %rdi            # imm = 0x168
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x278(%rbp), %rdi
movslq (%rax), %rsi
callq 0x27180
movq (%rax), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0xa0(%rbp), %rdi
callq *%rax
jmp 0x368e3
movq -0x270(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x4210
movq %rax, -0x280(%rbp)
jmp 0x368ff
movq -0x280(%rbp), %rdi
leaq 0x9cc5(%rip), %rsi      # 0x405d2
callq 0x4260
jmp 0x36914
leaq -0xa0(%rbp), %rdi
callq 0x4160
movq 0x176b1(%rip), %rdi     # 0x4dfd8
leaq -0x21(%rbp), %rsi
callq 0x4360
jmp 0x36932
jmp 0x36934
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x79, %ecx
movb %al, -0x281(%rbp)
je 0x36977
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x59, %ecx
movb %al, -0x281(%rbp)
je 0x36977
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x6e, %ecx
movb %al, -0x281(%rbp)
je 0x36977
movsbl -0x21(%rbp), %eax
cmpl $0x4e, %eax
setne %al
movb %al, -0x281(%rbp)
movb -0x281(%rbp), %al
testb $0x1, %al
jne 0x36920
movsbl -0x21(%rbp), %eax
cmpl $0x6e, %eax
je 0x36993
movsbl -0x21(%rbp), %eax
cmpl $0x4e, %eax
jne 0x369b5
jmp 0x378c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x4160
jmp 0x3791f
movq -0x218(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x298(%rbp)
movq %rdi, %rax
addq $0xd8, %rax
movq %rax, -0x290(%rbp)
addq $0x168, %rdi            # imm = 0x168
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x290(%rbp), %rdi
movslq (%rax), %rsi
callq 0x27180
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0x288(%rbp)
jmp 0x36a0e
movq -0x298(%rbp), %rdi
movl -0x288(%rbp), %esi
negl %esi
callq 0x1f9d0
jmp 0x36a24
movq -0x218(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq %rdi, %rax
addq $0xd8, %rax
movq %rax, -0x2a8(%rbp)
addq $0x168, %rdi            # imm = 0x168
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x2a8(%rbp), %rdi
movslq (%rax), %rsi
callq 0x27180
movq -0x2a0(%rbp), %rdi
movq (%rax), %rsi
callq 0x1f0e0
jmp 0x36a7a
movq -0x218(%rbp), %rdi
addq $0xd8, %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x27210
movq -0x218(%rbp), %rdi
movq %rax, -0xb8(%rbp)
addq $0x168, %rdi            # imm = 0x168
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movslq (%rax), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x27240
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x27280
movq -0x2b8(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x271a0
movq %rax, -0x2b0(%rbp)
jmp 0x36afb
movq -0x218(%rbp), %rdi
movq -0x2b0(%rbp), %rax
movq %rax, -0xc0(%rbp)
callq 0x2ed20
jmp 0x378c8
movq 0x174a7(%rip), %rdi     # 0x4dfc8
movq 0x17490(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, -0x2c0(%rbp)
jmp 0x36b36
movq -0x2c0(%rbp), %rdi
leaq 0x9aa7(%rip), %rsi      # 0x405eb
callq 0x4260
movq %rax, -0x2c8(%rbp)
jmp 0x36b52
movq -0x218(%rbp), %rdi
movq %rdi, %rax
addq $0xc0, %rax
movq %rax, -0x2d0(%rbp)
addq $0x150, %rdi            # imm = 0x150
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x2d0(%rbp), %rdi
movslq (%rax), %rsi
callq 0x272c0
movq (%rax), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0xe0(%rbp), %rdi
callq *%rax
jmp 0x36ba1
movq -0x2c8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x4210
movq %rax, -0x2d8(%rbp)
jmp 0x36bbd
movq -0x2d8(%rbp), %rdi
leaq 0x9a4a(%rip), %rsi      # 0x40615
callq 0x4260
jmp 0x36bd2
leaq -0xe0(%rbp), %rdi
callq 0x4160
movq 0x173f3(%rip), %rdi     # 0x4dfd8
leaq -0x21(%rbp), %rsi
callq 0x4360
jmp 0x36bf0
jmp 0x36bf2
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x79, %ecx
movb %al, -0x2d9(%rbp)
je 0x36c35
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x59, %ecx
movb %al, -0x2d9(%rbp)
je 0x36c35
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x6e, %ecx
movb %al, -0x2d9(%rbp)
je 0x36c35
movsbl -0x21(%rbp), %eax
cmpl $0x4e, %eax
setne %al
movb %al, -0x2d9(%rbp)
movb -0x2d9(%rbp), %al
testb $0x1, %al
jne 0x36bde
movsbl -0x21(%rbp), %eax
cmpl $0x6e, %eax
je 0x36c51
movsbl -0x21(%rbp), %eax
cmpl $0x4e, %eax
jne 0x36c73
jmp 0x378c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x4160
jmp 0x3791f
movq -0x218(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x2f0(%rbp)
movq %rdi, %rax
addq $0xc0, %rax
movq %rax, -0x2e8(%rbp)
addq $0x150, %rdi            # imm = 0x150
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x2e8(%rbp), %rdi
movslq (%rax), %rsi
callq 0x272c0
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0x2e0(%rbp)
jmp 0x36ccc
movq -0x2f0(%rbp), %rdi
movl -0x2e0(%rbp), %esi
negl %esi
callq 0x1f9d0
jmp 0x36ce2
movq -0x218(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x2f8(%rbp)
movq %rdi, %rax
addq $0xc0, %rax
movq %rax, -0x300(%rbp)
addq $0x150, %rdi            # imm = 0x150
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x300(%rbp), %rdi
movslq (%rax), %rsi
callq 0x272c0
movq -0x2f8(%rbp), %rdi
movq (%rax), %rsi
callq 0x1f160
jmp 0x36d38
movq -0x218(%rbp), %rdi
addq $0xc0, %rdi
movq %rdi, -0x310(%rbp)
callq 0x27350
movq -0x218(%rbp), %rdi
movq %rax, -0xf8(%rbp)
addq $0x150, %rdi            # imm = 0x150
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movslq (%rax), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x27380
movq %rax, -0xf0(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x273c0
movq -0x310(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x272e0
movq %rax, -0x308(%rbp)
jmp 0x36db9
movq -0x218(%rbp), %rdi
movq -0x308(%rbp), %rax
movq %rax, -0x100(%rbp)
callq 0x2ed20
jmp 0x378c8
movq 0x171e9(%rip), %rdi     # 0x4dfc8
movq 0x171d2(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, -0x318(%rbp)
jmp 0x36df4
movq -0x318(%rbp), %rdi
leaq 0x982d(%rip), %rsi      # 0x4062f
callq 0x4260
movq %rax, -0x320(%rbp)
jmp 0x36e10
movq -0x218(%rbp), %rdi
movq %rdi, %rax
addq $0xa8, %rax
movq %rax, -0x328(%rbp)
addq $0x138, %rdi            # imm = 0x138
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x328(%rbp), %rdi
movslq (%rax), %rsi
callq 0x27400
movq (%rax), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0x120(%rbp), %rdi
callq *%rax
jmp 0x36e5f
movq -0x320(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x4210
movq %rax, -0x330(%rbp)
jmp 0x36e7b
movq -0x330(%rbp), %rdi
leaq 0x97d3(%rip), %rsi      # 0x4065c
callq 0x4260
jmp 0x36e90
leaq -0x120(%rbp), %rdi
callq 0x4160
movq 0x17135(%rip), %rdi     # 0x4dfd8
leaq -0x21(%rbp), %rsi
callq 0x4360
jmp 0x36eae
jmp 0x36eb0
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x79, %ecx
movb %al, -0x331(%rbp)
je 0x36ef3
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x59, %ecx
movb %al, -0x331(%rbp)
je 0x36ef3
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x6e, %ecx
movb %al, -0x331(%rbp)
je 0x36ef3
movsbl -0x21(%rbp), %eax
cmpl $0x4e, %eax
setne %al
movb %al, -0x331(%rbp)
movb -0x331(%rbp), %al
testb $0x1, %al
jne 0x36e9c
movsbl -0x21(%rbp), %eax
cmpl $0x6e, %eax
je 0x36f0f
movsbl -0x21(%rbp), %eax
cmpl $0x4e, %eax
jne 0x36f31
jmp 0x378c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x4160
jmp 0x3791f
movq -0x218(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x348(%rbp)
movq %rdi, %rax
addq $0xa8, %rax
movq %rax, -0x340(%rbp)
addq $0x138, %rdi            # imm = 0x138
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x340(%rbp), %rdi
movslq (%rax), %rsi
callq 0x27400
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0x338(%rbp)
jmp 0x36f8a
movq -0x348(%rbp), %rdi
movl -0x338(%rbp), %esi
negl %esi
callq 0x1f9d0
jmp 0x36fa0
movq -0x218(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x350(%rbp)
movq %rdi, %rax
addq $0xa8, %rax
movq %rax, -0x358(%rbp)
addq $0x138, %rdi            # imm = 0x138
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x358(%rbp), %rdi
movslq (%rax), %rsi
callq 0x27400
movq -0x350(%rbp), %rdi
movq (%rax), %rsi
callq 0x1f1e0
jmp 0x36ff6
movq -0x218(%rbp), %rdi
addq $0xa8, %rdi
movq %rdi, -0x368(%rbp)
callq 0x27490
movq -0x218(%rbp), %rdi
movq %rax, -0x138(%rbp)
addq $0x138, %rdi            # imm = 0x138
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movslq (%rax), %rsi
leaq -0x138(%rbp), %rdi
callq 0x274c0
movq %rax, -0x130(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x27500
movq -0x368(%rbp), %rdi
movq -0x128(%rbp), %rsi
callq 0x27420
movq %rax, -0x360(%rbp)
jmp 0x37077
movq -0x218(%rbp), %rdi
movq -0x360(%rbp), %rax
movq %rax, -0x140(%rbp)
callq 0x2ed20
jmp 0x378c8
movq 0x16f2b(%rip), %rdi     # 0x4dfc8
movq 0x16f14(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, -0x370(%rbp)
jmp 0x370b2
movq -0x370(%rbp), %rdi
leaq 0x95ba(%rip), %rsi      # 0x4067a
callq 0x4260
movq %rax, -0x378(%rbp)
jmp 0x370ce
movq -0x218(%rbp), %rdi
movq %rdi, %rax
addq $0xf0, %rax
movq %rax, -0x380(%rbp)
addq $0x180, %rdi            # imm = 0x180
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x380(%rbp), %rdi
movslq (%rax), %rsi
callq 0x27540
movq (%rax), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x160(%rbp), %rdi
callq *%rax
jmp 0x3711c
movq -0x378(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x4210
movq %rax, -0x388(%rbp)
jmp 0x37138
movq -0x388(%rbp), %rdi
leaq 0x9562(%rip), %rsi      # 0x406a8
callq 0x4260
jmp 0x3714d
leaq -0x160(%rbp), %rdi
callq 0x4160
movq 0x16e78(%rip), %rdi     # 0x4dfd8
leaq -0x21(%rbp), %rsi
callq 0x4360
jmp 0x3716b
jmp 0x3716d
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x79, %ecx
movb %al, -0x389(%rbp)
je 0x371b0
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x59, %ecx
movb %al, -0x389(%rbp)
je 0x371b0
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x6e, %ecx
movb %al, -0x389(%rbp)
je 0x371b0
movsbl -0x21(%rbp), %eax
cmpl $0x4e, %eax
setne %al
movb %al, -0x389(%rbp)
movb -0x389(%rbp), %al
testb $0x1, %al
jne 0x37159
movsbl -0x21(%rbp), %eax
cmpl $0x6e, %eax
je 0x371cc
movsbl -0x21(%rbp), %eax
cmpl $0x4e, %eax
jne 0x371ee
jmp 0x378c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x4160
jmp 0x3791f
movq -0x218(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x3a0(%rbp)
movq %rdi, %rax
addq $0xf0, %rax
movq %rax, -0x398(%rbp)
addq $0x180, %rdi            # imm = 0x180
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x398(%rbp), %rdi
movslq (%rax), %rsi
callq 0x27540
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movl %eax, -0x390(%rbp)
jmp 0x37247
movq -0x3a0(%rbp), %rdi
movl -0x390(%rbp), %esi
negl %esi
callq 0x1f9d0
jmp 0x3725d
movq -0x218(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x3a8(%rbp)
movq %rdi, %rax
addq $0xf0, %rax
movq %rax, -0x3b0(%rbp)
addq $0x180, %rdi            # imm = 0x180
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x3b0(%rbp), %rdi
movslq (%rax), %rsi
callq 0x27540
movq -0x3a8(%rbp), %rdi
movq (%rax), %rsi
callq 0x1f260
jmp 0x372b3
movq -0x218(%rbp), %rdi
addq $0xf0, %rdi
movq %rdi, -0x3c0(%rbp)
callq 0x275d0
movq -0x218(%rbp), %rdi
movq %rax, -0x178(%rbp)
addq $0x180, %rdi            # imm = 0x180
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movslq (%rax), %rsi
leaq -0x178(%rbp), %rdi
callq 0x27600
movq %rax, -0x170(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x27640
movq -0x3c0(%rbp), %rdi
movq -0x168(%rbp), %rsi
callq 0x27560
movq %rax, -0x3b8(%rbp)
jmp 0x37334
movq -0x218(%rbp), %rdi
movq -0x3b8(%rbp), %rax
movq %rax, -0x180(%rbp)
callq 0x2ed20
jmp 0x378c8
movq 0x16c6e(%rip), %rdi     # 0x4dfc8
movq 0x16c57(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, -0x3c8(%rbp)
jmp 0x3736f
movq -0x3c8(%rbp), %rdi
leaq 0x9341(%rip), %rsi      # 0x406be
callq 0x4260
movq %rax, -0x3d0(%rbp)
jmp 0x3738b
movq -0x218(%rbp), %rdi
movq %rdi, %rax
addq $0x120, %rax            # imm = 0x120
movq %rax, -0x3d8(%rbp)
addq $0x1b0, %rdi            # imm = 0x1B0
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x3d8(%rbp), %rdi
movslq (%rax), %rsi
callq 0x27680
movq (%rax), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x1a0(%rbp), %rdi
callq *%rax
jmp 0x373d9
movq -0x3d0(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x4210
movq %rax, -0x3e0(%rbp)
jmp 0x373f5
movq -0x3e0(%rbp), %rdi
leaq 0x92e8(%rip), %rsi      # 0x406eb
callq 0x4260
jmp 0x3740a
leaq -0x1a0(%rbp), %rdi
callq 0x4160
movq 0x16bbb(%rip), %rdi     # 0x4dfd8
leaq -0x21(%rbp), %rsi
callq 0x4360
jmp 0x37428
jmp 0x3742a
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x79, %ecx
movb %al, -0x3e1(%rbp)
je 0x3746d
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x59, %ecx
movb %al, -0x3e1(%rbp)
je 0x3746d
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x6e, %ecx
movb %al, -0x3e1(%rbp)
je 0x3746d
movsbl -0x21(%rbp), %eax
cmpl $0x4e, %eax
setne %al
movb %al, -0x3e1(%rbp)
movb -0x3e1(%rbp), %al
testb $0x1, %al
jne 0x37416
movsbl -0x21(%rbp), %eax
cmpl $0x6e, %eax
je 0x37489
movsbl -0x21(%rbp), %eax
cmpl $0x4e, %eax
jne 0x374ab
jmp 0x378c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x4160
jmp 0x3791f
movq -0x218(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x3f8(%rbp)
movq %rdi, %rax
addq $0x120, %rax            # imm = 0x120
movq %rax, -0x3f0(%rbp)
addq $0x1b0, %rdi            # imm = 0x1B0
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x3f0(%rbp), %rdi
movslq (%rax), %rsi
callq 0x27680
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movl %eax, -0x3e8(%rbp)
jmp 0x37504
movq -0x3f8(%rbp), %rdi
movl -0x3e8(%rbp), %esi
negl %esi
callq 0x1f9d0
jmp 0x3751a
movq -0x218(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x400(%rbp)
movq %rdi, %rax
addq $0x120, %rax            # imm = 0x120
movq %rax, -0x408(%rbp)
addq $0x1b0, %rdi            # imm = 0x1B0
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x408(%rbp), %rdi
movslq (%rax), %rsi
callq 0x27680
movq -0x400(%rbp), %rdi
movq (%rax), %rsi
callq 0x1f2e0
jmp 0x37570
movq -0x218(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
movq %rdi, -0x418(%rbp)
callq 0x27710
movq -0x218(%rbp), %rdi
movq %rax, -0x1b8(%rbp)
addq $0x1b0, %rdi            # imm = 0x1B0
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movslq (%rax), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x27740
movq %rax, -0x1b0(%rbp)
leaq -0x1a8(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x27780
movq -0x418(%rbp), %rdi
movq -0x1a8(%rbp), %rsi
callq 0x276a0
movq %rax, -0x410(%rbp)
jmp 0x375f1
movq -0x218(%rbp), %rdi
movq -0x410(%rbp), %rax
movq %rax, -0x1c0(%rbp)
callq 0x2ed20
jmp 0x378c8
movq 0x169b1(%rip), %rdi     # 0x4dfc8
movq 0x1699a(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, -0x420(%rbp)
jmp 0x3762c
movq -0x420(%rbp), %rdi
leaq 0x90c6(%rip), %rsi      # 0x40700
callq 0x4260
movq %rax, -0x428(%rbp)
jmp 0x37648
movq -0x218(%rbp), %rdi
movq %rdi, %rax
addq $0x108, %rax            # imm = 0x108
movq %rax, -0x430(%rbp)
addq $0x198, %rdi            # imm = 0x198
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x430(%rbp), %rdi
movslq (%rax), %rsi
callq 0x277c0
movq (%rax), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x1e0(%rbp), %rdi
callq *%rax
jmp 0x37696
movq -0x428(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x4210
movq %rax, -0x438(%rbp)
jmp 0x376b2
movq -0x438(%rbp), %rdi
leaq 0x906d(%rip), %rsi      # 0x4072d
callq 0x4260
jmp 0x376c7
leaq -0x1e0(%rbp), %rdi
callq 0x4160
movq 0x168fe(%rip), %rdi     # 0x4dfd8
leaq -0x21(%rbp), %rsi
callq 0x4360
jmp 0x376e5
jmp 0x376e7
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x79, %ecx
movb %al, -0x439(%rbp)
je 0x3772a
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x59, %ecx
movb %al, -0x439(%rbp)
je 0x3772a
movsbl -0x21(%rbp), %ecx
xorl %eax, %eax
cmpl $0x6e, %ecx
movb %al, -0x439(%rbp)
je 0x3772a
movsbl -0x21(%rbp), %eax
cmpl $0x4e, %eax
setne %al
movb %al, -0x439(%rbp)
movb -0x439(%rbp), %al
testb $0x1, %al
jne 0x376d3
movsbl -0x21(%rbp), %eax
cmpl $0x6e, %eax
je 0x37746
movsbl -0x21(%rbp), %eax
cmpl $0x4e, %eax
jne 0x37768
jmp 0x378c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x4160
jmp 0x3791f
movq -0x218(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x450(%rbp)
movq %rdi, %rax
addq $0x108, %rax            # imm = 0x108
movq %rax, -0x448(%rbp)
addq $0x198, %rdi            # imm = 0x198
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x448(%rbp), %rdi
movslq (%rax), %rsi
callq 0x277c0
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movl %eax, -0x440(%rbp)
jmp 0x377c1
movq -0x450(%rbp), %rdi
movl -0x440(%rbp), %esi
negl %esi
callq 0x1f9d0
jmp 0x377d7
movq -0x218(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x458(%rbp)
movq %rdi, %rax
addq $0x108, %rax            # imm = 0x108
movq %rax, -0x460(%rbp)
addq $0x198, %rdi            # imm = 0x198
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movq -0x460(%rbp), %rdi
movslq (%rax), %rsi
callq 0x277c0
movq -0x458(%rbp), %rdi
movq (%rax), %rsi
callq 0x1f360
jmp 0x3782d
movq -0x218(%rbp), %rdi
addq $0x108, %rdi            # imm = 0x108
movq %rdi, -0x470(%rbp)
callq 0x27850
movq -0x218(%rbp), %rdi
movq %rax, -0x1f8(%rbp)
addq $0x198, %rdi            # imm = 0x198
movl -0x20(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x3a0f0
movslq (%rax), %rsi
leaq -0x1f8(%rbp), %rdi
callq 0x27880
movq %rax, -0x1f0(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x278c0
movq -0x470(%rbp), %rdi
movq -0x1e8(%rbp), %rsi
callq 0x277e0
movq %rax, -0x468(%rbp)
jmp 0x378ae
movq -0x218(%rbp), %rdi
movq -0x468(%rbp), %rax
movq %rax, -0x200(%rbp)
callq 0x2ed20
movl $0x0, -0x80(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x480(%rbp)
addq $0x40, %rax
movq %rax, -0x478(%rbp)
movq -0x478(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x488(%rbp)
callq 0x4160
movq -0x480(%rbp), %rcx
movq -0x488(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x478(%rbp)
jne 0x378e5
addq $0x4a0, %rsp            # imm = 0x4A0
popq %rbp
retq
leaq -0x70(%rbp), %rax
movq %rax, -0x498(%rbp)
addq $0x40, %rax
movq %rax, -0x490(%rbp)
movq -0x490(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x4a0(%rbp)
callq 0x4160
movq -0x498(%rbp), %rcx
movq -0x4a0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x490(%rbp)
jne 0x37935
jmp 0x37968
movq -0x78(%rbp), %rdi
callq 0x4440
nopw %cs:(%rax,%rax)