// File: /workspace/github_cpp_makefile_star2_O3/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, -0x70(%rbp)
movq %rdx, -0x60(%rbp)
movl %esi, %ebx
movq %rdi, %r12
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
leaq -0x54(%rbp), %rdx
movl $0x0, (%rdx)
movsbl 0x198(%rdi), %esi
xorl %ecx, %ecx
callq 0x2cba
movl %ebx, -0x34(%rbp)
testl %ebx, %ebx
jle 0x3825
cmpl $0x0, -0x54(%rbp)
jne 0x3825
movsbl 0x198(%r12), %esi
leaq -0x50(%rbp), %rdx
movq %r12, %rdi
callq 0x2a1e
movq -0x50(%rbp), %r13
movq -0x48(%rbp), %r15
movq %r15, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
subq %r13, %rax
je 0x36ef
leaq 0x4(%r12), %rax
movq %rax, -0x30(%rbp)
movl $0x4, %r14d
xorl %ebx, %ebx
movl -0x4(%r13,%r14), %esi
movl (%r13,%r14), %edx
movsbl 0x198(%r12), %ecx
movq %r12, %rdi
callq 0x128e
movq -0x50(%rbp), %r13
movl -0x4(%r13,%r14), %esi
movl (%r13,%r14), %edx
movsbl 0x198(%r12), %ecx
movq %r12, %rdi
xorl %r8d, %r8d
callq 0x2ba8
movq %rax, 0x4(%r13,%r14)
movslq -0x4(%r13,%r14), %rax
movslq (%r13,%r14), %rcx
leaq (%rax,%rax,4), %rax
movq -0x30(%rbp), %rdx
leaq (%rdx,%rax,4), %rax
movb $0x65, (%rcx,%rax)
addq $-0x18, 0x248(%r12)
decl (%r12)
incq %rbx
movq -0x48(%rbp), %r15
movq %r15, %rax
subq %r13, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
addq $0x18, %r14
cmpq %rbx, %rax
ja 0x3658
jmp 0x36f7
sarq $0x3, %rax
imulq %rcx, %rax
cmpq %r15, %r13
je 0x3727
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x3b0e
movq %r13, %rdi
movq %r15, %rsi
callq 0x3c39
movq -0x50(%rbp), %r13
movq -0x48(%rbp), %r15
cmpq %r13, %r15
je 0x3805
decl -0x34(%rbp)
leaq 0x4(%r12), %rax
movq %rax, -0x68(%rbp)
movq $-0x77359400, -0x30(%rbp) # imm = 0x88CA6C00
movl $0x4, %edx
xorl %esi, %esi
movq -0x70(%rbp), %r14
movq %rsi, -0x80(%rbp)
movl -0x4(%r13,%rdx), %ebx
movq %rdx, -0x78(%rbp)
movl (%r13,%rdx), %r13d
movsbl 0x198(%r12), %ecx
movq %r12, %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x128e
movq -0x60(%rbp), %r15
movq %r12, %rdi
movl -0x34(%rbp), %esi
movq %r15, %rdx
movq %r14, %rcx
callq 0x330a
movslq %ebx, %rcx
movslq %r13d, %rdx
leaq (%rcx,%rcx,4), %rcx
movq -0x68(%rbp), %rsi
leaq (%rsi,%rcx,4), %rcx
movb $0x65, (%rdx,%rcx)
addq $-0x18, 0x248(%r12)
decl (%r12)
movq -0x30(%rbp), %rdx
cmpq %rdx, %rax
cmovgq %rax, %rdx
movq %rdx, -0x30(%rbp)
cmpq %r15, %rax
cmovgq %rax, %r15
movq -0x50(%rbp), %r13
cmpq %r14, %r15
movq -0x80(%rbp), %rsi
jge 0x380d
movq %r15, -0x60(%rbp)
incq %rsi
movq -0x48(%rbp), %rax
subq %r13, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rax
movq -0x78(%rbp), %rdx
addq $0x18, %rdx
cmpq %rsi, %rax
ja 0x374f
jmp 0x380d
movq $-0x77359400, -0x30(%rbp) # imm = 0x88CA6C00
testq %r13, %r13
je 0x3821
movq -0x40(%rbp), %rsi
subq %r13, %rsi
movq %r13, %rdi
callq 0x10a0
movq -0x30(%rbp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3838
jmp 0x3838
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x3850
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10a0
movq %rbx, %rdi
callq 0x10e0