// File: /workspace/github_cpp_makefile_star2_O3/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), %rsi
movl (%rsi), %edx
movl 0xc(%rsi), %r8d
xorl %ecx, %ecx
testq %rdx, %rdx
setne %cl
imulq $0xf0, %rdx, %rax
movl 0x3f0(%rsi,%rax), %eax
leal (%rcx,%rcx,2), %ecx
incl %ecx
testl %r8d, %ecx
je 0x11ed3
leal -0x3(%rax), %ecx
movq %rax, %r10
shlq $0x9, %r10
addq 0x132bd(%rip), %r10     # 0x24fc0
movq 0x80(%rsi), %r9
orq 0x78(%rsi), %r9
testq %r9, (%r10,%rcx,8)
jne 0x11ed3
leal -0x1(%rax), %r15d
movq %rdx, %r10
shlq $0x9, %r10
addq 0x13286(%rip), %r10     # 0x24fb0
movl 0x4(%rsi), %ecx
leaq (%rcx,%rcx,2), %rbp
shlq $0x4, %rbp
movq 0x288(%rsi,%rbp), %r14
testq %r14, (%r10,%r15,8)
jne 0x11ed3
leaq 0x288(%rsi), %r12
leaq 0x9ceb(%rip), %rcx      # 0x1ba40
movq 0x8(%r12,%rbp), %r13
testq %r13, (%rcx,%r15,8)
jne 0x11ed3
leaq 0x134a5(%rip), %rcx     # 0x25210
leaq 0x9ace(%rip), %r11      # 0x1b840
movq (%r11,%r15,8), %rbx
andq %r9, %rbx
leaq 0x98c0(%rip), %r11      # 0x1b640
imulq (%r11,%r15,8), %rbx
movq (%rcx,%r15,8), %rcx
movq %rcx, -0x18(%rsp)
leaq 0x97ab(%rip), %rcx      # 0x1b540
movb (%rcx,%r15,4), %cl
shrq %cl, %rbx
movq 0x20(%r12,%rbp), %rcx
movq 0x10(%r12,%rbp), %r11
movq %rcx, -0x8(%rsp)
orq %rcx, %r11
movq -0x18(%rsp), %rcx
testq %r11, (%rcx,%rbx,8)
jne 0x11ed3
movq %r11, -0x10(%rsp)
leaq 0x13647(%rip), %r11     # 0x25410
movq (%r11,%r15,8), %r11
movq %r11, -0x18(%rsp)
leaq 0x9567(%rip), %r11      # 0x1b340
movq (%r11,%r15,8), %rbx
andq %r9, %rbx
leaq 0x9359(%rip), %r11      # 0x1b140
imulq (%r11,%r15,8), %rbx
leaq 0x924d(%rip), %r11      # 0x1b040
movb (%r11,%r15,4), %cl
movq %r11, %r15
shrq %cl, %rbx
movq -0x8(%rsp), %rcx
orq 0x18(%r12,%rbp), %rcx
movq -0x18(%rsp), %r11
testq %rcx, (%r11,%rbx,8)
jne 0x11ed3
movq %r15, %r11
leaq 0x9320(%rip), %rbp      # 0x1b140
leaq 0x9519(%rip), %r12      # 0x1b340
leaq 0x135e2(%rip), %rbx     # 0x25410
leal -0x2(%rax), %r15d
testq %r14, (%r10,%r15,8)
jne 0x11ed3
leaq 0x9bfd(%rip), %r10      # 0x1ba40
testq %r13, (%r10,%r15,8)
jne 0x11ed3
movq %rcx, %r13
leaq 0x99e9(%rip), %rcx      # 0x1b840
movq (%rcx,%r15,8), %r10
andq %r9, %r10
leaq 0x97db(%rip), %rcx      # 0x1b640
imulq (%rcx,%r15,8), %r10
leaq 0x96cf(%rip), %rcx      # 0x1b540
movb (%rcx,%r15,4), %cl
shrq %cl, %r10
leaq 0x13391(%rip), %rcx     # 0x25210
movq (%rcx,%r15,8), %rcx
movq -0x10(%rsp), %r14
testq %r14, (%rcx,%r10,8)
jne 0x11ed3
andq (%r12,%r15,8), %r9
imulq (%rbp,%r15,8), %r9
movb (%r11,%r15,4), %cl
shrq %cl, %r9
movq (%rbx,%r15,8), %rcx
testq %r13, (%rcx,%r9,8)
jne 0x11ed3
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)
movl 0xc(%rsi), %r8d
testq %rdx, %rdx
movl $0x2, %ecx
movl $0x8, %r9d
cmovel %ecx, %r9d
testl %r9d, %r8d
je 0x12093
leal 0x4(%rax), %ecx
movq %rax, %r9
shlq $0x9, %r9
addq 0x130c1(%rip), %r9      # 0x24fc0
movq 0x80(%rsi), %r8
orq 0x78(%rsi), %r8
testq %r8, (%r9,%rcx,8)
jne 0x12093
leal 0x1(%rax), %ebx
shlq $0x9, %rdx
addq 0x1308e(%rip), %rdx     # 0x24fb0
movl 0x4(%rsi), %ecx
leaq (%rcx,%rcx,2), %r13
shlq $0x4, %r13
movq 0x288(%rsi,%r13), %r11
testq %r11, (%rdx,%rbx,8)
jne 0x12093
addq $0x288, %rsi            # imm = 0x288
leaq 0x9af3(%rip), %r14      # 0x1ba40
movq 0x8(%rsi,%r13), %r15
testq %r15, (%r14,%rbx,8)
jne 0x12093
leaq 0x132ad(%rip), %rcx     # 0x25210
leaq 0x98d6(%rip), %r9       # 0x1b840
movq (%r9,%rbx,8), %rbp
andq %r8, %rbp
leaq 0x96c8(%rip), %r9       # 0x1b640
imulq (%r9,%rbx,8), %rbp
movq (%rcx,%rbx,8), %r10
leaq 0x95b8(%rip), %rcx      # 0x1b540
movb (%rcx,%rbx,4), %cl
shrq %cl, %rbp
movq 0x20(%rsi,%r13), %r9
movq 0x10(%rsi,%r13), %r12
orq %r9, %r12
testq %r12, (%r10,%rbp,8)
jne 0x12093
leaq 0x13464(%rip), %rcx     # 0x25410
movq (%rcx,%rbx,8), %rcx
movq %rcx, -0x18(%rsp)
leaq 0x9384(%rip), %rcx      # 0x1b340
movq (%rcx,%rbx,8), %rbp
andq %r8, %rbp
leaq 0x9176(%rip), %rcx      # 0x1b140
imulq (%rcx,%rbx,8), %rbp
leaq 0x906a(%rip), %r10      # 0x1b040
movb (%r10,%rbx,4), %cl
shrq %cl, %rbp
orq 0x18(%rsi,%r13), %r9
movq -0x18(%rsp), %rcx
testq %r9, (%rcx,%rbp,8)
jne 0x12093
movl %eax, %esi
addl $0x2, %esi
testq %r11, (%rdx,%rsi,8)
jne 0x12093
testq %r15, (%r14,%rsi,8)
jne 0x12093
leaq 0x982f(%rip), %rcx      # 0x1b840
movq (%rcx,%rsi,8), %rdx
andq %r8, %rdx
leaq 0x9621(%rip), %rcx      # 0x1b640
imulq (%rcx,%rsi,8), %rdx
leaq 0x9515(%rip), %rcx      # 0x1b540
movb (%rcx,%rsi,4), %cl
shrq %cl, %rdx
leaq 0x131d8(%rip), %rcx     # 0x25210
movq (%rcx,%rsi,8), %rcx
testq %r12, (%rcx,%rdx,8)
jne 0x12093
leaq 0x92f7(%rip), %rcx      # 0x1b340
andq (%rcx,%rsi,8), %r8
leaq 0x90ec(%rip), %rcx      # 0x1b140
imulq (%rcx,%rsi,8), %r8
movb (%r10,%rsi,4), %cl
shrq %cl, %r8
leaq 0x133a9(%rip), %rcx     # 0x25410
movq (%rcx,%rsi,8), %rcx
testq %r9, (%rcx,%r8,8)
jne 0x12093
shll $0x6, %esi
orl %eax, %esi
orl $0x8000, %esi           # imm = 0x8000
movq 0x848(%rdi), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x848(%rdi)
movw %si, 0x30(%rdi,%rax,8)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq