// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x59de
testb %al, %al
je 0x3a96
movq 0x75d2(%rip), %r12      # 0xafd0
leaq 0x380f(%rip), %rsi      # 0x7214
movl $0x9, %edx
movq %r12, %rdi
callq 0x2190
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x59a6
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r12, %rdi
callq 0x2190
movq %rax, %r12
leaq 0x37e2(%rip), %rsi      # 0x721e
movl $0xf, %edx
movq %rax, %rdi
callq 0x2190
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3a8c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2180
movq %r14, %rdi
callq 0x59d4
jmp 0x3aaf
leaq 0x18(%rbx), %r12
movq %r14, %rdi
callq 0x59ca
movq %r15, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x4728
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x59a6
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq 0x7501(%rip), %rdi      # 0xafd0
callq 0x2190
movq %rax, %r12
leaq 0x3750(%rip), %rsi      # 0x722e
movl $0x5, %edx
movq %rax, %rdi
callq 0x2190
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
leaq 0x18(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x3b2e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2180
movq %r15, %rdi
callq 0x59d4
movq %r14, %rdi
callq 0x59ca
movl %eax, %ebp
movq %r15, %rdi
callq 0x59ca
cmpl %eax, %ebp
jg 0x3b58
movq %r15, %rdi
callq 0x59de
testb %al, %al
je 0x3b68
movq %r14, %rdi
callq 0x59de
testb %al, %al
je 0x3bf5
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x59a6
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq 0x7448(%rip), %rdi      # 0xafd0
callq 0x2190
movq %rax, %r15
leaq 0x369d(%rip), %rsi      # 0x7234
movl $0x12, %edx
movq %rax, %rdi
callq 0x2190
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x3be2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2180
movl 0x10(%rbx), %esi
movq %r14, %rdi
callq 0x5eca
incl 0x8(%rbx)
jmp 0x3c7b
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x59a6
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x73bd(%rip), %rdi      # 0xafd0
callq 0x2190
movq %rax, %r15
leaq 0x3612(%rip), %rsi      # 0x7234
movl $0x12, %edx
movq %rax, %rdi
callq 0x2190
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x3c6d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2180
movl 0x10(%rbx), %esi
movq %r14, %rdi
callq 0x5ec6
incl 0xc(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3c8e
jmp 0x3c9d
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
jne 0x3cae
jmp 0x3cbb
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3cbb
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2180
movq %rbx, %rdi
callq 0x2230
nop