// File: rozpo[P]enemy/data/game/shop/Shop.cpp
// Function: Shop::openShop(std::shared_ptr<Player>&)
void Shop::openShop(std::shared_ptr<Player> &player)
{
    int x;
    int heal_cost;
    int recover_cost = 0;

    while(true)
    {
        recover_cost = 0;
        heal_cost = player->max_hitpoints-player->hitpoints;
        if(heal_cost > player->gold)
            heal_cost = player->gold;

        for(int i = 0; i < 4; i++)
            recover_cost += 10-player->uses[i];

        print(player->gold, heal_cost, recover_cost);
        std::cin >> x;
        switch(x)
        {
            case e_shop_heal:
            {
                if(player->gold >= heal_cost)
                {
                    if(player->hitpoints > 0)
                    {
                        player->hitpoints += heal_cost;
                        player->gold-=heal_cost;
                        std::cout << player->name << " is now healthy\n";
                    }
                    else
                    {
                        std::cout << "You can heal only live characters\n";
                    }
                }
                else
                {
                    std::cout << "You dont have enough money \n";
                }
            }
                break;
            case e_shop_revive:
            {
                if(player->gold >= 100)
                {
                    if(player->hitpoints <= 0)
                    {
                        player->hitpoints = player->max_hitpoints;
                        player->gold-=100;
                        std::cout << player->name << " is now alive\n";
                    }
                    else
                    {
                        std::cout << "You can revive only dead characters\n";
                    }
                }
                else
                {
                    std::cout << "You dont have enough money \n";
                }
            }
                break;
            case e_shop_recover:
            {
                if(player->gold >= recover_cost)
                {
                    for(int i=0; i < 4; i++)
                        player->uses[i]=10;
                    player->gold-=recover_cost;
                    recover_cost = 0;
                    std::cout << player->name << " skills was recovered\n";
                }
                else
                {
                    std::cout << "You dont have enough money \n";
                }
            }
                break;

            case e_shop_add_hitpoints:
            {
                if(player->gold >= 75)
                {
                    player->max_hitpoints += 10;
                    player->hitpoints += 10;
                    player->gold-=75;
                    std::cout << player->name << " max hitpoints is now " << player->max_hitpoints << "\n";
                }
                else
                {
                    std::cout << "You dont have enough money \n";
                }
            }
                break;
            case e_shop_add_strength:
            {
                if(player->gold >= 50)
                {
                    player->strength += 2;
                    player->gold-=50;
                    std::cout << player->name << " strength is now " << player->strength << "\n";
                }
                else
                {
                    std::cout << "You dont have enough money \n";
                }
            }
                break;
            case e_shop_add_agility:
            {
                if(player->gold >= 50)
                {
                    player->agility += 2;
                    player->gold-=50;
                    std::cout << player->name << " agility is now " << player->agility << "\n";
                }
                else
                {
                    std::cout << "You dont have enough money \n";
                }
            }
                break;

            case e_shop_add_intelligence:
            {
                if(player->gold >= 50)
                {
                    player->intelligence += 2;
                    player->gold-=50;
                    std::cout << player->name << " intelligence is now " << player->intelligence << "\n";
                }
                else
                {
                    std::cout << "You dont have enough money \n";
                }
            }
                break;
            default:
                return;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0xc(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rcx
movl -0x38(%rbp), %eax
subl 0x8(%rcx), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rcx
movl -0x34(%rbp), %eax
cmpl 0x3c(%rcx), %eax
jle 0xf203
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
cmpl $0x4, -0x20(%rbp)
jge 0xf244
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rdi
addq $0x2c, %rdi
movslq -0x20(%rbp), %rsi
callq 0xafa0
movq %rax, %rcx
movl $0xa, %eax
subl (%rcx), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xf20a
movq -0x10(%rbp), %rdi
callq 0xaf60
movq -0x30(%rbp), %rdi
movq %rax, %rsi
addq $0x3c, %rsi
movl -0x18(%rbp), %edx
leaq -0x1c(%rbp), %rcx
callq 0xf750
movq 0x1fd75(%rip), %rdi     # 0x2efe0
leaq -0x14(%rbp), %rsi
callq 0x40e0
movl -0x14(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x6, %eax
ja 0xf73d
movq -0x40(%rbp), %rax
leaq 0xe351(%rip), %rcx      # 0x1d5e4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %eax
cmpl -0x18(%rbp), %eax
jl 0xf334
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x0, 0x8(%rax)
jle 0xf31f
movl -0x18(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl -0x48(%rbp), %ecx
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movl -0x18(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl -0x44(%rbp), %edx
movl 0x3c(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rsi
addq $0x40, %rsi
movq 0x1fcc7(%rip), %rdi     # 0x2efd0
callq 0x4190
movq %rax, %rdi
leaq 0xe2e8(%rip), %rsi      # 0x1d600
callq 0x41b0
jmp 0xf332
movq 0x1fcaa(%rip), %rdi     # 0x2efd0
leaq 0xe2e4(%rip), %rsi      # 0x1d611
callq 0x41b0
jmp 0xf347
movq 0x1fc95(%rip), %rdi     # 0x2efd0
leaq 0xe2f2(%rip), %rsi      # 0x1d634
callq 0x41b0
jmp 0xf743
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x64, 0x3c(%rax)
jl 0xf3e0
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x0, 0x8(%rax)
jg 0xf3cb
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0xc(%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl -0x4c(%rbp), %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %ecx
subl $0x64, %ecx
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rsi
addq $0x40, %rsi
movq 0x1fc1b(%rip), %rdi     # 0x2efd0
callq 0x4190
movq %rax, %rdi
leaq 0xe28d(%rip), %rsi      # 0x1d651
callq 0x41b0
jmp 0xf3de
movq 0x1fbfe(%rip), %rdi     # 0x2efd0
leaq 0xe287(%rip), %rsi      # 0x1d660
callq 0x41b0
jmp 0xf3f3
movq 0x1fbe9(%rip), %rdi     # 0x2efd0
leaq 0xe246(%rip), %rsi      # 0x1d634
callq 0x41b0
jmp 0xf743
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %eax
cmpl -0x1c(%rbp), %eax
jl 0xf492
movl $0x0, -0x24(%rbp)
cmpl $0x4, -0x24(%rbp)
jge 0xf444
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rdi
addq $0x2c, %rdi
movslq -0x24(%rbp), %rsi
callq 0xafa0
movl $0xa, (%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xf414
movl -0x1c(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl -0x50(%rbp), %edx
movl 0x3c(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x3c(%rax)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rsi
addq $0x40, %rsi
movq 0x1fb54(%rip), %rdi     # 0x2efd0
callq 0x4190
movq %rax, %rdi
leaq 0xe1fa(%rip), %rsi      # 0x1d685
callq 0x41b0
jmp 0xf4a5
movq 0x1fb37(%rip), %rdi     # 0x2efd0
leaq 0xe194(%rip), %rsi      # 0x1d634
callq 0x41b0
jmp 0xf743
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x4b, 0x3c(%rax)
jl 0xf548
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0xc(%rax), %ecx
addl $0xa, %ecx
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x8(%rax), %ecx
addl $0xa, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %ecx
subl $0x4b, %ecx
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rsi
addq $0x40, %rsi
movq 0x1fac6(%rip), %rdi     # 0x2efd0
callq 0x4190
movq %rax, %rdi
leaq 0xe183(%rip), %rsi      # 0x1d69c
callq 0x41b0
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq -0x58(%rbp), %rdi
movl 0xc(%rax), %esi
callq 0x42d0
movq %rax, %rdi
leaq 0xe099(%rip), %rsi      # 0x1d5da
callq 0x41b0
jmp 0xf55b
movq 0x1fa81(%rip), %rdi     # 0x2efd0
leaq 0xe0de(%rip), %rsi      # 0x1d634
callq 0x41b0
jmp 0xf743
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x32, 0x3c(%rax)
jl 0xf5e8
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x10(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %ecx
subl $0x32, %ecx
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rsi
addq $0x40, %rsi
movq 0x1fa26(%rip), %rdi     # 0x2efd0
callq 0x4190
movq %rax, %rdi
leaq 0xe0fa(%rip), %rsi      # 0x1d6b3
callq 0x41b0
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq -0x60(%rbp), %rdi
movl 0x10(%rax), %esi
callq 0x42d0
movq %rax, %rdi
leaq 0xdff9(%rip), %rsi      # 0x1d5da
callq 0x41b0
jmp 0xf5fb
movq 0x1f9e1(%rip), %rdi     # 0x2efd0
leaq 0xe03e(%rip), %rsi      # 0x1d634
callq 0x41b0
jmp 0xf743
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x32, 0x3c(%rax)
jl 0xf688
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x14(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %ecx
subl $0x32, %ecx
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rsi
addq $0x40, %rsi
movq 0x1f986(%rip), %rdi     # 0x2efd0
callq 0x4190
movq %rax, %rdi
leaq 0xe06c(%rip), %rsi      # 0x1d6c5
callq 0x41b0
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq -0x68(%rbp), %rdi
movl 0x14(%rax), %esi
callq 0x42d0
movq %rax, %rdi
leaq 0xdf59(%rip), %rsi      # 0x1d5da
callq 0x41b0
jmp 0xf69b
movq 0x1f941(%rip), %rdi     # 0x2efd0
leaq 0xdf9e(%rip), %rsi      # 0x1d634
callq 0x41b0
jmp 0xf743
movq -0x10(%rbp), %rdi
callq 0xaf60
cmpl $0x32, 0x3c(%rax)
jl 0xf728
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x18(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movl 0x3c(%rax), %ecx
subl $0x32, %ecx
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq %rax, %rsi
addq $0x40, %rsi
movq 0x1f8e6(%rip), %rdi     # 0x2efd0
callq 0x4190
movq %rax, %rdi
leaq 0xdfdd(%rip), %rsi      # 0x1d6d6
callq 0x41b0
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
callq 0xaf60
movq -0x70(%rbp), %rdi
movl 0x18(%rax), %esi
callq 0x42d0
movq %rax, %rdi
leaq 0xdeb9(%rip), %rsi      # 0x1d5da
callq 0x41b0
jmp 0xf73b
movq 0x1f8a1(%rip), %rdi     # 0x2efd0
leaq 0xdefe(%rip), %rsi      # 0x1d634
callq 0x41b0
jmp 0xf743
addq $0x70, %rsp
popq %rbp
retq
jmp 0xf1af
nopl (%rax,%rax)