// File: /workspace/github_cpp_makefile_star2_O2/smallHW89[P]gobang/GoBang_ChessBoard.cpp
// Function: ChessBoard::GetMaxValue(int, long, long)
int64_t   ChessBoard::  GetMaxValue(int deep, int64_t alpha, int64_t beta)
{
    int64_t bestVa = MM_MIN;
    std::vector<StPos>   nextList;
    int64_t va = MM_MIN;
    int win = 0;
    va = CalculateBoard(m_aiside, win, false );
    if( deep <= 0  || win )
    {
        return va;
    }
    
    int n = GetPossbilePos( m_aiside, nextList);
    for( int i=0; i<nextList.size(); i++ )
    {
        PutChess(nextList[i].x, nextList[i].y, m_aiside);
        nextList[i].score = CalculateOnePos(nextList[i].x, nextList[i].y,
                m_aiside, 0);
        UnPutChess(nextList[i].x, nextList[i].y);
    }
    sort(nextList.begin(), nextList.end(), greater<StPos>()   );    

    for( int i=0; i< nextList.size(); i++ )
    {
        StPos pos = nextList[i];
        PutChess(pos.x, pos.y, m_aiside  ); 
        win = 0; 
        va =  GetMinValue(deep-1, alpha , beta);
        UnPutChess(pos.x, pos.y);
        
        if(va  >  bestVa)  
        {
            bestVa = va;
        }
        if(va >   alpha )
            alpha = va;
        if( alpha >= beta) 
            break;
    }
    return bestVa;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %r15
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r12
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
andq $0x0, -0x40(%rbp)
leaq -0x30(%rbp), %rdx
andl $0x0, (%rdx)
movsbl 0x198(%rdi), %esi
xorl %ecx, %ecx
callq 0x2970
movq %rax, %r13
movl %r14d, -0x2c(%rbp)
testl %r14d, %r14d
jle 0x316d
movq %r12, -0x58(%rbp)
movq %rbx, -0x70(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x316d
movq -0x58(%rbp), %r12
movsbl 0x198(%r12), %esi
leaq -0x50(%rbp), %rdx
movq %r12, %rdi
callq 0x274a
pushq $0x4
popq %rbx
movq -0x50(%rbp), %r13
xorl %r14d, %r14d
movq -0x48(%rbp), %rsi
movq %rsi, %rax
subq %r13, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %r14, %rax
jbe 0x30b3
movl -0x4(%r13,%rbx), %esi
movl (%r13,%rbx), %edx
movsbl 0x198(%r12), %ecx
movq %r12, %rdi
callq 0x128c
movq -0x50(%rbp), %r13
movl -0x4(%r13,%rbx), %esi
movl (%r13,%rbx), %edx
movsbl 0x198(%r12), %ecx
movq %r12, %rdi
xorl %r8d, %r8d
callq 0x2860
movq %rax, 0x4(%r13,%rbx)
movl -0x4(%r13,%rbx), %esi
movl (%r13,%rbx), %edx
movq %r12, %rdi
callq 0x12d2
incq %r14
addq $0x18, %rbx
jmp 0x303f
movq %r13, %rdi
callq 0x34ba
decl -0x2c(%rbp)
movq $-0x77359400, %r13      # imm = 0x88CA6C00
pushq $-0x1
popq %rdi
pushq $0x4
popq %rax
movq %rax, -0x68(%rbp)
movq %r15, -0x60(%rbp)
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
subq %rcx, %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
incq %rdi
cmpq %rdi, %rax
jbe 0x316d
movq %rdi, -0x78(%rbp)
movq %r13, -0x80(%rbp)
movq -0x68(%rbp), %rax
movl -0x4(%rcx,%rax), %r15d
movl (%rcx,%rax), %ebx
movq -0x58(%rbp), %r13
movsbl 0x198(%r13), %ecx
movq %r13, %rdi
movl %r15d, %esi
movl %ebx, %edx
callq 0x128c
movq -0x70(%rbp), %r12
movq %r13, %rdi
movl -0x2c(%rbp), %esi
movq %r12, %rdx
movq -0x60(%rbp), %rcx
callq 0x2de2
movq %rax, %r14
addq $0x18, -0x68(%rbp)
movq %r13, %rdi
movl %r15d, %esi
movl %ebx, %edx
callq 0x12d2
movq -0x80(%rbp), %r13
cmpq %r13, %r14
cmovgq %r14, %r13
cmpq %r12, %r14
cmovgq %r14, %r12
movq %r12, -0x70(%rbp)
movq -0x60(%rbp), %r15
cmpq %r15, %r12
movq -0x78(%rbp), %rdi
jl 0x30d3
leaq -0x50(%rbp), %rdi
callq 0x32ec
movq %r13, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x318c
jmp 0x318c
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x32ec
movq %rbx, %rdi
callq 0x1100