// File: /workspace/github_cpp_makefile_star2_O1/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 0x80a0
movq %rbx, %rdi
callq 0x8c08
leaq 0x100(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x9436
leaq 0xf0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xc99d(%rip), %rsi      # 0x10004
leaq 0xc99b(%rip), %rdx      # 0x10009
leaq 0xe0(%rsp), %rdi
callq 0x3fee
leaq 0x120(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
callq 0xc3cc
movq 0xe0(%rsp), %rdi
cmpq %r14, %rdi
je 0x36b2
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0xd0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xc945(%rip), %rsi      # 0x1000a
leaq 0xc943(%rip), %rdx      # 0x1000f
leaq 0xc0(%rsp), %rdi
callq 0x3fee
leaq 0x180(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0xc3cc
movq 0xc0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3710
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x1e0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x100(%rsp), %rdx
leaq 0x120(%rsp), %rcx
leaq 0x180(%rsp), %r8
callq 0xc97c
movq 0x1288f(%rip), %rbx     # 0x15fd0
leaq 0xc8c8(%rip), %rsi      # 0x10010
movl $0x51, %edx
movq %rbx, %rdi
callq 0x21d0
movq 0x12884(%rip), %rdi     # 0x15fe0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %ecx
movq 0x12869(%rip), %r14     # 0x15fe0
leaq 0x270(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
callq 0x22a0
leaq 0xc8cf(%rip), %r15      # 0x10062
leaq 0x270(%rsp), %r12
leaq 0xc8c6(%rip), %r13      # 0x10068
leaq 0xc874(%rip), %rbp      # 0x1001d
movq %r12, %rdi
movq %r15, %rsi
callq 0x2230
testq %rax, %rax
je 0x37c9
movq %rax, %rdi
callq 0x2220
leal -0x4(%rax), %ecx
cmpl $-0x4, %ecx
ja 0x383c
movl $0x1a, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x21d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movl $0x44, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x21d0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %ecx
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
movq %r12, %rsi
callq 0x22a0
jmp 0x37a9
cmpl $0x3, %eax
je 0x3a1e
cmpl $0x2, %eax
jne 0x3af9
movq 0x1277b(%rip), %rdi     # 0x15fd0
leaq 0xc833(%rip), %rsi      # 0x1008f
movl $0x19, %edx
callq 0x21d0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %ecx
movq 0x1275c(%rip), %r14     # 0x15fe0
leaq 0x270(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
callq 0x22a0
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x270(%rsp), %r15
movq %r15, %rdi
callq 0x20c0
leaq (%rsp,%rax), %rdx
addq $0x270, %rdx            # imm = 0x270
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x3fee
movq 0x126fe(%rip), %rdi     # 0x15fd0
leaq 0xc7d0(%rip), %rsi      # 0x100a9
movl $0x19, %edx
callq 0x21d0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %ecx
movq 0x126df(%rip), %rdi     # 0x15fe0
leaq 0x270(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x22a0
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x270(%rsp), %r14
movq %r14, %rdi
callq 0x20c0
leaq (%rsp,%rax), %rdx
addq $0x270, %rdx            # imm = 0x270
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
callq 0x3fee
leaq 0xb0(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0xa0(%rsp), %rdi
callq 0x3f5e
leaq 0x120(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0xa5f0
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x399c
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x90(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x3f5e
leaq 0x180(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0xa5f0
movq 0x80(%rsp), %rdi
cmpq %r14, %rdi
je 0x39f4
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x3a0b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
jne 0x3aea
jmp 0x3b3f
movq 0x125ab(%rip), %rdi     # 0x15fd0
leaq 0xc697(%rip), %rsi      # 0x100c3
movl $0x1d, %edx
callq 0x21d0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %ecx
movq 0x1258c(%rip), %rdi     # 0x15fe0
leaq 0x270(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x22a0
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x270(%rsp), %r14
movq %r14, %rdi
callq 0x20c0
leaq (%rsp,%rax), %rdx
addq $0x270, %rdx            # imm = 0x270
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3fee
leaq 0x70(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %rdi
callq 0x3f5e
leaq 0x120(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0xa5f0
movq 0x60(%rsp), %rdi
cmpq %r14, %rdi
je 0x3ae0
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3b3f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x3b3f
movq 0x124d0(%rip), %r14     # 0x15fd0
leaq 0xc57c(%rip), %rsi      # 0x10083
movl $0xb, %edx
movq %r14, %rdi
callq 0x21d0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq 0x1249e(%rip), %rdi     # 0x15fd0
callq 0x2030
movq %rax, %rdi
callq 0x20f0
leaq 0x120(%rsp), %r14
leaq 0x1e0(%rsp), %r12
leaq 0x8(%rsp), %r13
movq %r14, %rdi
movl $0x3, %esi
callq 0xa912
cmpl $0x2, %eax
je 0x3cb9
leaq 0x180(%rsp), %rdi
movl $0x3, %esi
callq 0xa912
cmpl $0x2, %eax
je 0x3cb9
movq %r12, %rdi
callq 0xcb32
movq %r12, %rdi
callq 0xd7cc
movl %eax, %ebp
movl $0x14, %edx
movq %rbx, %rdi
leaq 0xc53b(%rip), %rsi      # 0x100e1
callq 0x21d0
movl 0x260(%rsp), %esi
decl %esi
movq %rbx, %rdi
callq 0x2270
movq %rax, %r15
movl $0x5, %edx
movq %rax, %rdi
leaq 0xc528(%rip), %rsi      # 0x100f6
callq 0x21d0
xorl %eax, %eax
cmpl $0x1, %ebp
setne %al
movq 0x1f0(%rsp,%rax,8), %rsi
movq %r13, %rdi
callq 0xa5fa
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0x21d0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3c43
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21a0
movl $0x17, %edx
movq %rbx, %rdi
leaq 0xc4aa(%rip), %rsi      # 0x100fc
callq 0x21d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq $0x3, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq %r13, %rdi
movq %r13, %rsi
callq 0x2090
cmpl $-0x1, %eax
jne 0x3caa
callq 0x2050
cmpl $0x4, (%rax)
je 0x3c90
movq %r12, %rdi
movl %ebp, %esi
callq 0xca74
jmp 0x3b54
leaq 0x1e0(%rsp), %rdi
callq 0xedc4
movl %eax, %ebp
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq 0x122ea(%rip), %rdi     # 0x15fd0
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq 0x122d6(%rip), %rdi     # 0x15fd0
leaq 0xc413(%rip), %rsi      # 0x10114
movl $0x21, %edx
callq 0x21d0
xorl %eax, %eax
cmpl $0x1, %ebp
setne %al
movq 0x1f0(%rsp,%rax,8), %rsi
leaq 0x8(%rsp), %rdi
callq 0xa5fa
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x1229a(%rip), %rdi     # 0x15fd0
callq 0x21d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3d81
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x1e0(%rsp), %rdi
callq 0xca12
leaq 0x180(%rsp), %rdi
callq 0xc45c
leaq 0x120(%rsp), %rdi
callq 0xc45c
leaq 0x100(%rsp), %rdi
callq 0x96b4
leaq 0x28(%rsp), %rdi
callq 0x8b02
xorl %eax, %eax
addq $0x378, %rsp            # imm = 0x378
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x80(%rsp), %rdi
cmpq %r14, %rdi
je 0x3e50
movq 0x90(%rsp), %rsi
jmp 0x3e05
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3e50
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x3e50
jmp 0x3e6e
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r14, %rdi
je 0x3e30
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x3e30
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
jne 0x3f01
jmp 0x3f17
jmp 0x3f14
jmp 0x3f14
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x3e71
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x3e71
jmp 0x3f14
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
jne 0x3f01
jmp 0x3f17
movq %rax, %rbx
jmp 0x3f24
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3f31
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x3f31
movq %rax, %rbx
jmp 0x3f31
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3f3e
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x3f3e
movq %rax, %rbx
jmp 0x3f3e
jmp 0x3ee0
movq %rax, %rbx
jmp 0x3f4b
jmp 0x3eef
jmp 0x3f14
jmp 0x3f14
jmp 0x3f14
jmp 0x3f14
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3f17
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x3f17
jmp 0x3f14
jmp 0x3f14
movq %rax, %rbx
leaq 0x1e0(%rsp), %rdi
callq 0xca12
leaq 0x180(%rsp), %rdi
callq 0xc45c
leaq 0x120(%rsp), %rdi
callq 0xc45c
leaq 0x100(%rsp), %rdi
callq 0x96b4
leaq 0x28(%rsp), %rdi
callq 0x8b02
movq %rbx, %rdi
callq 0x2280
nop