// File: /workspace/github_cpp_makefile_star2_O1/Serfati[P]Heroes-of-Might-and-Magic-3/GameUnit.cpp
// Function: GameUnit::mainMenu(Hero*)
bool GameUnit::mainMenu(Hero *turn) {
    if ( turn->inLife()) {
        bool isTurnRun = 1;
        string index;
        string toRob;
        Creature c;
        Hero *ptr = nullptr;
        cout << "Welcome " << turn->getName() << endl;
        while ( isTurnRun ) {
            cout << "What is your next step in the path to victory?" << endl;
            cout << "‫‪1. Attack‬‬" << endl;
            cout << "2. Get daily gold" << endl;
            cout << "‫‪3.‬‬ Buy creatures‬‬" << endl;
            cout << "4. Show details" << endl;
            cout << "‫‪5‬‬.‬‬ Special skill‬‬‬‬" << endl;
            cout << "6. End of my turn" << endl;
            cout << "7.‬ Exit‬‬‬‬" << endl;
            cin >> index;

            int choice = atoi(index.c_str());
            switch ( choice ) {
                case 1:    /*	Attack‬‬	*/
                    if ( ::roundNumber > - 1 )
                        attackMenu(turn);
                    else cout << "Can'nt attack before round 4, You're still on round " << ::roundNumber << endl;
                    save();
                    if ( ::numberOfPlayers <= 1 ) { // last player
                        cout << realOrder[0]->getName() + " is the winner!" << endl;
                        rmdir();
                        return (EXIT_SUCCESS);
                    }
                    break;

                case 2:    /*	Get daily gold	*/
                    if ( ! turn->isGotDG()) {
                        turn->getDailyGold();
                        turn->setGotDG(true);
                    } else cout << "You already got your daily gold!" << endl;
                    break;

                case 3: /*	Buy creatures	*/
                    try {
                        storeMenu(turn);
                    } catch( std::invalid_argument &e ) { cout << e.what() << endl; }
                    break;

                case 4:    /*	Show details	*/
                    turn->showHero();
                    break;

                case 5:    /*	Special skill‬‬‬‬	*/
                    if ( ! turn->isUsedSA()) {
                        try {
                            if ( turn->getType() == thief ) {
                                std::cout << "Please insert hero name:" << endl;
                                cin >> toRob;
                                ptr = getHeroByName(toRob);
                                if ( NULL == ptr )
                                    throw std::invalid_argument("Hero to rob not found!");
                                turn->specialAbility(*ptr);
                                turn->setUsedSA(true);
                                break;
                            }
                        } catch( std::invalid_argument &e ) { cout << e.what() << endl; }
                        turn->specialAbility(*ptr);
                        turn->setUsedSA(true);
                    } else cout << "You already used your special ability! wait for next round." << endl;
                    break;

                case 6:    /*	End of my turn	*/
                    turn->setUsedSA(false);
                    turn->setGotDG(false);
                    save();
                    isTurnRun = false;
                    nextTurn();
                    break;

                case 7: /* 	‫‪Exit‬‬‬‬  */
                    save();
                    return 1;

                default:
                    cout << "please choose a valid number" << endl;
                    break;
            }
        }
    }
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, -0x30(%rbp)
cmpb $0x1, 0x3a(%rsi)
jne 0x4a4f
movq %rsi, %rbx
leaq -0xb8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x98(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x100(%rbp), %rdi
callq 0x9ee0
movq 0xbca4(%rip), %rdi      # 0xffc0
leaq 0x6e10(%rip), %rsi      # 0xb133
movl $0x8, %edx
callq 0x32d0
leaq -0x60(%rbp), %rdi
movq %rbx, %rsi
callq 0x7c30
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq 0xbc78(%rip), %r15      # 0xffc0
movq %r15, %rdi
callq 0x32d0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4393
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x3290
movb $0x1, %al
movq $0x0, -0x40(%rbp)
movl %ecx, -0x34(%rbp)
movl %eax, %r14d
testb $0x1, %al
je 0x4a02
movl $0x2e, %edx
movq %r15, %rdi
leaq 0x6d82(%rip), %rsi      # 0xb13c
callq 0x32d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movl $0x15, %edx
movq %r15, %rdi
leaq 0x6d76(%rip), %rsi      # 0xb16b
callq 0x32d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movl $0x11, %edx
movq %r15, %rdi
leaq 0x6d51(%rip), %rsi      # 0xb181
callq 0x32d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movl $0x22, %edx
movq %r15, %rdi
leaq 0x6d28(%rip), %rsi      # 0xb193
callq 0x32d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movl $0xf, %edx
movq %r15, %rdi
leaq 0x6d10(%rip), %rsi      # 0xb1b6
callq 0x32d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movl $0x2e, %edx
movq %r15, %rdi
leaq 0x6ce5(%rip), %rsi      # 0xb1c6
callq 0x32d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movl $0x11, %edx
movq %r15, %rdi
leaq 0x6cd9(%rip), %rsi      # 0xb1f5
callq 0x32d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movl $0x16, %edx
movq %r15, %rdi
leaq 0x6cb0(%rip), %rsi      # 0xb207
callq 0x32d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movq 0xba56(%rip), %rdi      # 0xffe0
leaq -0xc8(%rbp), %rsi
callq 0x3300
movq -0xc8(%rbp), %rdi
callq 0x3360
decl %eax
cmpl $0x6, %eax
ja 0x46f2
leaq 0x6a84(%rip), %rcx      # 0xb038
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, 0xbcd4(%rip)      # 0x10298
js 0x479d
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x59ae
jmp 0x47e9
movl $0x3b, %edx
cmpb $0x0, 0x39(%rbx)
leaq 0x6cc9(%rip), %rsi      # 0xb2b4
jne 0x4712
movq %rbx, %rdi
callq 0x7c5e
cmpl $0x1, %eax
jne 0x49e3
movl $0x18, %edx
movq %r15, %rdi
leaq 0x6c73(%rip), %rsi      # 0xb284
callq 0x32d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movq 0xb99c(%rip), %rdi      # 0xffe0
leaq -0xa8(%rbp), %rsi
callq 0x3300
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x693a
movq -0x30(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x6100
movq %rax, %r12
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x46a7
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3290
testq %r12, %r12
je 0x48f5
movq (%rbx), %rax
movq %r12, -0x40(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq *(%rax)
movb $0x1, 0x39(%rbx)
movb $0x1, %r13b
movq %r12, -0x40(%rbp)
jmp 0x49f6
movb $0x1, %r13b
movq %rbx, %rsi
callq 0x5cd8
jmp 0x49f6
movb $0x1, %r13b
movq %rbx, %rdi
callq 0x8532
movl %r14d, %eax
jmp 0x49f9
movl $0x1c, %edx
leaq 0x6bf2(%rip), %rsi      # 0xb2f0
jmp 0x4712
movl $0x20, %edx
cmpb $0x0, 0x38(%rbx)
leaq 0x6b53(%rip), %rsi      # 0xb263
je 0x4784
movq %r15, %rdi
callq 0x32d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movb $0x1, %r13b
movq %rax, %rdi
callq 0x31b0
movl %r14d, %eax
jmp 0x49f9
movw $0x0, 0x38(%rbx)
movq -0x30(%rbp), %rdi
callq 0x54e6
movq -0x30(%rbp), %rdi
callq 0x61ae
movb $0x1, %r13b
xorl %eax, %eax
jmp 0x49f9
movq -0x30(%rbp), %rdi
callq 0x54e6
movb $0x1, %al
movl %eax, -0x34(%rbp)
xorl %r13d, %r13d
jmp 0x49f6
movq %rbx, %rdi
movsd 0x68a1(%rip), %xmm0     # 0xb030
callq 0x96f0
movb $0x1, 0x38(%rbx)
jmp 0x49f3
movl $0x34, %edx
movq %r15, %rdi
leaq 0x6a72(%rip), %rsi      # 0xb21e
callq 0x32d0
movl 0xbae1(%rip), %esi      # 0x10298
movq %r15, %rdi
callq 0x3410
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movq -0x30(%rbp), %rdi
callq 0x54e6
movb $0x1, %r13b
cmpl $0x1, 0xbaa0(%rip)      # 0x1029c
jg 0x49f6
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rsi
leaq -0xe8(%rbp), %r12
movq %r12, %rdi
callq 0x7c30
movq %r12, %rdi
leaq 0x6a2e(%rip), %rsi      # 0xb253
callq 0x3470
leaq -0x50(%rbp), %r13
movq %r13, -0x60(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x484e
movq %rdx, -0x60(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x50(%rbp)
jmp 0x4856
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, -0x58(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq %r15, %rdi
callq 0x32d0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movq -0x60(%rbp), %rdi
cmpq %r13, %rdi
je 0x48bc
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x3290
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x48de
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x3290
callq 0x534e
xorl %r13d, %r13d
movl %r14d, %eax
movl $0x0, -0x34(%rbp)
jmp 0x49f9
movl $0x10, %edi
callq 0x3140
movq %rax, %r12
movq %rax, %rdi
leaq 0x6991(%rip), %rsi      # 0xb29d
callq 0x3460
movq $0x0, -0x40(%rbp)
movq %r12, %rdi
movq 0xb6b5(%rip), %rsi      # 0xffd8
movq 0xb69e(%rip), %rdx      # 0xffc8
callq 0x3400
jmp 0x4a65
movq %rdx, -0x68(%rbp)
movq %rax, %r13
movq %r12, %rdi
callq 0x31d0
movq $0x0, -0x40(%rbp)
jmp 0x49b0
movq %rdx, -0x68(%rbp)
movq %rax, %r13
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x49b0
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3290
jmp 0x49b0
cmpl $0x1, %edx
jne 0x4aee
movq %rax, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq %r15, %rdi
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
callq 0x33c0
movl %r14d, %eax
jmp 0x49f9
movq %rdx, -0x68(%rbp)
movq %rax, %r13
cmpl $0x1, -0x68(%rbp)
jne 0x4a65
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq %r15, %rdi
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
callq 0x33c0
movq (%rbx), %rax
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
callq *(%rax)
movb $0x1, 0x39(%rbx)
movb $0x1, %r13b
movl %r14d, %eax
testb %r13b, %r13b
jne 0x43a0
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x4a24
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x3290
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x4a46
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3290
testb $0x1, %r14b
movl -0x34(%rbp), %eax
jne 0x4a51
xorl %eax, %eax
andb $0x1, %al
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rbx
jmp 0x4af1
jmp 0x4aee
movq %rax, %rbx
callq 0x33c0
jmp 0x4af1
jmp 0x4aee
movq %rax, %rbx
callq 0x33c0
jmp 0x4af1
movq %rax, %rdi
callq 0x6841
movq %rax, %rbx
jmp 0x4ab2
jmp 0x4aee
jmp 0x4aee
jmp 0x4aee
jmp 0x4aee
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r13, %rdi
je 0x4ab2
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x3290
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x4af1
movq -0xd8(%rbp), %rsi
jmp 0x4ae2
movq %rax, %rbx
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4af1
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x3290
jmp 0x4af1
jmp 0x4aee
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x4b13
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x3290
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x4b35
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3290
movq %rbx, %rdi
callq 0x3420
nop