// File: smallHW89[P]gobang/GoBang_ChessBoard.cpp
// Function: ChessBoard::IsSide1(char*, int, int, int&, int&)
bool ChessBoard::IsSide1(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;
    if( rr==ri && ll < li ) 
        return true;
    if( ll == li && rr > ri ) 
        return true;

    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
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 -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 0x2f2e
movb $0x0, -0x1(%rbp)
jmp 0x30ae
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x2f3c
cmpl $0x0, -0x20(%rbp)
jge 0x2f45
movb $0x0, -0x1(%rbp)
jmp 0x30ae
movsbl -0x31(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x20(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x2f62
movb $0x0, -0x1(%rbp)
jmp 0x30ae
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 0x2f9e
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2f7a
jmp 0x2fa0
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 0x2fc4
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x2fa0
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, -0x45(%rbp)
je 0x3008
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, -0x45(%rbp)
movb -0x45(%rbp), %al
testb $0x1, %al
jne 0x3011
jmp 0x301c
movl -0x44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x2fd0
jmp 0x301e
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, -0x46(%rbp)
je 0x3056
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, -0x46(%rbp)
movb -0x46(%rbp), %al
testb $0x1, %al
jne 0x305f
jmp 0x306a
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x301e
movl -0x40(%rbp), %eax
subl -0x44(%rbp), %eax
addl $0x1, %eax
cmpl $0x5, %eax
jge 0x307e
movb $0x0, -0x1(%rbp)
jmp 0x30ae
movl -0x40(%rbp), %eax
cmpl -0x38(%rbp), %eax
jne 0x3094
movl -0x44(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x3094
movb $0x1, -0x1(%rbp)
jmp 0x30ae
movl -0x44(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x30aa
movl -0x40(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x30aa
movb $0x1, -0x1(%rbp)
jmp 0x30ae
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
popq %rbp
retq
nopw %cs:(%rax,%rax)