// File: /workspace/github_cpp_makefile_star2_O3/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, -0x68(%rbp)
movq %rdx, %r14
movl %esi, %ebx
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
leaq -0x5c(%rbp), %rdx
movl $0x0, (%rdx)
movsbl 0x198(%rdi), %esi
movq %rdi, -0x30(%rbp)
movl $0x1, %ecx
callq 0x2cba
movq %rax, %rdx
movl %ebx, -0x34(%rbp)
testl %ebx, %ebx
jle 0x3584
cmpl $0x0, -0x5c(%rbp)
jne 0x3584
movq -0x30(%rbp), %rdi
movsbl 0x199(%rdi), %esi
leaq -0x50(%rbp), %rdx
callq 0x2a1e
movq %r14, -0x78(%rbp)
movq -0x50(%rbp), %r13
movq -0x48(%rbp), %r15
movq %r15, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
subq %r13, %rax
je 0x344c
movq -0x30(%rbp), %rdi
leaq 0x4(%rdi), %rax
movq %rax, -0x58(%rbp)
movl $0x4, %r14d
xorl %ebx, %ebx
movl -0x4(%r13,%r14), %esi
movl (%r13,%r14), %edx
movsbl 0x199(%rdi), %ecx
movq %rdi, %r12
callq 0x128e
movq -0x50(%rbp), %r13
movl -0x4(%r13,%r14), %esi
movl (%r13,%r14), %edx
movsbl 0x199(%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 -0x58(%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
movq %r12, %rdi
ja 0x33b4
jmp 0x3458
sarq $0x3, %rax
imulq %rcx, %rax
movq -0x30(%rbp), %rdi
cmpq %r15, %r13
je 0x348c
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
movq -0x30(%rbp), %rdi
cmpq %r13, %r15
je 0x3565
decl -0x34(%rbp)
leaq 0x4(%rdi), %rax
movq %rax, -0x70(%rbp)
movl $0x77359400, %edx       # imm = 0x77359400
movl $0x4, %ecx
xorl %esi, %esi
movq -0x78(%rbp), %r15
movq %rsi, -0x30(%rbp)
movq %rdx, -0x58(%rbp)
movl -0x4(%r13,%rcx), %r14d
movq %rcx, -0x80(%rbp)
movl (%r13,%rcx), %r13d
movsbl 0x199(%rdi), %ecx
movq %rdi, %rbx
movl %r14d, %esi
movl %r13d, %edx
callq 0x128e
movq -0x68(%rbp), %r12
movq %rbx, %rdi
movl -0x34(%rbp), %esi
movq %r15, %rdx
movq %r12, %rcx
callq 0x35ba
movslq %r14d, %rcx
movslq %r13d, %rdx
leaq (%rcx,%rcx,4), %rcx
movq -0x70(%rbp), %rsi
leaq (%rsi,%rcx,4), %rcx
movb $0x65, (%rdx,%rcx)
addq $-0x18, 0x248(%rbx)
decl (%rbx)
movq -0x58(%rbp), %rdx
cmpq %rdx, %rax
cmovlq %rax, %rdx
cmpq %r12, %rax
cmovlq %rax, %r12
movq -0x50(%rbp), %r13
cmpq %r15, %r12
movq -0x30(%rbp), %rsi
jle 0x356a
movq %rbx, %rdi
movq %r12, -0x68(%rbp)
incq %rsi
movq -0x48(%rbp), %rax
subq %r13, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
movq -0x80(%rbp), %rcx
addq $0x18, %rcx
cmpq %rsi, %rax
ja 0x34b0
jmp 0x356a
movl $0x77359400, %edx       # imm = 0x77359400
testq %r13, %r13
je 0x3584
movq -0x40(%rbp), %rsi
subq %r13, %rsi
movq %r13, %rdi
movq %rdx, %rbx
callq 0x10a0
movq %rbx, %rdx
movq %rdx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x359a
jmp 0x359a
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x35b2
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10a0
movq %rbx, %rdi
callq 0x10e0