// File: /workspace/github_cpp_makefile_star2_O1/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, -0x60(%rbp)
movq %rdx, -0x68(%rbp)
movl %esi, %ebx
movq %rdi, %r12
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
leaq -0x2c(%rbp), %rdx
movl $0x0, (%rdx)
movsbl 0x198(%rdi), %esi
movl $0x1, %ecx
callq 0x2d14
movq %rax, %r14
movl %ebx, -0x30(%rbp)
testl %ebx, %ebx
jle 0x35eb
cmpl $0x0, -0x2c(%rbp)
jne 0x35eb
movsbl 0x199(%r12), %esi
leaq -0x50(%rbp), %rdx
movq %r12, %rdi
callq 0x2a7c
movq -0x50(%rbp), %r13
movq -0x48(%rbp), %r15
movq %r15, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
subq %r13, %rax
je 0x34c5
leaq 0x4(%r12), %rax
movq %rax, -0x58(%rbp)
movl $0x4, %r14d
xorl %ebx, %ebx
movl -0x4(%r13,%r14), %esi
movl (%r13,%r14), %edx
movsbl 0x199(%r12), %ecx
movq %r12, %rdi
callq 0x128e
movq -0x50(%rbp), %r15
movl -0x4(%r15,%r14), %esi
movl (%r15,%r14), %edx
movsbl 0x199(%r12), %ecx
movq %r12, %rdi
xorl %r8d, %r8d
callq 0x2c02
movq %rax, 0x4(%r15,%r14)
movslq -0x4(%r15,%r14), %rax
movslq (%r15,%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 -0x50(%rbp), %r13
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 0x342c
jmp 0x34cd
sarq $0x3, %rax
imulq %rcx, %rax
cmpq %r15, %r13
je 0x34f5
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x3bb0
movq %r13, %rdi
movq %r15, %rsi
callq 0x3cdb
movl -0x2c(%rbp), %ebx
movq -0x50(%rbp), %rax
cmpq %rax, -0x48(%rbp)
je 0x35de
decl -0x30(%rbp)
leaq 0x4(%r12), %rcx
movq %rcx, -0x70(%rbp)
movl $0x77359400, %r14d      # imm = 0x77359400
movl $0x4, %esi
xorl %edi, %edi
movq %rdi, -0x80(%rbp)
movq %r14, -0x58(%rbp)
movl -0x4(%rax,%rsi), %r15d
movq %rsi, -0x78(%rbp)
movl (%rax,%rsi), %r14d
movsbl 0x199(%r12), %ecx
movq %r12, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x128e
movq -0x60(%rbp), %r13
movq -0x68(%rbp), %rdx
xorl %ebx, %ebx
movq %r12, %rdi
movl -0x30(%rbp), %esi
movq %r13, %rcx
callq 0x363c
movq -0x68(%rbp), %rdi
movslq %r15d, %rcx
movslq %r14d, %rdx
leaq (%rcx,%rcx,4), %rcx
movq -0x70(%rbp), %rsi
leaq (%rsi,%rcx,4), %rcx
movb $0x65, (%rdx,%rcx)
addq $-0x18, 0x248(%r12)
decl (%r12)
movq -0x58(%rbp), %r14
cmpq %r14, %rax
cmovlq %rax, %r14
cmpq %r13, %rax
cmovlq %rax, %r13
cmpq %rdi, %r13
movq -0x80(%rbp), %rdi
jle 0x35e6
movq %r13, -0x60(%rbp)
incq %rdi
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rcx
movq -0x78(%rbp), %rsi
addq $0x18, %rsi
xorl %ebx, %ebx
cmpq %rdi, %rcx
ja 0x351f
jmp 0x35e8
movl $0x77359400, %r14d      # imm = 0x77359400
jmp 0x35e8
xorl %ebx, %ebx
movl %ebx, -0x2c(%rbp)
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x3600
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10a0
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3614
movq %rax, %r14
jmp 0x361f
movq %rax, %r14
movl %ebx, -0x2c(%rbp)
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x3634
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10a0
movq %r14, %rdi
callq 0x10e0