// File: /workspace/github_cpp_makefile_star2_O3/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
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xc(%rsp), %r13
leaq 0x4ed8(%rip), %r12      # 0xb6b0
movq 0xa7f1(%rip), %rbp      # 0x10fd0
movq (%rbx), %rax
movl 0xc(%rax), %r15d
leaq 0x3c(%rax), %rsi
movl 0x3c(%rax), %ecx
movdqu 0x2c(%rax), %xmm0
movdqa 0x4876(%rip), %xmm1     # 0xb070
psubd %xmm0, %xmm1
pshufd $0xee, %xmm1, %xmm0     # xmm0 = xmm1[2,3,2,3]
paddd %xmm1, %xmm0
pshufd $0x55, %xmm0, %xmm1     # xmm1 = xmm0[1,1,1,1]
paddd %xmm0, %xmm1
subl 0x8(%rax), %r15d
cmpl %ecx, %r15d
cmovgel %ecx, %r15d
movdqa %xmm1, 0x10(%rsp)
movd %xmm1, 0x8(%rsp)
movq %r14, %rdi
movl %r15d, %edx
leaq 0x8(%rsp), %rcx
callq 0x6af8
movq 0xa7a2(%rip), %rdi      # 0x10fe0
movq %r13, %rsi
callq 0x30a0
movl 0xc(%rsp), %eax
decl %eax
cmpl $0x6, %eax
ja 0x6ae9
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq (%rbx), %rax
movl 0x3c(%rax), %ecx
subl %r15d, %ecx
jl 0x6a82
movl 0x8(%rax), %edx
testl %edx, %edx
jle 0x6a9b
addl %r15d, %edx
movl %edx, 0x8(%rax)
movl %ecx, 0x3c(%rax)
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
movq %rbp, %rdi
callq 0x3140
movl $0x10, %edx
movq %rax, %rdi
leaq 0x4e2c(%rip), %rsi      # 0xb6cc
callq 0x3140
jmp 0x67df
movq (%rbx), %rax
movl 0x3c(%rax), %ecx
cmpl $0x32, %ecx
jl 0x6a82
addl $0x2, 0x10(%rax)
addl $-0x32, %ecx
movl %ecx, 0x3c(%rax)
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
movq %rbp, %rdi
callq 0x3140
movq %rax, %r15
movl $0x11, %edx
movq %rax, %rdi
leaq 0x4e9a(%rip), %rsi      # 0xb77f
callq 0x3140
movq (%rbx), %rax
movl 0x10(%rax), %esi
jmp 0x6a61
movdqa 0x10(%rsp), %xmm0
movd %xmm0, %ecx
movq (%rbx), %rax
cmpl %ecx, 0x3c(%rax)
jl 0x6a82
movdqa 0x475d(%rip), %xmm0     # 0xb070
movdqu %xmm0, 0x2c(%rax)
subl %ecx, 0x3c(%rax)
movl $0x0, 0x8(%rsp)
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
movq %rbp, %rdi
callq 0x3140
movl $0x16, %edx
movq %rax, %rdi
leaq 0x4e0f(%rip), %rsi      # 0xb751
callq 0x3140
jmp 0x67df
movq (%rbx), %rax
movl 0x3c(%rax), %ecx
cmpl $0x4b, %ecx
jl 0x6a82
movq 0x8(%rax), %xmm0
paddd 0x4d38(%rip), %xmm0     # 0xb6a0
movq %xmm0, 0x8(%rax)
addl $-0x4b, %ecx
movl %ecx, 0x3c(%rax)
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
movq %rbp, %rdi
callq 0x3140
movq %rax, %r15
movl $0x16, %edx
movq %rax, %rdi
leaq 0x4dd3(%rip), %rsi      # 0xb768
callq 0x3140
movq (%rbx), %rax
movl 0xc(%rax), %esi
jmp 0x6a61
movq (%rbx), %rax
movl 0x3c(%rax), %ecx
cmpl $0x64, %ecx
jl 0x6a82
cmpl $0x0, 0x8(%rax)
jle 0x6ab4
movl $0x24, %edx
movq %rbp, %rdi
leaq 0x4d5f(%rip), %rsi      # 0xb72c
callq 0x3140
jmp 0x67df
movq (%rbx), %rax
movl 0x3c(%rax), %ecx
cmpl $0x32, %ecx
jl 0x6a82
addl $0x2, 0x14(%rax)
addl $-0x32, %ecx
movl %ecx, 0x3c(%rax)
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
movq %rbp, %rdi
callq 0x3140
movq %rax, %r15
movl $0x10, %edx
movq %rax, %rdi
leaq 0x4d7f(%rip), %rsi      # 0xb791
callq 0x3140
movq (%rbx), %rax
movl 0x14(%rax), %esi
jmp 0x6a61
movq (%rbx), %rax
movl 0x3c(%rax), %ecx
cmpl $0x32, %ecx
jl 0x6a82
addl $0x2, 0x18(%rax)
addl $-0x32, %ecx
movl %ecx, 0x3c(%rax)
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
movq %rbp, %rdi
callq 0x3140
movq %rax, %r15
movl $0x15, %edx
movq %rax, %rdi
leaq 0x4d4c(%rip), %rsi      # 0xb7a2
callq 0x3140
movq (%rbx), %rax
movl 0x18(%rax), %esi
movq %r15, %rdi
callq 0x31b0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x4c16(%rip), %rsi      # 0xb68e
callq 0x3140
jmp 0x67df
movl $0x1c, %edx
movq %rbp, %rdi
leaq 0x4c6f(%rip), %rsi      # 0xb700
callq 0x3140
jmp 0x67df
movl $0x22, %edx
movq %rbp, %rdi
leaq 0x4c33(%rip), %rsi      # 0xb6dd
callq 0x3140
jmp 0x67df
movl 0xc(%rax), %edx
movl %edx, 0x8(%rax)
addl $-0x64, %ecx
movl %ecx, 0x3c(%rax)
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
movq %rbp, %rdi
callq 0x3140
movl $0xe, %edx
movq %rax, %rdi
leaq 0x4c3e(%rip), %rsi      # 0xb71d
callq 0x3140
jmp 0x67df
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq