// File: /workspace/github_cpp_makefile_star2_O3/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 0x5a1a
testb %al, %al
je 0x3aae
movq 0x75ba(%rip), %r12      # 0xafd0
leaq 0x37f7(%rip), %rsi      # 0x7214
movl $0x9, %edx
movq %r12, %rdi
callq 0x2190
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x59e2
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r12, %rdi
callq 0x2190
movq %rax, %r12
leaq 0x37ca(%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 0x3aa4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2180
movq %r14, %rdi
callq 0x5a10
jmp 0x3ac7
leaq 0x18(%rbx), %r12
movq %r14, %rdi
callq 0x5a06
movq %r15, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x4740
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x59e2
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq 0x74e9(%rip), %rdi      # 0xafd0
callq 0x2190
movq %rax, %r12
leaq 0x3738(%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 0x3b46
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2180
movq %r15, %rdi
callq 0x5a10
movq %r14, %rdi
callq 0x5a06
movl %eax, %ebp
movq %r15, %rdi
callq 0x5a06
cmpl %eax, %ebp
jg 0x3b70
movq %r15, %rdi
callq 0x5a1a
testb %al, %al
je 0x3b80
movq %r14, %rdi
callq 0x5a1a
testb %al, %al
je 0x3c0d
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x59e2
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq 0x7430(%rip), %rdi      # 0xafd0
callq 0x2190
movq %rax, %r15
leaq 0x3685(%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 0x3bfa
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2180
movl 0x10(%rbx), %esi
movq %r14, %rdi
callq 0x5f04
incl 0x8(%rbx)
jmp 0x3c93
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x59e2
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x73a5(%rip), %rdi      # 0xafd0
callq 0x2190
movq %rax, %r15
leaq 0x35fa(%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 0x3c85
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2180
movl 0x10(%rbx), %esi
movq %r14, %rdi
callq 0x5f00
incl 0xc(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3ca6
jmp 0x3cb5
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
jne 0x3cc6
jmp 0x3cd3
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3cd3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2180
movq %rbx, %rdi
callq 0x2230
nop