// File: fredericmarchand[P]TexasHoldem/Player.cpp
// Function: Player::doMove(moves, int, Player*, bool)
Move Player::doMove(Move move, int index, Player *last, bool sim)
{
    //int prob = (rand() % 2)+1;
    if (!sim)
        cout << "Player " << index << ": ";
    switch (move) 
    {
        case FOLD:
            fold();
            if (!sim)
                cout << "fold" << endl;
            return FOLD;
        case BET:
            if (last->getState().bet >= state.bet)
            {
                bet(DEFAULT_BET + (last->getState().bet - getState().bet));
                if (!sim)
                    cout << "raise " << DEFAULT_BET << " to " << getState().bet << endl;
            }
            else
            {
                bet(DEFAULT_BET);
                if (!sim)
                    cout << "bet " << DEFAULT_BET << endl;
            }
            return BET;
        case CHECK:
        default:
            if (last->getState().bet > getState().bet)
            {
                bet(last->getState().bet - getState().bet);
                check();
                if (!sim)
                    cout << "call" << endl;
            }
            else
            {
                check();
                if (!sim)
                    cout << "check" << endl;
            }
            return CHECK;      
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
testb $0x1, -0x21(%rbp)
jne 0x37fc
movq 0xc7fa(%rip), %rdi      # 0xffd0
leaq 0x7a2d(%rip), %rsi      # 0xb20a
callq 0x2180
movq %rax, %rdi
movl -0x18(%rbp), %esi
callq 0x2290
movq %rax, %rdi
leaq 0x7a49(%rip), %rsi      # 0xb240
callq 0x2180
movl -0x14(%rbp), %eax
movl %eax, -0x74(%rbp)
testl %eax, %eax
je 0x3823
jmp 0x3808
movl -0x74(%rbp), %eax
subl $0x1, %eax
je 0x3963
jmp 0x3816
movl -0x74(%rbp), %eax
subl $0x2, %eax
je 0x3860
jmp 0x3965
movq -0x70(%rbp), %rdi
callq 0x3780
testb $0x1, -0x21(%rbp)
jne 0x3854
movq 0xc797(%rip), %rdi      # 0xffd0
leaq 0x78a2(%rip), %rsi      # 0xb0e2
callq 0x2180
movq %rax, %rdi
movq 0xc771(%rip), %rsi      # 0xffc0
callq 0x21b0
movl $0x0, -0x4(%rbp)
jmp 0x3a38
movq -0x20(%rbp), %rdi
callq 0x3690
movq -0x70(%rbp), %rcx
movq %rax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
cmpl 0x1c(%rcx), %eax
jl 0x3912
movq -0x20(%rbp), %rdi
callq 0x3690
movq -0x70(%rbp), %rdi
movq %rax, -0x34(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x78(%rbp)
callq 0x3690
movl -0x78(%rbp), %esi
movq -0x70(%rbp), %rdi
movq %rax, -0x3c(%rbp)
subl -0x38(%rbp), %esi
addl $0x64, %esi
callq 0x36d0
testb $0x1, -0x21(%rbp)
jne 0x3910
movq 0xc714(%rip), %rdi      # 0xffd0
leaq 0x7824(%rip), %rsi      # 0xb0e7
callq 0x2180
movq %rax, %rdi
movl $0x64, %esi
callq 0x2290
movq %rax, %rdi
leaq 0x780f(%rip), %rsi      # 0xb0ee
callq 0x2180
movq -0x70(%rbp), %rdi
movq %rax, -0x80(%rbp)
callq 0x3690
movq -0x80(%rbp), %rdi
movq %rax, -0x44(%rbp)
movl -0x40(%rbp), %esi
callq 0x2290
movq %rax, %rdi
movq 0xc6b5(%rip), %rsi      # 0xffc0
callq 0x21b0
jmp 0x3957
movq -0x70(%rbp), %rdi
movl $0x64, %esi
callq 0x36d0
testb $0x1, -0x21(%rbp)
jne 0x3955
movq 0xc6a3(%rip), %rdi      # 0xffd0
leaq 0x77bf(%rip), %rsi      # 0xb0f3
callq 0x2180
movq %rax, %rdi
movl $0x64, %esi
callq 0x2290
movq %rax, %rdi
movq 0xc670(%rip), %rsi      # 0xffc0
callq 0x21b0
jmp 0x3957
movl $0x2, -0x4(%rbp)
jmp 0x3a38
jmp 0x3965
movq -0x20(%rbp), %rdi
callq 0x3690
movq -0x70(%rbp), %rdi
movq %rax, -0x4c(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x84(%rbp)
callq 0x3690
movq %rax, %rcx
movl -0x84(%rbp), %eax
movq %rcx, -0x54(%rbp)
cmpl -0x50(%rbp), %eax
jle 0x39fe
movq -0x20(%rbp), %rdi
callq 0x3690
movq -0x70(%rbp), %rdi
movq %rax, -0x5c(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x88(%rbp)
callq 0x3690
movl -0x88(%rbp), %esi
movq -0x70(%rbp), %rdi
movq %rax, -0x64(%rbp)
subl -0x60(%rbp), %esi
callq 0x36d0
movq -0x70(%rbp), %rdi
callq 0x3750
testb $0x1, -0x21(%rbp)
jne 0x39fc
movq 0xc5ef(%rip), %rdi      # 0xffd0
leaq 0x7710(%rip), %rsi      # 0xb0f8
callq 0x2180
movq %rax, %rdi
movq 0xc5c9(%rip), %rsi      # 0xffc0
callq 0x21b0
jmp 0x3a31
movq -0x70(%rbp), %rdi
callq 0x3750
testb $0x1, -0x21(%rbp)
jne 0x3a2f
movq 0xc5bc(%rip), %rdi      # 0xffd0
leaq 0x76e2(%rip), %rsi      # 0xb0fd
callq 0x2180
movq %rax, %rdi
movq 0xc596(%rip), %rsi      # 0xffc0
callq 0x21b0
jmp 0x3a31
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)