// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x42cc(%rip), %r12      # 0xa6b0
movq 0xbbe5(%rip), %rbp      # 0x11fd0
movq (%rbx), %rdx
movl 0x8(%rdx), %eax
movl 0xc(%rdx), %r15d
leaq 0x3c(%rdx), %rsi
movl 0x3c(%rdx), %ecx
xorl %edi, %edi
xorl %r13d, %r13d
cmpq $0x4, %rdi
je 0x6415
subl 0x2c(%rdx,%rdi,4), %r13d
addl $0xa, %r13d
incq %rdi
jmp 0x6401
subl %eax, %r15d
cmpl %ecx, %r15d
cmovgel %ecx, %r15d
movl %r13d, (%rsp)
movq %r14, %rdi
movl %r15d, %edx
movq %rsp, %rcx
callq 0x6692
movq 0xbba8(%rip), %rdi      # 0x11fe0
leaq 0x4(%rsp), %rsi
callq 0x30b0
movl 0x4(%rsp), %eax
decl %eax
cmpl $0x6, %eax
ja 0x6682
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq (%rbx), %rsi
movl 0x3c(%rsi), %eax
subl %r15d, %eax
jl 0x6606
movl 0x8(%rsi), %ecx
testl %ecx, %ecx
jle 0x6642
addl %r15d, %ecx
movl %ecx, 0x8(%rsi)
movl %eax, 0x3c(%rsi)
addq $0x40, %rsi
movq %rbp, %rdi
callq 0x3120
movq %rax, %rdi
leaq 0x4239(%rip), %rsi      # 0xa6cc
callq 0x3130
jmp 0x63eb
movq (%rbx), %rsi
movl 0x3c(%rsi), %eax
cmpl $0x32, %eax
jl 0x6606
addl $0x2, 0x10(%rsi)
addl $-0x32, %eax
movl %eax, 0x3c(%rsi)
addq $0x40, %rsi
movq %rbp, %rdi
callq 0x3120
movq %rax, %rdi
leaq 0x42b3(%rip), %rsi      # 0xa77f
callq 0x3130
movq (%rbx), %rcx
movl 0x10(%rcx), %esi
jmp 0x65ea
movq (%rbx), %rsi
cmpl %r13d, 0x3c(%rsi)
jl 0x6606
xorl %eax, %eax
cmpq $0x4, %rax
je 0x661a
movl $0xa, 0x2c(%rsi,%rax,4)
incq %rax
jmp 0x64eb
movq (%rbx), %rsi
movl 0x3c(%rsi), %eax
cmpl $0x4b, %eax
jl 0x6606
movq 0x8(%rsi), %xmm0
paddd 0x4182(%rip), %xmm0     # 0xa6a0
movq %xmm0, 0x8(%rsi)
addl $-0x4b, %eax
movl %eax, 0x3c(%rsi)
addq $0x40, %rsi
movq %rbp, %rdi
callq 0x3120
movq %rax, %rdi
leaq 0x4229(%rip), %rsi      # 0xa768
callq 0x3130
movq (%rbx), %rcx
movl 0xc(%rcx), %esi
jmp 0x65ea
movq (%rbx), %rsi
movl 0x3c(%rsi), %eax
cmpl $0x64, %eax
jl 0x6606
cmpl $0x0, 0x8(%rsi)
jle 0x6656
movq %rbp, %rdi
leaq 0x41ba(%rip), %rsi      # 0xa72c
callq 0x3130
jmp 0x63eb
movq (%rbx), %rsi
movl 0x3c(%rsi), %eax
cmpl $0x32, %eax
jl 0x6606
addl $0x2, 0x14(%rsi)
addl $-0x32, %eax
movl %eax, 0x3c(%rsi)
addq $0x40, %rsi
movq %rbp, %rdi
callq 0x3120
movq %rax, %rdi
leaq 0x41ea(%rip), %rsi      # 0xa791
callq 0x3130
movq (%rbx), %rcx
movl 0x14(%rcx), %esi
jmp 0x65ea
movq (%rbx), %rsi
movl 0x3c(%rsi), %eax
cmpl $0x32, %eax
jl 0x6606
addl $0x2, 0x18(%rsi)
addl $-0x32, %eax
movl %eax, 0x3c(%rsi)
addq $0x40, %rsi
movq %rbp, %rdi
callq 0x3120
movq %rax, %rdi
leaq 0x41c3(%rip), %rsi      # 0xa7a2
callq 0x3130
movq (%rbx), %rcx
movl 0x18(%rcx), %esi
movq %rax, %rdi
callq 0x31f0
movq %rax, %rdi
leaq 0x4092(%rip), %rsi      # 0xa68e
callq 0x3130
jmp 0x63eb
movq %rbp, %rdi
leaq 0x40f0(%rip), %rsi      # 0xa700
callq 0x3130
jmp 0x63eb
subl %r13d, 0x3c(%rsi)
andl $0x0, (%rsp)
addq $0x40, %rsi
movq %rbp, %rdi
callq 0x3120
movq %rax, %rdi
leaq 0x4119(%rip), %rsi      # 0xa751
callq 0x3130
jmp 0x63eb
movq %rbp, %rdi
leaq 0x4091(%rip), %rsi      # 0xa6dd
callq 0x3130
jmp 0x63eb
movl 0xc(%rsi), %ecx
movl %ecx, 0x8(%rsi)
addl $-0x64, %eax
movl %eax, 0x3c(%rsi)
addq $0x40, %rsi
movq %rbp, %rdi
callq 0x3120
movq %rax, %rdi
leaq 0x40a5(%rip), %rsi      # 0xa71d
callq 0x3130
jmp 0x63eb
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop