// File: moloch--[P]cli-Blackjack/./Blackjack/Blackjack.cpp
// Function: Blackjack::findWinner(Player&, Dealer&)
void Blackjack::findWinner(Player & player, Dealer & dealer)
{
    if(player.isBust()) // Check to see if player busted during their turn
    {
        cout << "\n***** [ " << player.getName() << " busted ] *****" << endl;
        player.printCurrentHand();
    }
    else
    {
        dealer.turn(deck, player.getCurrentScore());
    }
    cout << dealer.getName() << " has:" << endl;
    dealer.printCurrentHand();
    /* Find winner and print the results on stdout, remember house wins on a tie */
    if((player.getCurrentScore() > dealer.getCurrentScore() || dealer.isBust()) && !player.isBust())
    {
        cout << player.getName() << " has won the game!" << endl;
        player.giveMoney(wager);
        playerWins++;
    }
    else
    {
        cout << dealer.getName() << " has won the game!" << endl;
        player.takeMoney(wager);
        dealerWins++;
    }
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x130(%rsp)
movq %rsi, 0x128(%rsp)
movq %rdx, 0x120(%rsp)
movq 0x130(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x128(%rsp), %rdi
callq 0x86c0
testb $0x1, %al
jne 0x5755
jmp 0x5810
movq 0x8874(%rip), %rdi      # 0xdfd0
leaq 0x4ab1(%rip), %rsi      # 0xa214
callq 0x21b0
movq %rax, 0x70(%rsp)
movq 0x128(%rsp), %rsi
leaq 0x100(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x8650
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x2180
movq %rax, 0x80(%rsp)
jmp 0x57a0
movq 0x80(%rsp), %rdi
leaq 0x4a6f(%rip), %rsi      # 0xa21e
callq 0x21b0
movq %rax, 0x68(%rsp)
jmp 0x57bb
movq 0x68(%rsp), %rdi
movq 0x87f9(%rip), %rsi      # 0xdfc0
callq 0x21f0
jmp 0x57ce
leaq 0x100(%rsp), %rdi
callq 0x2110
movq 0x128(%rsp), %rdi
callq 0x86a0
jmp 0x584c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x2110
jmp 0x5aba
movq 0x88(%rsp), %rax
movq 0x120(%rsp), %rcx
movq %rcx, 0x58(%rsp)
addq $0x18, %rax
movq %rax, 0x60(%rsp)
movq 0x128(%rsp), %rdi
callq 0x8680
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rsi
movl %eax, %edx
callq 0x6750
movq 0x120(%rsp), %rsi
leaq 0xd0(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x8650
movq 0x48(%rsp), %rsi
movq 0x875e(%rip), %rdi      # 0xdfd0
callq 0x2180
movq %rax, 0x50(%rsp)
jmp 0x587e
movq 0x50(%rsp), %rdi
leaq 0x49a4(%rip), %rsi      # 0xa22e
callq 0x21b0
movq %rax, 0x40(%rsp)
jmp 0x5896
movq 0x40(%rsp), %rdi
movq 0x871e(%rip), %rsi      # 0xdfc0
callq 0x21f0
jmp 0x58a9
leaq 0xd0(%rsp), %rdi
callq 0x2110
movq 0x120(%rsp), %rdi
callq 0x86a0
movq 0x128(%rsp), %rdi
callq 0x8680
movl %eax, 0x3c(%rsp)
movq 0x120(%rsp), %rdi
callq 0x8680
movl %eax, %ecx
movl 0x3c(%rsp), %eax
cmpl %ecx, %eax
jg 0x5901
movq 0x120(%rsp), %rdi
callq 0x86c0
testb $0x1, %al
jne 0x5901
jmp 0x59fa
movq 0x128(%rsp), %rdi
callq 0x86c0
testb $0x1, %al
jne 0x59fa
movq 0x128(%rsp), %rsi
leaq 0xb0(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x8650
movq 0x28(%rsp), %rsi
movq 0x8694(%rip), %rdi      # 0xdfd0
callq 0x2180
movq %rax, 0x30(%rsp)
jmp 0x5948
movq 0x30(%rsp), %rdi
leaq 0x48e0(%rip), %rsi      # 0xa234
callq 0x21b0
movq %rax, 0x20(%rsp)
jmp 0x5960
movq 0x20(%rsp), %rdi
movq 0x8654(%rip), %rsi      # 0xdfc0
callq 0x21f0
jmp 0x5973
leaq 0xb0(%rsp), %rdi
callq 0x2110
movq 0x88(%rsp), %rax
movq 0x128(%rsp), %rdi
movl 0x10(%rax), %esi
callq 0x8d20
movq 0x88(%rsp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x5ab2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x2110
jmp 0x5aba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x2110
jmp 0x5aba
movq 0x120(%rsp), %rsi
leaq 0x90(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x8650
movq 0x10(%rsp), %rsi
movq 0x85b0(%rip), %rdi      # 0xdfd0
callq 0x2180
movq %rax, 0x18(%rsp)
jmp 0x5a2c
movq 0x18(%rsp), %rdi
leaq 0x47fc(%rip), %rsi      # 0xa234
callq 0x21b0
movq %rax, 0x8(%rsp)
jmp 0x5a44
movq 0x8(%rsp), %rdi
movq 0x8570(%rip), %rsi      # 0xdfc0
callq 0x21f0
jmp 0x5a57
leaq 0x90(%rsp), %rdi
callq 0x2110
movq 0x88(%rsp), %rax
movq 0x128(%rsp), %rdi
movl 0x10(%rax), %esi
callq 0x8d40
movq 0x88(%rsp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x5ab2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x2110
jmp 0x5aba
addq $0x138, %rsp            # imm = 0x138
retq
movq 0xf8(%rsp), %rdi
callq 0x22f0
nopw (%rax,%rax)