// File: /workspace/github_cpp_makefile_star2_O1/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 0x2f17
movl %edx, %r13d
movq 0x70ed(%rip), %rdi      # 0x9fd0
leaq 0x4320(%rip), %rsi      # 0x720a
movl $0x7, %edx
callq 0x2150
movq 0x70d5(%rip), %rdi      # 0x9fd0
movl %r13d, %esi
callq 0x21b0
leaq 0x4336(%rip), %rsi      # 0x7240
movl $0x2, %edx
movq %rax, %rdi
callq 0x2150
cmpl $0x2, %r12d
je 0x2f58
testl %r12d, %r12d
jne 0x2f82
movl $0x0, 0x18(%rbx)
xorl %r15d, %r15d
testb %r14b, %r14b
jne 0x3110
movq 0x7094(%rip), %rbx      # 0x9fd0
leaq 0x419f(%rip), %rsi      # 0x70e2
movl $0x4, %edx
movq %rbx, %rdi
callq 0x2150
xorl %r15d, %r15d
jmp 0x30e9
movl 0x1c(%r15), %ecx
movl 0x1c(%rbx), %eax
cmpl %ecx, %eax
jle 0x2fa8
movl 0x10(%rbx), %ecx
cmpl $0x64, %ecx
jg 0x2ffb
movl $0x0, 0x10(%rbx)
movl $0x2, 0x18(%rbx)
jmp 0x300e
movl 0x1c(%r15), %eax
subl 0x1c(%rbx), %eax
jle 0x2fcd
movl 0x10(%rbx), %ecx
subl %eax, %ecx
jle 0x30ae
movl %ecx, 0x10(%rbx)
movl $0x2, 0x18(%rbx)
addl %eax, 0x1c(%rbx)
jmp 0x30bc
subl 0x1c(%rbx), %ecx
addl $0x64, %ecx
movl 0x10(%rbx), %edx
subl %ecx, %edx
jle 0x3042
movl %edx, 0x10(%rbx)
addl %eax, %ecx
movl $0x2, 0x18(%rbx)
movl %ecx, 0x1c(%rbx)
jmp 0x3050
movl $0x1, 0x18(%rbx)
movl $0x1, %r15d
testb %r14b, %r14b
jne 0x3110
movq 0x6fe6(%rip), %rbx      # 0x9fd0
leaq 0x410c(%rip), %rsi      # 0x70fd
movl $0x5, %edx
jmp 0x30e1
addl $-0x64, %ecx
movl %ecx, 0x10(%rbx)
addl $0x64, %eax
movl $0x2, 0x18(%rbx)
movl %eax, 0x1c(%rbx)
movl $0x2, %r15d
testb %r14b, %r14b
jne 0x3110
movq 0x6fac(%rip), %rbx      # 0x9fd0
leaq 0x40c8(%rip), %rsi      # 0x70f3
movl $0x4, %edx
movq %rbx, %rdi
callq 0x2150
movq %rbx, %rdi
movl $0x64, %esi
jmp 0x30a4
movl $0x0, 0x10(%rbx)
movl $0x2, 0x18(%rbx)
movl $0x2, %r15d
testb %r14b, %r14b
jne 0x3110
movq 0x6f6a(%rip), %r14      # 0x9fd0
leaq 0x407a(%rip), %rsi      # 0x70e7
movl $0x6, %edx
movq %r14, %rdi
callq 0x2150
movq %r14, %rdi
movl $0x64, %esi
callq 0x21b0
movq %rax, %r14
leaq 0x405d(%rip), %rsi      # 0x70ee
movl $0x4, %edx
movq %rax, %rdi
callq 0x2150
movl 0x1c(%rbx), %esi
movq %r14, %rdi
callq 0x21b0
movq %rax, %rbx
jmp 0x30e9
movl $0x0, 0x10(%rbx)
movl $0x2, 0x18(%rbx)
movl $0x1, 0x18(%rbx)
movl $0x1, %r15d
testb %r14b, %r14b
jne 0x3110
movq 0x6efb(%rip), %rbx      # 0x9fd0
leaq 0x401c(%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