// File: /workspace/github_cpp_makefile_star2_O1/SethKasmann[P]clever-girl/src/move_generator.cpp
// Function: void MoveList::pushCastle<(MoveType)4>()
void MoveList::pushCastle()
{
    Square k = mState.getKingSquare(mState.getOurColor());

    if (mState.canCastleKingside() &&
        !(between_hor[k][k-3] & mState.getOccupancyBB()) &&
        !mState.attacked(k-1) && 
        !mState.attacked(k-2)) 
    {
        if (T == MoveType::QuietChecks)
        {
            if (square_bb[k-1] & mState.getCheckSquaresBB(rook))
                push(makeCastle(k, k-2));
        }
        else
            push(makeCastle(k, k-2));
    }

    if (mState.canCastleQueenside() && 
        !(between_hor[k][k+4] & mState.getOccupancyBB()) && 
        !mState.attacked(k+1) && 
        !mState.attacked(k+2))
    {
        if (T == MoveType::QuietChecks)
        {
            if (square_bb[k+1] & mState.getCheckSquaresBB(rook))
                push(makeCastle(k, k+2));
        }
        else
            push(makeCastle(k, k+2));
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x18(%rdi), %rdx
movl (%rdx), %esi
xorl %ecx, %ecx
testq %rsi, %rsi
setne %cl
imulq $0xf0, %rsi, %rax
movl 0x3f0(%rdx,%rax), %eax
leal (%rcx,%rcx,2), %ecx
incl %ecx
testl %ecx, 0xc(%rdx)
je 0x11f92
leal -0x3(%rax), %ecx
movq %rax, %r9
shlq $0x9, %r9
addq 0x131df(%rip), %r9      # 0x24fc0
movq 0x80(%rdx), %r8
orq 0x78(%rdx), %r8
testq %r8, (%r9,%rcx,8)
jne 0x11f92
leal -0x1(%rax), %r15d
movq %rsi, %r11
shlq $0x9, %r11
addq 0x131a8(%rip), %r11     # 0x24fb0
movl 0x4(%rdx), %ecx
leaq (%rcx,%rcx,2), %r9
shlq $0x4, %r9
movq 0x288(%rdx,%r9), %rbx
testq %rbx, (%r11,%r15,8)
jne 0x11f92
leaq 0x288(%rdx), %r10
leaq 0x9d0d(%rip), %r14      # 0x1bb40
movq 0x8(%r10,%r9), %rcx
testq %rcx, (%r14,%r15,8)
jne 0x11f92
leaq 0x133c7(%rip), %rcx     # 0x25210
leaq 0x99f0(%rip), %r12      # 0x1b840
movq (%r12,%r15,8), %rbp
andq %r8, %rbp
leaq 0x97e2(%rip), %r12      # 0x1b640
imulq (%r12,%r15,8), %rbp
movq (%rcx,%r15,8), %r12
leaq 0x96d2(%rip), %rcx      # 0x1b540
movb (%rcx,%r15,4), %cl
shrq %cl, %rbp
movq 0x20(%r10,%r9), %r13
movq 0x10(%r10,%r9), %rcx
orq %r13, %rcx
testq %rcx, (%r12,%rbp,8)
jne 0x11f92
leaq 0x1357d(%rip), %rcx     # 0x25410
movq (%rcx,%r15,8), %r12
leaq 0x94a2(%rip), %rcx      # 0x1b340
movq (%rcx,%r15,8), %rbp
andq %r8, %rbp
leaq 0x9294(%rip), %rcx      # 0x1b140
imulq (%rcx,%r15,8), %rbp
leaq 0x9188(%rip), %rcx      # 0x1b040
movb (%rcx,%r15,4), %cl
shrq %cl, %rbp
orq 0x18(%r10,%r9), %r13
testq %r13, (%r12,%rbp,8)
jne 0x11f92
leal -0x2(%rax), %r15d
testq %rbx, (%r11,%r15,8)
jne 0x11f92
movq 0x8(%r10,%r9), %rcx
testq %rcx, (%r14,%r15,8)
jne 0x11f92
leaq 0x1331e(%rip), %rcx     # 0x25210
movq (%rcx,%r15,8), %rbx
leaq 0x9943(%rip), %rcx      # 0x1b840
movq (%rcx,%r15,8), %r14
andq %r8, %r14
leaq 0x9735(%rip), %rcx      # 0x1b640
imulq (%rcx,%r15,8), %r14
leaq 0x9629(%rip), %rcx      # 0x1b540
movb (%rcx,%r15,4), %cl
shrq %cl, %r14
movq 0x20(%r10,%r9), %r11
movq 0x10(%r10,%r9), %rcx
orq %r11, %rcx
testq %rcx, (%rbx,%r14,8)
jne 0x11f92
leaq 0x9408(%rip), %rcx      # 0x1b340
andq (%rcx,%r15,8), %r8
leaq 0x134cd(%rip), %rcx     # 0x25410
movq (%rcx,%r15,8), %rbx
leaq 0x91f2(%rip), %rcx      # 0x1b140
imulq (%rcx,%r15,8), %r8
leaq 0x90e6(%rip), %rcx      # 0x1b040
movb (%rcx,%r15,4), %cl
shrq %cl, %r8
orq 0x18(%r10,%r9), %r11
testq %r11, (%rbx,%r8,8)
jne 0x11f92
shll $0x6, %r15d
orl %eax, %r15d
orl $0x8000, %r15d          # imm = 0x8000
movq 0x848(%rdi), %rcx
leaq 0x1(%rcx), %r8
movq %r8, 0x848(%rdi)
movw %r15w, 0x30(%rdi,%rcx,8)
testq %rsi, %rsi
movl $0x2, %ecx
movl $0x8, %r8d
cmovel %ecx, %r8d
testl %r8d, 0xc(%rdx)
je 0x12164
leal 0x4(%rax), %ecx
movq %rax, %r9
shlq $0x9, %r9
addq 0x13001(%rip), %r9      # 0x24fc0
movq 0x80(%rdx), %r8
orq 0x78(%rdx), %r8
testq %r8, (%r9,%rcx,8)
jne 0x12164
leal 0x1(%rax), %r11d
shlq $0x9, %rsi
addq 0x12fcd(%rip), %rsi     # 0x24fb0
movl 0x4(%rdx), %ecx
leaq (%rcx,%rcx,2), %r9
shlq $0x4, %r9
movq 0x288(%rdx,%r9), %r10
testq %r10, (%rsi,%r11,8)
jne 0x12164
addq $0x288, %rdx            # imm = 0x288
leaq 0x9b32(%rip), %rbx      # 0x1bb40
movq 0x8(%rdx,%r9), %rcx
testq %rcx, (%rbx,%r11,8)
jne 0x12164
leaq 0x131ec(%rip), %rcx     # 0x25210
leaq 0x9815(%rip), %r14      # 0x1b840
movq (%r14,%r11,8), %r14
andq %r8, %r14
leaq 0x9607(%rip), %r12      # 0x1b640
imulq (%r12,%r11,8), %r14
movq (%rcx,%r11,8), %r15
leaq 0x94f7(%rip), %rbp      # 0x1b540
movb (%rbp,%r11,4), %cl
shrq %cl, %r14
movq 0x20(%rdx,%r9), %r13
movq 0x10(%rdx,%r9), %rcx
orq %r13, %rcx
testq %rcx, (%r15,%r14,8)
jne 0x12164
leaq 0x133a1(%rip), %rcx     # 0x25410
movq (%rcx,%r11,8), %r14
leaq 0x92c6(%rip), %rcx      # 0x1b340
movq (%rcx,%r11,8), %r15
andq %r8, %r15
leaq 0x90b8(%rip), %rcx      # 0x1b140
imulq (%rcx,%r11,8), %r15
leaq 0x8fac(%rip), %rcx      # 0x1b040
movb (%rcx,%r11,4), %cl
shrq %cl, %r15
orq 0x18(%rdx,%r9), %r13
testq %r13, (%r14,%r15,8)
jne 0x12164
movl %eax, %r11d
addl $0x2, %r11d
testq %r10, (%rsi,%r11,8)
jne 0x12164
movq 0x8(%rdx,%r9), %rcx
testq %rcx, (%rbx,%r11,8)
jne 0x12164
leaq 0x1313f(%rip), %rcx     # 0x25210
movq (%rcx,%r11,8), %r10
leaq 0x9764(%rip), %rcx      # 0x1b840
movq (%rcx,%r11,8), %rbx
andq %r8, %rbx
imulq (%r12,%r11,8), %rbx
movb (%rbp,%r11,4), %cl
shrq %cl, %rbx
movq 0x20(%rdx,%r9), %rsi
movq 0x10(%rdx,%r9), %rcx
orq %rsi, %rcx
testq %rcx, (%r10,%rbx,8)
jne 0x12164
leaq 0x9236(%rip), %rcx      # 0x1b340
andq (%rcx,%r11,8), %r8
leaq 0x132fb(%rip), %rcx     # 0x25410
movq (%rcx,%r11,8), %r10
leaq 0x9020(%rip), %rcx      # 0x1b140
imulq (%rcx,%r11,8), %r8
leaq 0x8f14(%rip), %rcx      # 0x1b040
movb (%rcx,%r11,4), %cl
shrq %cl, %r8
orq 0x18(%rdx,%r9), %rsi
testq %rsi, (%r10,%r8,8)
jne 0x12164
shll $0x6, %r11d
orl %eax, %r11d
orl $0x8000, %r11d          # imm = 0x8000
movq 0x848(%rdi), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x848(%rdi)
movw %r11w, 0x30(%rdi,%rax,8)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop