// File: /workspace/github_cpp_makefile_star2_O3/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 0x4a01
movq %rsi, %r14
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 0x9ea8
movq 0xbcb6(%rip), %rdi      # 0xffc0
leaq 0x6e22(%rip), %rsi      # 0xb133
movl $0x8, %edx
callq 0x32d0
leaq -0x60(%rbp), %rdi
movq %r14, %rsi
callq 0x7c0c
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq 0xbc8a(%rip), %r15      # 0xffc0
movq %r15, %rdi
callq 0x32d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4381
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x3290
movq $0x0, -0x38(%rbp)
movq 0xbc50(%rip), %rbx      # 0xffe0
leaq 0x6ca1(%rip), %r12      # 0xb038
movl $0x2e, %edx
movq %r15, %rdi
leaq 0x6d96(%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 0x6d8a(%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 0x6d65(%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 0x6d3c(%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 0x6d24(%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 0x6cf9(%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 0x6ced(%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 0x6cc4(%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 %rbx, %rdi
leaq -0xc8(%rbp), %rsi
callq 0x3300
movq -0xc8(%rbp), %rdi
callq 0x3360
decl %eax
cmpl $0x6, %eax
ja 0x46f2
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
cmpl $0x0, 0xbcf3(%rip)      # 0x10298
js 0x4732
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x5986
jmp 0x477e
movl $0x3b, %edx
cmpb $0x0, 0x39(%r14)
leaq 0x6ce7(%rip), %rsi      # 0xb2b4
jne 0x46fe
movq %r14, %rdi
callq 0x7c3a
cmpl $0x1, %eax
jne 0x488a
movl $0x18, %edx
movq %r15, %rdi
leaq 0x6c91(%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 %rbx, %rdi
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 0x6930
movq -0x30(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x60d8
movq %rax, %r13
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x4685
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3290
testq %r13, %r13
je 0x4799
movq (%r14), %rax
movq %r13, -0x38(%rbp)
movq %r14, %rdi
movq %r13, %rsi
callq *(%rax)
movb $0x1, 0x39(%r14)
movq %r13, -0x38(%rbp)
jmp 0x4397
movq %r14, %rsi
callq 0x5cb0
jmp 0x4397
movq %r14, %rdi
callq 0x8514
jmp 0x4397
movl $0x20, %edx
cmpb $0x0, 0x38(%r14)
leaq 0x6b8d(%rip), %rsi      # 0xb263
jne 0x46fe
movq %r14, %rdi
movsd 0x694d(%rip), %xmm0     # 0xb030
callq 0x96b2
movb $0x1, 0x38(%r14)
jmp 0x4397
movl $0x1c, %edx
leaq 0x6bf2(%rip), %rsi      # 0xb2f0
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
movq %rax, %rdi
callq 0x31b0
jmp 0x4397
movl $0x34, %edx
movq %r15, %rdi
leaq 0x6add(%rip), %rsi      # 0xb21e
callq 0x32d0
movl 0xbb4c(%rip), %esi      # 0x10298
movq %r15, %rdi
callq 0x3410
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movq -0x30(%rbp), %rdi
callq 0x54be
cmpl $0x1, 0xbb0e(%rip)      # 0x1029c
jg 0x4397
jmp 0x48d6
movl $0x10, %edi
callq 0x3140
movq %rax, -0x68(%rbp)
movq %rax, %rdi
leaq 0x6aec(%rip), %rsi      # 0xb29d
callq 0x3460
movq $0x0, -0x38(%rbp)
movq -0x68(%rbp), %rdi
movq 0xb80f(%rip), %rsi      # 0xffd8
movq 0xb7f8(%rip), %rdx      # 0xffc8
callq 0x3400
jmp 0x4a1a
movq %rdx, -0x40(%rbp)
movq %rax, %r13
movq -0x68(%rbp), %rdi
callq 0x31d0
movq $0x0, -0x38(%rbp)
jmp 0x4857
movq %rdx, -0x40(%rbp)
movq %rax, %r13
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x4857
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3290
jmp 0x4857
cmpl $0x1, %edx
jne 0x4aa7
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
jmp 0x4397
movq %rdx, -0x40(%rbp)
movq %rax, %r13
cmpl $0x1, -0x40(%rbp)
jne 0x4a1a
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 (%r14), %rax
movq %r14, %rdi
movq -0x38(%rbp), %rsi
callq *(%rax)
movb $0x1, 0x39(%r14)
jmp 0x4397
movb $0x1, %r14b
movq -0x30(%rbp), %rdi
callq 0x54be
movb $0x1, %bl
jmp 0x49b8
movw $0x0, 0x38(%r14)
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x54be
movq %rbx, %rdi
callq 0x618a
xorl %r14d, %r14d
jmp 0x49b8
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rsi
leaq -0xe8(%rbp), %rdi
callq 0x7c0c
leaq 0x6960(%rip), %rsi      # 0xb253
leaq -0xe8(%rbp), %rdi
callq 0x3470
leaq -0x50(%rbp), %r14
movq %r14, -0x60(%rbp)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x4923
movq %rsi, -0x60(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x50(%rbp)
jmp 0x492d
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq %r14, %rsi
movq 0x8(%rax), %rdx
movq %rdx, -0x58(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0xb675(%rip), %rdi      # 0xffc0
callq 0x32d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movq -0x60(%rbp), %rdi
cmpq %r14, %rdi
je 0x498f
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x3290
leaq -0xd8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x49ae
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x3290
callq 0x5326
movb $0x1, %r14b
xorl %ebx, %ebx
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x49da
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x3290
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x49fc
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3290
testb %r14b, %r14b
jne 0x4a03
xorl %ebx, %ebx
andb $0x1, %bl
movl %ebx, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rbx
jmp 0x4aaa
jmp 0x4aa7
movq %rax, %rbx
callq 0x33c0
jmp 0x4aaa
jmp 0x4aa7
movq %rax, %rbx
callq 0x33c0
jmp 0x4aaa
movq %rax, %rdi
callq 0x6837
movq %rax, %rbx
jmp 0x4a6e
jmp 0x4aa7
jmp 0x4aa7
jmp 0x4aa7
jmp 0x4aa7
jmp 0x4aa7
jmp 0x4aa7
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r14, %rdi
je 0x4a6e
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x3290
leaq -0xd8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4aaa
movq -0xd8(%rbp), %rsi
jmp 0x4a9b
movq %rax, %rbx
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4aaa
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x3290
jmp 0x4aaa
jmp 0x4aa7
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x4acc
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x3290
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x4aee
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3290
movq %rbx, %rdi
callq 0x3420