// File: /workspace/github_cpp_makefile_star2_O2/Serfati[P]Heroes-of-Might-and-Magic-3/GameUnit.cpp
// Function: GameUnit::storeMenu(Hero*)
int GameUnit::storeMenu(Hero *me) {
    Creature c;
    string index;
    while ( 1 > 0 ) {
        int choosenType = 0,count = 0,unitPrice = 0;
        cout << "‫‪1. Buy Zombies." << endl;
        cout << "2. Buy Archers." << endl;
        cout << "‫‪3.‬‬ Buy Vampire." << endl;
        cout << "4. Buy Wizard." << endl;
        cout << "‫‪5‬‬.‬‬ Buy Black Dragon." << endl;
        cin >> index;
        int choice = atoi(index.c_str());
        switch ( choice ) {
            case 1:    /*	Buy Zombies 	*/
                choosenType = 0;
                c = Zombie();
                unitPrice = c.getPrice();
                c.showCreature();
                break;
            case 2:    /*  Buy	Archers	   */
                choosenType = 1;
                c = Archer();
                unitPrice = c.getPrice();
                c.showCreature();
                break;
            case 3:     /*	Buy Vampire	   */
                choosenType = 2;
                c = Vampire();
                unitPrice = c.getPrice();
                c.showCreature();
                break;
            case 4:    /*	Buy Wizard	   */
                choosenType = 3;
                c = Wizard();
                unitPrice = c.getPrice();
                c.showCreature();
                break;
            case 5:    /*	Buy Black Dragon  */
                choosenType = 4;
                c = BlackDragon();
                unitPrice = c.getPrice();
                c.showCreature();
                break;
            default:
                cout << "please choose a valid number" << endl;
        }
        cin >> count;
        if ( unitPrice * count > me->getGold()) {
            throw std::invalid_argument("Not enough gold!");
            return 0;
        }
        me->buyCreature(me->getGold(),choosenType,count,unitPrice);
        return 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rsi, %rbx
leaq -0x40(%rbp), %rdi
callq 0x82b4
leaq -0x68(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
andl $0x0, -0x24(%rbp)
movq 0x8ece(%rip), %rdi      # 0xdfc0
leaq 0x4273(%rip), %rsi      # 0x936c
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq 0x8eb3(%rip), %rdi      # 0xdfc0
leaq 0x426e(%rip), %rsi      # 0x9382
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq 0x8e98(%rip), %rdi      # 0xdfc0
leaq 0x4263(%rip), %rsi      # 0x9392
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq 0x8e7d(%rip), %rdi      # 0xdfc0
leaq 0x4264(%rip), %rsi      # 0x93ae
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq 0x8e62(%rip), %rdi      # 0xdfc0
leaq 0x4258(%rip), %rsi      # 0x93bd
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq 0x8e67(%rip), %rdi      # 0xdfe0
leaq -0x78(%rbp), %rsi
callq 0x32d0
movq -0x78(%rbp), %rdi
callq 0x3340
decl %eax
cmpl $0x4, %eax
ja 0x52c9
leaq 0x3eaf(%rip), %rcx      # 0x904c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x58(%rbp), %rdi
callq 0x8888
leaq -0x58(%rbp), %rdi
movupd 0x8(%rdi), %xmm0
leaq -0x40(%rbp), %r14
movupd %xmm0, 0x8(%r14)
callq 0x893a
movq %r14, %rdi
callq 0x84d6
movl %eax, %r14d
leaq -0x40(%rbp), %rdi
callq 0x833c
jmp 0x52e7
leaq -0x58(%rbp), %rdi
callq 0x8520
leaq -0x58(%rbp), %rdi
movupd 0x8(%rdi), %xmm0
leaq -0x40(%rbp), %r14
movupd %xmm0, 0x8(%r14)
callq 0x85d0
movq %r14, %rdi
callq 0x84d6
movl %eax, %r14d
leaq -0x40(%rbp), %rdi
callq 0x833c
pushq $0x4
jmp 0x52c5
leaq -0x58(%rbp), %rdi
callq 0x87d0
leaq -0x58(%rbp), %rdi
movupd 0x8(%rdi), %xmm0
leaq -0x40(%rbp), %r14
movupd %xmm0, 0x8(%r14)
callq 0x8844
movq %r14, %rdi
callq 0x84d6
movl %eax, %r14d
leaq -0x40(%rbp), %rdi
callq 0x833c
pushq $0x2
jmp 0x52c5
leaq -0x58(%rbp), %rdi
callq 0x8600
leaq -0x58(%rbp), %rdi
movupd 0x8(%rdi), %xmm0
leaq -0x40(%rbp), %r14
movupd %xmm0, 0x8(%r14)
callq 0x86a6
movq %r14, %rdi
callq 0x84d6
movl %eax, %r14d
leaq -0x40(%rbp), %rdi
callq 0x833c
pushq $0x3
jmp 0x52c5
leaq -0x58(%rbp), %rdi
callq 0x86d4
leaq -0x58(%rbp), %rdi
movupd 0x8(%rdi), %xmm0
leaq -0x40(%rbp), %r14
movupd %xmm0, 0x8(%r14)
callq 0x8700
movq %r14, %rdi
callq 0x84d6
movl %eax, %r14d
leaq -0x40(%rbp), %rdi
callq 0x833c
pushq $0x1
popq %r15
jmp 0x52ea
movq 0x8cf0(%rip), %rdi      # 0xdfc0
leaq 0x4019(%rip), %rsi      # 0x92f0
callq 0x3270
movq %rax, %rdi
callq 0x3150
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x8cef(%rip), %rdi      # 0xdfe0
leaq -0x24(%rbp), %rsi
callq 0x31a0
movl -0x24(%rbp), %r12d
movq %rbx, %rdi
callq 0x6c6a
imull %r14d, %r12d
cvtsi2sd %r12d, %xmm1
ucomisd %xmm0, %xmm1
ja 0x5347
movq %rbx, %rdi
callq 0x6c6a
movl -0x24(%rbp), %edx
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %ecx
callq 0x71a6
leaq -0x78(%rbp), %rdi
callq 0x3130
pushq $0x1
popq %rax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x3160
movq %rax, %r14
leaq 0x408b(%rip), %rsi      # 0x93e4
movq %rax, %rdi
callq 0x3440
movq 0x8c70(%rip), %rsi      # 0xdfd8
movq 0x8c59(%rip), %rdx      # 0xdfc8
movq %r14, %rdi
callq 0x33d0
jmp 0x5390
jmp 0x5390
jmp 0x5390
jmp 0x5390
jmp 0x5390
movq %rax, %rbx
movq %r14, %rdi
callq 0x31e0
jmp 0x5393
jmp 0x5390
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x3130
movq %rbx, %rdi
callq 0x33f0