// File: /workspace/github_cpp_makefile_star2_O2/ogghead[P]Moon_Boersma_Coe_CSCI2270_FinalProject/Main.cpp
// Function: main
int main()
{
    Blackjack myGame;
        int i=0;
        int dD=0;
        int deck=0;
        int players=0;
        string inputDeck, inputPlayers;
        cout<<"How many decks: "<<endl;
        getline(cin,inputDeck);
        stringstream de(inputDeck);
        de >> deck;
        cout<<"How many players: "<<endl;
        getline(cin,inputPlayers);
        stringstream pl(inputPlayers);
        pl >> players;
    myGame.buildDeck(deck);
    myGame.shuffleDeck(deck);
    myGame.createPlayers(players);

    bool Quit = false;
     player* me = myGame.returnPlayer();
        player* dealer = myGame.returnDealer();
    while (!Quit)
    {
        myGame.Reset();
        string bet;
        cout<<"Buy-in is 10, max bet is 1000."<<endl;
        cout<<"How much would you like to bet?"<<endl;
        cout<<"You have: "<< me->totalMoney << " dollars left." << endl;
        getline(cin,bet);
        int myBet = stoi(bet);
        myGame.Bet(myBet);
        myGame.Deal();

        myGame.show();
        cout << "The dealer has: " << endl;
        cout << "??" << endl;
        cout << dealer->hand[0]->name << " of " << dealer->hand[0]->sui << endl;
        cout << endl;

        cout << "You have: " << endl;
        cout << me->hand[0]->name << " of " << me->hand[0]->sui << endl;
        cout << me->hand[1]->name << " of " << me->hand[1]->sui << endl;
        cout << endl;
        //cout << dealer->hand[1] << endl;



        cout << "1. Hit " << endl;
        cout << "2. Stand" << endl;
        cout << "3. Double Down " << endl;
        int splitted=0;
        if (me->hand[0]->name == me->hand[1]->name){
            cout << "4. Split " << endl;
            me->isSplit = true;

        }
        string choice;
        getline(cin, choice);
        int myChoice = stoi(choice);
        if (myChoice == 1){
            myGame.HitMe(me, false);

        }
        if (myChoice == 2){
            myGame.Stand(me);
        }
        if (myChoice == 3){
            myGame.doubleDown(me);
        }
        if (myChoice == 4 && me->isSplit==true){
            myGame.Split(me);
            splitted=1;
        }

        while (!me->stand)
        {
            cout << "1. Hit " << endl;
            cout << "2. Stand" << endl;
            string choice;
            getline(cin, choice);
            int myChoice = stoi(choice);

            if (myChoice == 1){
                myGame.HitMe(me, false);
            }
            if (myChoice == 2){
                myGame.Stand(me);
            }
        }
        if (me->isSplit){
            while (!me->stand2)
            {
                cout << "1. Hit " << endl;
                cout << "2. Stand" << endl;
                string choice;
                getline(cin, choice);
                int myChoice = stoi(choice);

                if (myChoice == 1){
                    myGame.HitMe(me, true);
                }
                if (myChoice == 2){
                    myGame.Stand2(me);
                }
            }
        }
        myGame.Round();
//cout<<"F"<<endl;
        myGame.show();
     cout << "The dealer had: " << endl;
        for (int i = 0; i < dealer->hand.size();i++)
        {
            cout << dealer->hand[i]->name << " of " << dealer->hand[i]->sui << endl;
        }
        cout << endl;

        cout << "You had: " << endl;
        for (int i = 0; i < me->hand.size();i++)
        {
            cout << me->hand[i]->name << " of " << me->hand[i]->sui << endl;
        }
        cout << endl;

         cout<<"CardCounter: "<<myGame.displayCardCounter()<<endl;
        if(me->handValue > 21){
            me->handValue=0;
        }
         if(dealer->handValue > 21){
            dealer->handValue=0;
        }
        if(me->handValue < dealer->handValue){
            cout<<"You lose."<<endl;
            me->totalMoney=me->totalMoney-me->bet;
        }
        if(me->handValue > dealer->handValue){
            cout<< " You win." <<endl;
            if(me->hand.size()==2){
                me->totalMoney=me->totalMoney+(me->bet)/2 +me->bet;
            }else{
            me->totalMoney=me->totalMoney+me->bet;
            }
        }
        if(me->handValue==dealer->handValue){
            cout<< " You push." <<endl;
        }

        if(splitted==1){
          if(me->handValue2 > 21){
            me->handValue2=0;
        }


        if(me->handValue2 < dealer->handValue){
            cout<<"You lose.(Second Hand)"<<endl;
            me->totalMoney=me->totalMoney-me->bet2;
        }
        if(me->handValue > dealer->handValue){
             cout<< " You win. (Second Hand)" <<endl;
            if(me->hand2.size()==2){
                me->totalMoney=me->totalMoney+(me->bet2)/2 +me->bet2;
            }else{
            me->totalMoney=me->totalMoney+me->bet2;
            }
        }
        if(me->handValue==dealer->handValue){
                cout << "You push. (Second Hand)"<<endl;
        }


    }


    cout<< "Would you like to stop playing? (Y) ";
    string choice2;
    getline(cin, choice2);
    if (choice2 == "Y")
        Quit = true;
    }


    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3f8, %rsp            # imm = 0x3F8
leaq -0x90(%rbp), %rdi
callq 0x234c
andl $0x0, -0x30(%rbp)
andl $0x0, -0x34(%rbp)
leaq -0x100(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq -0xe0(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
movq 0x2fb3(%rip), %rdi      # 0x5fc8
leaq 0x1134(%rip), %rsi      # 0x4150
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq 0x2fb0(%rip), %rdi      # 0x5fe0
leaq -0x110(%rbp), %rsi
callq 0x2040
leaq -0x420(%rbp), %rdi
leaq -0x110(%rbp), %rsi
pushq $0x18
popq %rdx
callq 0x2190
leaq -0x420(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x20d0
movq 0x2f5f(%rip), %rdi      # 0x5fc8
leaq 0x10f1(%rip), %rsi      # 0x4161
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq 0x2f5c(%rip), %rdi      # 0x5fe0
leaq -0xf0(%rbp), %rsi
callq 0x2040
leaq -0x298(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
pushq $0x18
popq %rdx
callq 0x2190
leaq -0x298(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x20d0
movl -0x30(%rbp), %esi
leaq -0x90(%rbp), %rdi
callq 0x2384
movl -0x30(%rbp), %esi
leaq -0x90(%rbp), %rdi
callq 0x2486
movl -0x34(%rbp), %esi
leaq -0x90(%rbp), %rdi
callq 0x263a
leaq -0x90(%rbp), %rdi
callq 0x29d0
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x2aca
movq %rax, %r14
leaq -0x90(%rbp), %r15
movq 0x2eb9(%rip), %r12      # 0x5fc8
leaq -0x58(%rbp), %r13
movq %r15, %rdi
callq 0x2968
leaq -0xa0(%rbp), %rax
movq %rax, -0xb0(%rbp)
andq $0x0, -0xa8(%rbp)
movb $0x0, -0xa0(%rbp)
movq %r12, %rdi
leaq 0x1032(%rip), %rsi      # 0x4174
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq %r12, %rdi
leaq 0xf20(%rip), %rsi       # 0x4079
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq %r12, %rdi
leaq 0x1023(%rip), %rsi      # 0x4193
callq 0x2150
movl 0x40(%rbx), %esi
movq %rax, %rdi
callq 0x21b0
movq %rax, %rdi
leaq 0x1014(%rip), %rsi      # 0x419e
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq 0x2e42(%rip), %rdi      # 0x5fe0
leaq -0xb0(%rbp), %rsi
callq 0x2040
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2bd7
movq %r15, %rdi
movl %eax, %esi
callq 0x2854
movq %r15, %rdi
callq 0x2796
movq %r15, %rdi
callq 0x29de
movq %r12, %rdi
leaq 0xfce(%rip), %rsi       # 0x41ad
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq %r12, %rdi
leaq 0xfc8(%rip), %rsi       # 0x41be
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq 0x28(%r14), %rax
movq (%rax), %rsi
addq $0x28, %rsi
movq %r12, %rdi
callq 0x2110
movq %rax, %rdi
leaq 0xe81(%rip), %rsi       # 0x40a1
callq 0x2150
movq 0x28(%r14), %rcx
movq (%rcx), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x20a0
movq %r12, %rdi
callq 0x20a0
movq %r12, %rdi
leaq 0xf41(%rip), %rsi       # 0x4193
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq 0x28(%rbx), %rax
movq (%rax), %rsi
addq $0x28, %rsi
movq %r12, %rdi
callq 0x2110
movq %rax, %rdi
leaq 0xe25(%rip), %rsi       # 0x40a1
callq 0x2150
movq 0x28(%rbx), %rcx
movq (%rcx), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x20a0
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rsi
addq $0x28, %rsi
movq %r12, %rdi
callq 0x2110
movq %rax, %rdi
leaq 0xde7(%rip), %rsi       # 0x40a1
callq 0x2150
movq 0x28(%rbx), %rcx
movq 0x8(%rcx), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x20a0
movq %r12, %rdi
callq 0x20a0
movq %r12, %rdi
leaq 0xed4(%rip), %rsi       # 0x41c1
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq %r12, %rdi
leaq 0xec5(%rip), %rsi       # 0x41c9
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq %r12, %rdi
leaq 0xeb7(%rip), %rsi       # 0x41d2
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq 0x28(%rbx), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rsi
addq $0x28, %rdi
addq $0x28, %rsi
callq 0x3932
testb %al, %al
je 0x335f
movq %r12, %rdi
leaq 0xe94(%rip), %rsi       # 0x41e2
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movb $0x1, 0x48(%rbx)
leaq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
andq $0x0, -0xc8(%rbp)
movb $0x0, -0xc0(%rbp)
movq 0x2c5d(%rip), %rdi      # 0x5fe0
leaq -0xd0(%rbp), %r15
movq %r15, %rsi
callq 0x2040
movq %r15, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2bd7
decl %eax
cmpl $0x3, %eax
ja 0x340c
leaq 0xd93(%rip), %rcx       # 0x4140
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x2c(%rbp)
leaq -0x90(%rbp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2542
jmp 0x3413
leaq -0x90(%rbp), %rdi
movq %rbx, %rsi
callq 0x2912
jmp 0x340c
cmpb $0x1, 0x48(%rbx)
jne 0x340c
movb $0x1, %al
movl %eax, -0x2c(%rbp)
leaq -0x90(%rbp), %rdi
movq %rbx, %rsi
callq 0x27ec
jmp 0x3413
leaq -0x90(%rbp), %rdi
movq %rbx, %rsi
callq 0x2630
movl $0x0, -0x2c(%rbp)
leaq -0x90(%rbp), %r15
cmpb $0x0, 0x6c(%rbx)
jne 0x34b0
movq %r12, %rdi
leaq 0xd93(%rip), %rsi       # 0x41c1
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq %r12, %rdi
leaq 0xd84(%rip), %rsi       # 0x41c9
callq 0x2150
movq %rax, %rdi
callq 0x20a0
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
andq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
movq 0x2b76(%rip), %rdi      # 0x5fe0
movq %r13, %rsi
callq 0x2040
movq %r13, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2bd7
cmpl $0x2, %eax
je 0x3498
cmpl $0x1, %eax
jne 0x34a3
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2542
jmp 0x34a3
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2630
movq %r13, %rdi
callq 0x2090
jmp 0x341a
cmpb $0x1, 0x48(%rbx)
jne 0x3551
cmpb $0x0, 0x6d(%rbx)
jne 0x3551
movq %r12, %rdi
leaq 0xcf3(%rip), %rsi       # 0x41c1
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq %r12, %rdi
leaq 0xce4(%rip), %rsi       # 0x41c9
callq 0x2150
movq %rax, %rdi
callq 0x20a0
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
andq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
movq 0x2ad6(%rip), %rdi      # 0x5fe0
movq %r13, %rsi
callq 0x2040
movq %r13, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2bd7
cmpl $0x2, %eax
je 0x3539
cmpl $0x1, %eax
jne 0x3544
movq %r15, %rdi
movq %rbx, %rsi
pushq $0x1
popq %rdx
callq 0x2542
jmp 0x3544
movq %r15, %rdi
movq %rbx, %rsi
callq 0x27e2
movq %r13, %rdi
callq 0x2090
jmp 0x34ba
movq %r15, %rdi
callq 0x2930
leaq -0x90(%rbp), %rdi
callq 0x29de
movq %r12, %rdi
leaq 0xc7d(%rip), %rsi       # 0x41ec
callq 0x2150
movq %rax, %rdi
callq 0x20a0
xorl %r15d, %r15d
movq 0x28(%r14), %rax
movq 0x30(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
jbe 0x35d3
movq (%rax,%r15,8), %rsi
addq $0x28, %rsi
movq %r12, %rdi
callq 0x2110
movq %rax, %rdi
leaq 0xaf4(%rip), %rsi       # 0x40a1
callq 0x2150
movq 0x28(%r14), %rcx
movq (%rcx,%r15,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x20a0
incq %r15
jmp 0x357f
movq %r12, %rdi
callq 0x20a0
movq %r12, %rdi
leaq 0xc18(%rip), %rsi       # 0x41fd
callq 0x2150
movq %rax, %rdi
callq 0x20a0
xorl %r15d, %r15d
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
jbe 0x3649
movq (%rax,%r15,8), %rsi
addq $0x28, %rsi
movq %r12, %rdi
callq 0x2110
movq %rax, %rdi
leaq 0xa7e(%rip), %rsi       # 0x40a1
callq 0x2150
movq 0x28(%rbx), %rcx
movq (%rcx,%r15,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x20a0
incq %r15
jmp 0x35f5
movq %r12, %rdi
callq 0x20a0
movq %r12, %rdi
leaq 0xbac(%rip), %rsi       # 0x4207
callq 0x2150
movq %rax, %r15
leaq -0x90(%rbp), %rdi
callq 0x2908
movq %r15, %rdi
movl %eax, %esi
callq 0x21b0
movq %rax, %rdi
callq 0x20a0
movl 0x24(%rbx), %eax
cmpl $0x16, %eax
jl 0x368f
andl $0x0, 0x24(%rbx)
xorl %eax, %eax
movl 0x24(%r14), %ecx
cmpl $0x16, %ecx
jl 0x36a2
andl $0x0, 0x24(%r14)
movl 0x24(%rbx), %eax
xorl %ecx, %ecx
cmpl %ecx, %eax
jge 0x36ca
movq %r12, %rdi
leaq 0xb65(%rip), %rsi       # 0x4215
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movl 0x24(%rbx), %eax
movl 0x44(%rbx), %ecx
subl %ecx, 0x40(%rbx)
movl 0x24(%r14), %ecx
cmpl %ecx, %eax
jle 0x370c
movq %r12, %rdi
leaq 0xb47(%rip), %rsi       # 0x421f
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq 0x30(%rbx), %rax
subq 0x28(%rbx), %rax
movl 0x40(%rbx), %esi
movl 0x44(%rbx), %ecx
cmpq $0x10, %rax
jne 0x3707
movl %ecx, %eax
cltd
pushq $0x2
popq %rdi
idivl %edi
addl %ecx, %esi
addl %eax, %esi
jmp 0x3709
addl %ecx, %esi
movl %esi, 0x40(%rbx)
movl 0x24(%rbx), %eax
cmpl 0x24(%r14), %eax
jne 0x372c
movq %r12, %rdi
leaq 0xb0a(%rip), %rsi       # 0x4229
callq 0x2150
movq %rax, %rdi
callq 0x20a0
cmpb $0x0, -0x2c(%rbp)
je 0x37d0
movl 0x4c(%rbx), %eax
cmpl $0x16, %eax
jl 0x3744
andl $0x0, 0x4c(%rbx)
xorl %eax, %eax
movl 0x24(%r14), %ecx
cmpl %ecx, %eax
jge 0x376d
movq %r12, %rdi
leaq 0xade(%rip), %rsi       # 0x4234
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movl 0x68(%rbx), %eax
subl %eax, 0x40(%rbx)
movl 0x24(%r14), %ecx
cmpl %ecx, 0x24(%rbx)
jle 0x37b0
movq %r12, %rdi
leaq 0xacf(%rip), %rsi       # 0x424b
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq 0x58(%rbx), %rax
subq 0x50(%rbx), %rax
movl 0x40(%rbx), %esi
movl 0x68(%rbx), %ecx
cmpq $0x10, %rax
jne 0x37ab
movl %ecx, %eax
cltd
pushq $0x2
popq %rdi
idivl %edi
addl %ecx, %esi
addl %eax, %esi
jmp 0x37ad
addl %ecx, %esi
movl %esi, 0x40(%rbx)
movl 0x24(%rbx), %eax
cmpl 0x24(%r14), %eax
jne 0x37d0
movq %r12, %rdi
leaq 0xaa0(%rip), %rsi       # 0x4263
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq %r12, %rdi
leaq 0xaa1(%rip), %rsi       # 0x427b
callq 0x2150
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
andq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
movq 0x27e9(%rip), %rdi      # 0x5fe0
movq %r13, %rsi
callq 0x2040
movq %r13, %rdi
leaq 0xa97(%rip), %rsi       # 0x42a0
callq 0x3955
movl %eax, %r15d
movq %r13, %rdi
callq 0x2090
leaq -0xd0(%rbp), %rdi
callq 0x2090
leaq -0xb0(%rbp), %rdi
callq 0x2090
testb %r15b, %r15b
leaq -0x90(%rbp), %r15
je 0x3113
leaq -0x298(%rbp), %rdi
callq 0x20e0
leaq -0x420(%rbp), %rdi
callq 0x20e0
leaq -0xf0(%rbp), %rdi
callq 0x2090
leaq -0x110(%rbp), %rdi
callq 0x2090
leaq -0x90(%rbp), %rdi
callq 0x2364
xorl %eax, %eax
addq $0x3f8, %rsp            # imm = 0x3F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x38ab
jmp 0x38ab
jmp 0x38a0
jmp 0x3899
movq %rax, %rbx
jmp 0x3906
jmp 0x38ab
movq %rax, %rbx
jmp 0x38fa
jmp 0x38bf
jmp 0x38b8
jmp 0x38d3
movq %rax, %rbx
jmp 0x38ee
jmp 0x38b8
jmp 0x38bf
jmp 0x38d3
jmp 0x38bf
movq %rax, %rbx
jmp 0x38e2
jmp 0x38bf
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x2090
jmp 0x38d6
jmp 0x38d3
jmp 0x38d3
jmp 0x38d3
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x2090
leaq -0xb0(%rbp), %rdi
callq 0x2090
leaq -0x298(%rbp), %rdi
callq 0x20e0
leaq -0x420(%rbp), %rdi
callq 0x20e0
leaq -0xf0(%rbp), %rdi
callq 0x2090
leaq -0x110(%rbp), %rdi
callq 0x2090
leaq -0x90(%rbp), %rdi
callq 0x2364
movq %rbx, %rdi
callq 0x21c0