// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %r14d
movq %rcx, %r15
movl %esi, %r12d
movq %rdi, %rbx
testl %r8d, %r8d
jne 0x2bcd
movl %edx, %r13d
movq 0x6429(%rip), %rdi      # 0x8fd0
leaq 0x365c(%rip), %rsi      # 0x620a
callq 0x2160
movq %rax, %rdi
movl %r13d, %esi
callq 0x21e0
leaq 0x367b(%rip), %rsi      # 0x6240
movq %rax, %rdi
callq 0x2160
cmpl $0x2, %r12d
je 0x2c01
testl %r12d, %r12d
jne 0x2c35
andl $0x0, 0x18(%rbx)
xorl %ebx, %ebx
testb %r14b, %r14b
jne 0x2ce4
movq 0x63e2(%rip), %rdi      # 0x8fd0
leaq 0x34ed(%rip), %rsi      # 0x60e2
callq 0x2160
xorl %ebx, %ebx
jmp 0x2cdc
movl 0x1c(%r15), %esi
cmpl %esi, 0x1c(%rbx)
jle 0x2c62
pushq $0x64
popq %rsi
movq %rbx, %rdi
callq 0x2b40
testb %r14b, %r14b
jne 0x2c75
movq 0x63af(%rip), %rdi      # 0x8fd0
leaq 0x34cb(%rip), %rsi      # 0x60f3
callq 0x2160
pushq $0x64
popq %rsi
jmp 0x2cba
movl 0x1c(%r15), %esi
subl 0x1c(%rbx), %esi
jle 0x2c79
movq %rbx, %rdi
callq 0x2b40
movl $0x1, 0x18(%rbx)
testb %r14b, %r14b
jne 0x2c85
movq 0x6377(%rip), %rdi      # 0x8fd0
leaq 0x3498(%rip), %rsi      # 0x60f8
jmp 0x2cd4
subl 0x1c(%rbx), %esi
addl $0x64, %esi
movq %rbx, %rdi
callq 0x2b40
testb %r14b, %r14b
je 0x2c8a
pushq $0x2
jmp 0x2c87
movl $0x1, 0x18(%rbx)
testb %r14b, %r14b
je 0x2cc6
pushq $0x1
popq %rbx
jmp 0x2ce4
movq 0x633f(%rip), %rdi      # 0x8fd0
leaq 0x344f(%rip), %rsi      # 0x60e7
callq 0x2160
pushq $0x64
popq %rsi
movq %rax, %rdi
callq 0x21e0
leaq 0x343f(%rip), %rsi      # 0x60ee
movq %rax, %rdi
callq 0x2160
movl 0x1c(%rbx), %esi
movq %rax, %rdi
callq 0x21e0
pushq $0x2
jmp 0x2cdb
movq 0x6303(%rip), %rdi      # 0x8fd0
leaq 0x3429(%rip), %rsi      # 0x60fd
callq 0x2160
pushq $0x1
popq %rbx
movq %rax, %rdi
callq 0x20b0
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq