// File: smallHW89[P]gobang/GoBang_ChessBoard.cpp
// Function: ChessBoard::CalculatePosRight(int, int, char)
BoardType  ChessBoard:: CalculatePosRight(int x, int y, ChessSide side)
{
   if( x==0 || y== 0 || x > m_size || y> m_size )  
        return 0;
   char line[30];
   int kk = 0;
   int pos = 0;
   if( x + y <= m_size+2 )  // (x+y,0), (x+y-1, 1) .....
   {
        int xx = x+y;
        int yy = 0;
        for( kk=0; xx >= 0 ; kk++,yy++ , xx--  )
        {
            line[kk] = m_board[xx][yy];
            if( xx == x )
                pos = kk;
        }
   }
   else  //(m_size+2 , y-(m_size+2-x) ), ....( y+x - (m-size-2)   ,  m_size+2)
   {
       int xx = m_size+2;
       int yy = y+x - m_size-2; 
       for(kk=0; yy<=m_size+2 && xx>=0;  xx--, yy++ , kk++ )
       {
            line[kk] = m_board[xx][yy]; 
            if( xx ==  x)
                pos = kk;
       }
   }
   int rr, rl;
   return CalculateLine( line, m_size+2, pos,rl, rr );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %cl, %al
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x3609
cmpl $0x0, -0x18(%rbp)
je 0x3609
movq -0x68(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x194(%rcx), %eax
jg 0x3609
movq -0x68(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x194(%rcx), %eax
jle 0x3615
movl $0x0, -0x4(%rbp)
jmp 0x3775
movq -0x68(%rbp), %rcx
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x14(%rbp), %eax
addl -0x18(%rbp), %eax
movl 0x194(%rcx), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jg 0x36ab
movl -0x14(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x44(%rbp)
cmpl $0x0, -0x4c(%rbp)
jl 0x36a6
movq -0x68(%rbp), %rax
addq $0x4, %rax
movslq -0x4c(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movslq -0x50(%rbp), %rcx
movb (%rax,%rcx), %cl
movslq -0x44(%rbp), %rax
movb %cl, -0x40(%rbp,%rax)
movl -0x4c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x3687
movl -0x44(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0x3689
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x3651
jmp 0x3751
movq -0x68(%rbp), %rcx
movl 0x194(%rcx), %eax
addl $0x2, %eax
movl %eax, -0x54(%rbp)
movl -0x18(%rbp), %eax
addl -0x14(%rbp), %eax
subl 0x194(%rcx), %eax
subl $0x2, %eax
movl %eax, -0x58(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x68(%rbp), %rax
movl -0x58(%rbp), %ecx
movl 0x194(%rax), %edx
addl $0x2, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x69(%rbp)
jg 0x36f7
cmpl $0x0, -0x54(%rbp)
setge %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x3700
jmp 0x374f
movq -0x68(%rbp), %rax
addq $0x4, %rax
movslq -0x54(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movslq -0x58(%rbp), %rcx
movb (%rax,%rcx), %cl
movslq -0x44(%rbp), %rax
movb %cl, -0x40(%rbp,%rax)
movl -0x54(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x3730
movl -0x44(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0x3732
movl -0x54(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x36d4
jmp 0x3751
movq -0x68(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movl 0x194(%rdi), %edx
addl $0x2, %edx
movl -0x48(%rbp), %ecx
leaq -0x60(%rbp), %r8
leaq -0x5c(%rbp), %r9
callq 0x30c0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nop