// File: smallHW89[P]gobang/GoBang_ChessBoard.cpp
// Function: ChessBoard::IsOpen3(char*, int, int, int&, int&)
bool ChessBoard::IsOpen3(char oneLine[], int len, int pos, int &resL ,int &resR)
{
    char side = oneLine[pos];
    if( Chess_Empty == side  )
        return  false;
    if( pos > len || pos<0 )
        return false;
    if( side != oneLine[pos])
        return false;

    int ri =pos, li=pos;
    int rr =pos, ll=pos;
    while( oneLine[li-1] == side )  li--;
    while( oneLine[ri+1] == side )  ri++;
    rr = ri; ll = li; 
    while( oneLine[ll-1] == Chess_Empty || oneLine[ll-1] == side ) ll--;
    while( oneLine[rr+1] == Chess_Empty || oneLine[rr+1] == side ) rr++;

    if(rr - ll +1 < 5)
        return false;

    int cnt = 0;
    //向左尝试放3个
    int kk=0, ii=0, rL = 0, rR = 0;
    for( kk = ri ; kk>=ll && ii<4 ; kk--, ii++)
    {
        if (oneLine[kk] != Chess_Empty)
            continue;
        oneLine[kk] = side;

        bool res = IsOpen4(oneLine,len ,pos, rL, rR );
        if(res )
            cnt++;
        oneLine[kk] = Chess_Empty;
    }
    //向右3个
    ii=0;
    for( kk = li ; kk<=rr  && ii<4 ; kk++, ii++ )
    {
        if (oneLine[kk] != Chess_Empty)
            continue;
        oneLine[kk] = side;

        bool res = IsOpen4(oneLine,len ,pos, rL, rR );
        if(res )
            cnt++;
        oneLine[kk] = Chess_Empty;
    }
    if(cnt > 0 )
    {
        resL = li;
        resR = ri;
        return true;
    }

    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x31(%rbp)
movsbl -0x31(%rbp), %ecx
movl $0x65, %eax
cmpl %ecx, %eax
jne 0x1f4a
movb $0x0, -0x1(%rbp)
jmp 0x221b
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x1f58
cmpl $0x0, -0x20(%rbp)
jge 0x1f61
movb $0x0, -0x1(%rbp)
jmp 0x221b
movsbl -0x31(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x20(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x1f7e
movb $0x0, -0x1(%rbp)
jmp 0x221b
movl -0x20(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movsbl -0x31(%rbp), %ecx
cmpl %ecx, %eax
jne 0x1fba
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1f96
jmp 0x1fbc
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movsbl -0x31(%rbp), %ecx
cmpl %ecx, %eax
jne 0x1fe0
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1fbc
movl -0x38(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
movl -0x44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %ecx
movb $0x1, %al
cmpl $0x65, %ecx
movb %al, -0x69(%rbp)
je 0x2024
movq -0x18(%rbp), %rax
movl -0x44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movsbl -0x31(%rbp), %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x202d
jmp 0x2038
movl -0x44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1fec
jmp 0x203a
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %ecx
movb $0x1, %al
cmpl $0x65, %ecx
movb %al, -0x6a(%rbp)
je 0x2072
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movsbl -0x31(%rbp), %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x6a(%rbp)
movb -0x6a(%rbp), %al
testb $0x1, %al
jne 0x207b
jmp 0x2086
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x203a
movl -0x40(%rbp), %eax
subl -0x44(%rbp), %eax
addl $0x1, %eax
cmpl $0x5, %eax
jge 0x209d
movb $0x0, -0x1(%rbp)
jmp 0x221b
movl $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x44(%rbp), %ecx
movb %al, -0x6b(%rbp)
jl 0x20dd
cmpl $0x4, -0x50(%rbp)
setl %al
movb %al, -0x6b(%rbp)
movb -0x6b(%rbp), %al
testb $0x1, %al
jne 0x20e6
jmp 0x2159
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x65, %eax
je 0x20f9
jmp 0x2142
movq -0x68(%rbp), %rdi
movb -0x31(%rbp), %dl
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq -0x54(%rbp), %r8
leaq -0x58(%rbp), %r9
callq 0x1990
andb $0x1, %al
movb %al, -0x59(%rbp)
testb $0x1, -0x59(%rbp)
je 0x2136
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb $0x65, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x20c6
movl $0x0, -0x50(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x40(%rbp), %ecx
movb %al, -0x6c(%rbp)
jg 0x217d
cmpl $0x4, -0x50(%rbp)
setl %al
movb %al, -0x6c(%rbp)
movb -0x6c(%rbp), %al
testb $0x1, %al
jne 0x2186
jmp 0x21f9
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x65, %eax
je 0x2199
jmp 0x21e2
movq -0x68(%rbp), %rdi
movb -0x31(%rbp), %dl
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq -0x54(%rbp), %r8
leaq -0x58(%rbp), %r9
callq 0x1990
andb $0x1, %al
movb %al, -0x5a(%rbp)
testb $0x1, -0x5a(%rbp)
je 0x21d6
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb $0x65, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x2166
cmpl $0x0, -0x48(%rbp)
jle 0x2217
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x38(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0x221b
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)