// File: /workspace/github_cpp_makefile_star2_O3/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 0x3007
movl %edx, %r13d
movq 0x6ffd(%rip), %rdi      # 0x9fd0
leaq 0x4230(%rip), %rsi      # 0x720a
movl $0x7, %edx
callq 0x2150
movq 0x6fe5(%rip), %rdi      # 0x9fd0
movl %r13d, %esi
callq 0x21b0
leaq 0x4246(%rip), %rsi      # 0x7240
movl $0x2, %edx
movq %rax, %rdi
callq 0x2150
cmpl $0x2, %r12d
je 0x304c
testl %r12d, %r12d
jne 0x30ad
movl $0x0, 0x18(%rbx)
xorl %r15d, %r15d
testb %r14b, %r14b
jne 0x31d0
movq 0x6fa0(%rip), %rbx      # 0x9fd0
leaq 0x40ab(%rip), %rsi      # 0x70e2
movl $0x4, %edx
movq %rbx, %rdi
callq 0x2150
xorl %r15d, %r15d
jmp 0x31a9
movl 0x1c(%r15), %ecx
movl 0x1c(%rbx), %eax
cmpl %ecx, %eax
jle 0x30cb
movl 0x10(%rbx), %ecx
xorl %edx, %edx
cmpl $0x65, %ecx
jl 0x306c
addl $-0x64, %ecx
addl $0x64, %eax
movl %eax, 0x1c(%rbx)
movl %ecx, %edx
movl %edx, 0x10(%rbx)
movl $0x2, 0x18(%rbx)
movl $0x2, %r15d
testb %r14b, %r14b
jne 0x31d0
movq 0x6f44(%rip), %rbx      # 0x9fd0
leaq 0x4060(%rip), %rsi      # 0x70f3
movl $0x4, %edx
movq %rbx, %rdi
callq 0x2150
movq %rbx, %rdi
movl $0x64, %esi
jmp 0x316d
movl 0x1c(%r15), %ecx
movl 0x1c(%rbx), %eax
subl %ecx, %eax
jge 0x30df
addl 0x10(%rbx), %eax
testl %eax, %eax
jle 0x3177
movl %ecx, 0x1c(%rbx)
jmp 0x3179
subl 0x1c(%rbx), %ecx
addl $0x64, %ecx
movl 0x10(%rbx), %edx
subl %ecx, %edx
jle 0x310d
addl %eax, %ecx
movl %ecx, 0x1c(%rbx)
jmp 0x310f
movl $0x1, 0x18(%rbx)
movl $0x1, %r15d
testb %r14b, %r14b
jne 0x31d0
movq 0x6ed4(%rip), %rbx      # 0x9fd0
leaq 0x3ffa(%rip), %rsi      # 0x70fd
movl $0x5, %edx
jmp 0x31a1
xorl %edx, %edx
movl %edx, 0x10(%rbx)
movl $0x2, 0x18(%rbx)
movl $0x2, %r15d
testb %r14b, %r14b
jne 0x31d0
movq 0x6ea1(%rip), %r14      # 0x9fd0
leaq 0x3fb1(%rip), %rsi      # 0x70e7
movl $0x6, %edx
movq %r14, %rdi
callq 0x2150
movq %r14, %rdi
movl $0x64, %esi
callq 0x21b0
movq %rax, %r14
leaq 0x3f94(%rip), %rsi      # 0x70ee
movl $0x4, %edx
movq %rax, %rdi
callq 0x2150
movl 0x1c(%rbx), %esi
movq %r14, %rdi
callq 0x21b0
movq %rax, %rbx
jmp 0x31a9
xorl %eax, %eax
movl %eax, 0x10(%rbx)
movl $0x1, 0x18(%rbx)
movl $0x1, %r15d
testb %r14b, %r14b
jne 0x31d0
movq 0x6e3b(%rip), %rbx      # 0x9fd0
leaq 0x3f5c(%rip), %rsi      # 0x70f8
movl $0x4, %edx
movq %rbx, %rdi
callq 0x2150
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2090
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq