// File: 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
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x11b00
leaq -0x48(%rbp), %rdi
callq 0x4420
jmp 0x7757
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movq 0x1484d(%rip), %rdi     # 0x1bfc0
leaq 0xbbf2(%rip), %rsi      # 0x1336c
callq 0x4310
movq %rax, -0xe8(%rbp)
jmp 0x7788
movq -0xe8(%rbp), %rdi
movq 0x1481a(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x779d
movq 0x1481c(%rip), %rdi     # 0x1bfc0
leaq 0xbbd7(%rip), %rsi      # 0x13382
callq 0x4310
movq %rax, -0xf0(%rbp)
jmp 0x77b9
movq -0xf0(%rbp), %rdi
movq 0x147e9(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x77ce
movq 0x147eb(%rip), %rdi     # 0x1bfc0
leaq 0xbbb6(%rip), %rsi      # 0x13392
callq 0x4310
movq %rax, -0xf8(%rbp)
jmp 0x77ea
movq -0xf8(%rbp), %rdi
movq 0x147b8(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x77ff
movq 0x147ba(%rip), %rdi     # 0x1bfc0
leaq 0xbba1(%rip), %rsi      # 0x133ae
callq 0x4310
movq %rax, -0x100(%rbp)
jmp 0x781b
movq -0x100(%rbp), %rdi
movq 0x14787(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x7830
movq 0x14789(%rip), %rdi     # 0x1bfc0
leaq 0xbb7f(%rip), %rsi      # 0x133bd
callq 0x4310
movq %rax, -0x108(%rbp)
jmp 0x784c
movq -0x108(%rbp), %rdi
movq 0x14756(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x7861
movq 0x14778(%rip), %rdi     # 0x1bfe0
leaq -0x48(%rbp), %rsi
callq 0x43e0
jmp 0x7873
leaq -0x48(%rbp), %rdi
callq 0x4140
movq %rax, %rdi
callq 0x4480
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x110(%rbp)
subl $0x4, %eax
ja 0x7ad9
movq -0x110(%rbp), %rax
leaq 0xb7a0(%rip), %rcx      # 0x1304c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x7c13
movl $0x0, -0x4c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x12750
jmp 0x78d8
leaq -0x28(%rbp), %rdi
movq %rdi, -0x120(%rbp)
leaq -0x80(%rbp), %rsi
movq %rsi, -0x128(%rbp)
callq 0x8a30
movq -0x128(%rbp), %rdi
callq 0x12870
movq -0x120(%rbp), %rdi
callq 0x12020
movl %eax, -0x114(%rbp)
jmp 0x7913
movl -0x114(%rbp), %eax
movl %eax, -0x54(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x11c30
jmp 0x7927
jmp 0x7b0c
movl $0x1, -0x4c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x12410
jmp 0x7941
leaq -0x28(%rbp), %rdi
movq %rdi, -0x138(%rbp)
leaq -0x98(%rbp), %rsi
movq %rsi, -0x140(%rbp)
callq 0x8a30
movq -0x140(%rbp), %rdi
callq 0x12460
movq -0x138(%rbp), %rdi
callq 0x12020
movl %eax, -0x12c(%rbp)
jmp 0x797f
movl -0x12c(%rbp), %eax
movl %eax, -0x54(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x11c30
jmp 0x7993
jmp 0x7b0c
movl $0x2, -0x4c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x125e0
jmp 0x79ad
leaq -0x28(%rbp), %rdi
movq %rdi, -0x150(%rbp)
leaq -0xb0(%rbp), %rsi
movq %rsi, -0x158(%rbp)
callq 0x8a30
movq -0x158(%rbp), %rdi
callq 0x126a0
movq -0x150(%rbp), %rdi
callq 0x12020
movl %eax, -0x144(%rbp)
jmp 0x79eb
movl -0x144(%rbp), %eax
movl %eax, -0x54(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x11c30
jmp 0x79ff
jmp 0x7b0c
movl $0x3, -0x4c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x12270
jmp 0x7a19
leaq -0x28(%rbp), %rdi
movq %rdi, -0x168(%rbp)
leaq -0xc8(%rbp), %rsi
movq %rsi, -0x170(%rbp)
callq 0x8a30
movq -0x170(%rbp), %rdi
callq 0x12380
movq -0x168(%rbp), %rdi
callq 0x12020
movl %eax, -0x15c(%rbp)
jmp 0x7a57
movl -0x15c(%rbp), %eax
movl %eax, -0x54(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x11c30
jmp 0x7a6b
jmp 0x7b0c
movl $0x4, -0x4c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x120e0
jmp 0x7a85
leaq -0x28(%rbp), %rdi
movq %rdi, -0x180(%rbp)
leaq -0xe0(%rbp), %rsi
movq %rsi, -0x188(%rbp)
callq 0x8a30
movq -0x188(%rbp), %rdi
callq 0x121e0
movq -0x180(%rbp), %rdi
callq 0x12020
movl %eax, -0x174(%rbp)
jmp 0x7ac3
movl -0x174(%rbp), %eax
movl %eax, -0x54(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x11c30
jmp 0x7ad7
jmp 0x7b0c
movq 0x144e0(%rip), %rdi     # 0x1bfc0
leaq 0xb809(%rip), %rsi      # 0x132f0
callq 0x4310
movq %rax, -0x190(%rbp)
jmp 0x7af5
movq -0x190(%rbp), %rdi
movq 0x144ad(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x7b0a
jmp 0x7b0c
movq 0x144cd(%rip), %rdi     # 0x1bfe0
leaq -0x50(%rbp), %rsi
callq 0x41f0
jmp 0x7b1e
movl -0x54(%rbp), %eax
movl -0x50(%rbp), %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x1a0(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf110
movsd %xmm0, -0x198(%rbp)
jmp 0x7b46
movsd -0x1a0(%rbp), %xmm0
movsd -0x198(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x7bba
movl $0x10, %edi
callq 0x41a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1a8(%rbp)
leaq 0xb86a(%rip), %rsi      # 0x133e4
callq 0x4590
jmp 0x7b81
movq -0x1a8(%rbp), %rdi
movq 0x14449(%rip), %rsi     # 0x1bfd8
movq 0x14432(%rip), %rdx     # 0x1bfc8
callq 0x44f0
jmp 0x7c2e
movq -0x1a8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
callq 0x4250
jmp 0x7c13
movq -0x10(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0xf110
movsd %xmm0, -0x1b0(%rbp)
jmp 0x7bd4
movsd -0x1b0(%rbp), %xmm0
movq -0x1b8(%rbp), %rdi
movl -0x4c(%rbp), %esi
movl -0x50(%rbp), %edx
movl -0x54(%rbp), %ecx
callq 0xfaa0
jmp 0x7bf3
leaq -0x48(%rbp), %rdi
callq 0x4200
leaq -0x28(%rbp), %rdi
callq 0x8a20
movl $0x1, %eax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x4200
leaq -0x28(%rbp), %rdi
callq 0x8a20
movq -0x60(%rbp), %rdi
callq 0x4520
nop