// File: /workspace/github_cpp_makefile_star2_O2/whitefusion[P]Jaipur_cardgame-/main.cpp
// Function: main
int main(){
    // initialize deck and market
    Deck   d1;
    d1.shuffle();
    Market m1(d1);

    Human p1(d1,"name1");
    Human p2(d1,"name2");

    Game g1(d1, m1, p1, p2);

    // initialize player game mode
    int mode;
    char tmp[256];
    char *token;

    cout << "Game starts! Choose Modes---> 1: AI vs. AI; 2: Human vs. Human; 3: Human vs. AI: " ; 
    cin.getline(tmp,256);

    token = strtok(tmp, " \t\n\r\f");
    while (!token || atoi(token) > 3 || atoi(token) < 1){
        cout << "Invalid choice! Try again." << endl;
        cout << "Choose Modes---> 1: AI vs. AI; 2: Human vs. Human; 3: Human vs. AI: ";
        cin.getline(tmp, 256);
        token = strtok(tmp, " \t\n\r\f");
    }
    mode = atoi(token);

    switch(mode){
        case 1:
        {
            cout << " AI vs. AI " << endl;     
            break;
        }
        case 2:
        {
            cout << "Enter Name for Player 1: ";
            cin.getline(tmp, 256);
            string n1(tmp);
            cout << "Enter Name for Player 2: ";
            cin.getline(tmp, 256);
            string n2(tmp);

            p1.setName(n1);
            p2.setName(n2);
            break;
        }
        case 3:
        {
            cout << "Enter Name for Human Player: ";
            cin.getline(tmp,256);
            string n1(tmp);
            p1.setName(n1); 
            break;
        }
    }

    while (p1.getPoints(3) != 2 && p2.getPoints(3) != 2){
        g1.play_a_round();
        int winner = g1.roundWinner();
        cout << "The winner of Round " << g1.getRound() - 1 << " is: " << g1.getPlayer(winner).getName() << endl;
        cout << "Starting a NEW ROUND..." << endl;
        std::this_thread::sleep_for (std::chrono::seconds(3));
        g1.newRound(winner);
    }

    int finalwinner = g1.finalWinner();

    cout << endl;
    cout << "The FINAL winner of this game is " << g1.getPlayer(finalwinner).getName() << endl;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x378, %rsp            # imm = 0x378
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x6ee4
movq %rbx, %rdi
callq 0x772e
leaq 0x100(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x7dea
leaq 0x9c39(%rip), %rsi      # 0xd004
leaq 0xe0(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0x3950
leaq 0x120(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
callq 0xa27c
leaq 0xe0(%rsp), %rdi
callq 0x20e0
leaq 0x9bfc(%rip), %rsi      # 0xd00a
leaq 0xc0(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0x3950
leaq 0x180(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0xa27c
leaq 0xc0(%rsp), %rdi
callq 0x20e0
leaq 0x1e0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x100(%rsp), %rdx
leaq 0x120(%rsp), %rcx
leaq 0x180(%rsp), %r8
callq 0xa654
movq 0x11b55(%rip), %rdi     # 0x14fd0
leaq 0x9b8e(%rip), %rsi      # 0xd010
callq 0x21b0
movq 0x11b52(%rip), %rdi     # 0x14fe0
leaq 0x270(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x2080
leaq 0x9bbb(%rip), %rbx      # 0xd062
leaq 0x270(%rsp), %r14
movq 0x11b1a(%rip), %r15     # 0x14fd0
leaq 0x9bab(%rip), %r12      # 0xd068
leaq 0x9b59(%rip), %r13      # 0xd01d
movq 0x11b15(%rip), %rbp     # 0x14fe0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2250
testq %rax, %rax
je 0x34eb
movq %rax, %rdi
callq 0x2240
leal -0x4(%rax), %ecx
cmpl $-0x4, %ecx
ja 0x351b
movq %r15, %rdi
movq %r12, %rsi
callq 0x21b0
movq %rax, %rdi
callq 0x20f0
movq %r15, %rdi
movq %r13, %rsi
callq 0x21b0
movl $0x100, %edx            # imm = 0x100
movq %rbp, %rdi
movq %r14, %rsi
callq 0x2080
jmp 0x34cb
cmpl $0x3, %eax
je 0x3622
cmpl $0x2, %eax
jne 0x369c
movq 0x11a9c(%rip), %rdi     # 0x14fd0
leaq 0x9b54(%rip), %rsi      # 0xd08f
callq 0x21b0
movq 0x11a99(%rip), %rdi     # 0x14fe0
leaq 0x270(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x2080
leaq 0x8(%rsp), %rdi
leaq 0x270(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x3950
movq 0x11a59(%rip), %rdi     # 0x14fd0
leaq 0x9b2b(%rip), %rsi      # 0xd0a9
callq 0x21b0
movq 0x11a56(%rip), %rdi     # 0x14fe0
leaq 0x270(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x2080
leaq 0x40(%rsp), %rdi
leaq 0x270(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0x3950
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2200
leaq 0x120(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x8b04
leaq 0xa0(%rsp), %rdi
callq 0x20e0
leaq 0x80(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x2200
leaq 0x180(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x8b04
leaq 0x80(%rsp), %rdi
callq 0x20e0
leaq 0x40(%rsp), %rdi
jmp 0x368b
movq 0x119a7(%rip), %rdi     # 0x14fd0
leaq 0x9a93(%rip), %rsi      # 0xd0c3
callq 0x21b0
movq 0x119a4(%rip), %rdi     # 0x14fe0
leaq 0x270(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x2080
leaq 0x8(%rsp), %rdi
leaq 0x270(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x3950
leaq 0x60(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2200
leaq 0x120(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x8b04
leaq 0x60(%rsp), %rdi
callq 0x20e0
leaq 0x8(%rsp), %rdi
callq 0x20e0
jmp 0x36b7
movq 0x1192d(%rip), %rdi     # 0x14fd0
leaq 0x99d9(%rip), %rsi      # 0xd083
callq 0x21b0
movq %rax, %rdi
callq 0x20f0
pushq $0x3
popq %rbp
leaq 0x1e0(%rsp), %r15
movq 0x11907(%rip), %r12     # 0x14fd0
leaq 0x8(%rsp), %r13
leaq 0x120(%rsp), %rdi
movl %ebp, %esi
callq 0x8c9c
cmpl $0x2, %eax
je 0x37af
leaq 0x180(%rsp), %rdi
movl %ebp, %esi
callq 0x8c9c
cmpl $0x2, %eax
je 0x37af
movq %r15, %rdi
callq 0xa80c
movq %r15, %rdi
callq 0xb0b2
movl %eax, %r14d
movq %r12, %rdi
leaq 0x99c6(%rip), %rsi      # 0xd0e1
callq 0x21b0
movl 0x260(%rsp), %esi
decl %esi
movq %rax, %rdi
callq 0x2290
movq %rax, %rdi
leaq 0x99bb(%rip), %rsi      # 0xd0f6
callq 0x21b0
movq %rax, %rbx
xorl %eax, %eax
cmpl $0x1, %r14d
setne %al
movq 0x1f0(%rsp,%rax,8), %rsi
movq %r13, %rdi
callq 0x8b0e
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2180
movq %rax, %rdi
callq 0x20f0
movq %r13, %rdi
callq 0x20e0
movq %r12, %rdi
leaq 0x997b(%rip), %rsi      # 0xd0fc
callq 0x21b0
movq %rax, %rdi
callq 0x20f0
movq $0x3, 0x8(%rsp)
movq %r13, %rdi
callq 0x398b
movq %r15, %rdi
movl %r14d, %esi
callq 0xa74c
jmp 0x36ce
leaq 0x1e0(%rsp), %rdi
callq 0xbf34
movl %eax, %ebx
movq 0x1180b(%rip), %rdi     # 0x14fd0
callq 0x20f0
movq 0x117ff(%rip), %rdi     # 0x14fd0
leaq 0x993c(%rip), %rsi      # 0xd114
callq 0x21b0
movq %rax, %r14
xorl %eax, %eax
cmpl $0x1, %ebx
setne %al
movq 0x1f0(%rsp,%rax,8), %rsi
leaq 0x8(%rsp), %rdi
callq 0x8b0e
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x20f0
leaq 0x8(%rsp), %rdi
callq 0x20e0
leaq 0x1e0(%rsp), %rdi
callq 0xa6ea
leaq 0x180(%rsp), %rdi
callq 0xa2d6
leaq 0x120(%rsp), %rdi
callq 0xa2d6
leaq 0x100(%rsp), %rdi
callq 0x7fe6
leaq 0x28(%rsp), %rdi
callq 0x76b2
xorl %eax, %eax
addq $0x378, %rsp            # imm = 0x378
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0x3883
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x20e0
jmp 0x389f
jmp 0x38f3
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x38a4
jmp 0x38f3
jmp 0x3906
jmp 0x3906
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x20e0
jmp 0x38f6
jmp 0x38f3
jmp 0x3906
movq %rax, %rbx
jmp 0x3916
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x20e0
jmp 0x3923
movq %rax, %rbx
jmp 0x3923
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x20e0
jmp 0x3930
movq %rax, %rbx
jmp 0x3930
jmp 0x38e4
movq %rax, %rbx
jmp 0x393d
jmp 0x38f3
jmp 0x3906
jmp 0x3906
jmp 0x3906
jmp 0x3906
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x20e0
jmp 0x3909
jmp 0x3906
jmp 0x3906
movq %rax, %rbx
leaq 0x1e0(%rsp), %rdi
callq 0xa6ea
leaq 0x180(%rsp), %rdi
callq 0xa2d6
leaq 0x120(%rsp), %rdi
callq 0xa2d6
leaq 0x100(%rsp), %rdi
callq 0x7fe6
leaq 0x28(%rsp), %rdi
callq 0x76b2
movq %rbx, %rdi
callq 0x22a0
nop