// File: /workspace/github_cpp_makefile_star2_O2/smallHW89[P]gobang/GoBang_ChessBoard.cpp
// Function: ChessBoard::GetMinValue(int, long, long)
int64_t   ChessBoard::  GetMinValue(int deep, int64_t alpha, int64_t  beta)
{
    int64_t bestVa = MM_MAX;
    std::vector<StPos>   nextList;
    int64_t va = MM_MAX;
    int win = 0;
    va = CalculateBoard(m_aiside, win , true);
    if( deep <= 0  || win )
    {
        return va;
    }
    
    int n = GetPossbilePos( m_otherside, nextList);
    for( int i=0; i<nextList.size(); i++ )
    {
        PutChess(nextList[i].x, nextList[i].y , m_otherside);
        nextList[i].score = CalculateOnePos(nextList[i].x, nextList[i].y,
                m_otherside, 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_otherside  ); 
        win = 0; 
        va =  GetMaxValue(deep-1, alpha, beta);
        UnPutChess(pos.x, pos.y);
        
        if(va  <  bestVa)  
        {
            bestVa = va;
        }
        if(va <   beta )
            beta = 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 -0x34(%rbp), %rdx
andl $0x0, (%rdx)
movsbl 0x198(%rdi), %esi
pushq $0x1
popq %rcx
callq 0x2970
movq %rax, %r13
movl %r14d, -0x2c(%rbp)
testl %r14d, %r14d
jle 0x2f88
movq %r12, -0x58(%rbp)
movq %rbx, -0x68(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x2f88
movq -0x58(%rbp), %r12
movsbl 0x199(%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 0x2eda
movl -0x4(%r13,%rbx), %esi
movl (%r13,%rbx), %edx
movsbl 0x199(%r12), %ecx
movq %r12, %rdi
callq 0x128c
movq -0x50(%rbp), %r13
movl -0x4(%r13,%rbx), %esi
movl (%r13,%rbx), %edx
movsbl 0x199(%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 0x2e66
movq %r13, %rdi
callq 0x34ba
decl -0x2c(%rbp)
movl $0x77359400, %r13d      # imm = 0x77359400
pushq $-0x1
popq %rdi
pushq $0x4
popq %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %r14
movq -0x68(%rbp), %r12
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
subq %rcx, %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
incq %rdi
cmpq %rdi, %rax
jbe 0x2f88
movq %rdi, -0x70(%rbp)
movq %r13, -0x78(%rbp)
movq -0x60(%rbp), %rax
movl -0x4(%rcx,%rax), %r13d
movl (%rcx,%rax), %edx
movsbl 0x199(%r14), %ecx
movq %r14, %rdi
movl %r13d, %esi
movl %edx, -0x30(%rbp)
callq 0x128c
movq %r14, %rdi
movl -0x2c(%rbp), %esi
movq %r12, %rdx
movq %r15, %rcx
callq 0x2fbc
movq %rax, %rbx
addq $0x18, -0x60(%rbp)
movq %r14, %rdi
movl %r13d, %esi
movl -0x30(%rbp), %edx
callq 0x12d2
movq -0x78(%rbp), %r13
cmpq %r13, %rbx
cmovlq %rbx, %r13
cmpq %r15, %rbx
cmovlq %rbx, %r15
cmpq %r12, %r15
movq -0x70(%rbp), %rdi
jg 0x2efd
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 0x2fa7
jmp 0x2fa7
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x32ec
movq %rbx, %rdi
callq 0x1100
nop