// File: jswaff[P]prophet3/test/attack__test.cpp
// Function: test_attacked_by_knight()
void test_attacked_by_knight() {
    position pos;
    set_pos(&pos,"3k4/8/8/3n4/3N4/8/8/3K4 w - - 0 1");

    uint64 white_map=0,black_map=0;
    for (int32 sq=A8;sq<=H1;sq++) {
        if (attacked_by_knight(&pos,(square_t)sq,WHITE)) {
            white_map |= bb_squares[sq];
        }

        if (attacked_by_knight(&pos,(square_t)sq,BLACK)) {
            black_map |= bb_squares[sq];
        }
    }

    assert(white_map==(bb_squares[C6] | bb_squares[E6] | bb_squares[F5]
                     | bb_squares[F3] | bb_squares[E2] | bb_squares[C2]
                     | bb_squares[B3] | bb_squares[B5]));


    assert(black_map==(bb_squares[C7] | bb_squares[E7] | bb_squares[F6]
                     | bb_squares[F4] | bb_squares[E3] | bb_squares[C3]
                     | bb_squares[B4] | bb_squares[B6]));


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
leaq -0x1c8(%rbp), %rdi
leaq 0x22ce0(%rip), %rsi     # 0x397f9
callq 0xf3e0
movq $0x0, -0x1d0(%rbp)
movq $0x0, -0x1d8(%rbp)
movl $0x0, -0x1dc(%rbp)
cmpl $0x3f, -0x1dc(%rbp)
jg 0x16bd8
movl -0x1dc(%rbp), %esi
leaq -0x1c8(%rbp), %rdi
movl $0x1, %edx
callq 0x3ee0
testb $0x1, %al
jne 0x16b68
jmp 0x16b88
movslq -0x1dc(%rbp), %rcx
leaq 0xeeafa(%rip), %rax     # 0x105670
movq (%rax,%rcx,8), %rax
orq -0x1d0(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movl -0x1dc(%rbp), %esi
leaq -0x1c8(%rbp), %rdi
xorl %edx, %edx
callq 0x3ee0
testb $0x1, %al
jne 0x16ba2
jmp 0x16bc2
movslq -0x1dc(%rbp), %rcx
leaq 0xeeac0(%rip), %rax     # 0x105670
movq (%rax,%rcx,8), %rax
orq -0x1d8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
jmp 0x16bc4
movl -0x1dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1dc(%rbp)
jmp 0x16b3e
movq -0x1d0(%rbp), %rax
leaq 0xeea8a(%rip), %rcx     # 0x105670
movq 0x90(%rcx), %rcx
leaq 0xeea7c(%rip), %rdx     # 0x105670
orq 0xa0(%rdx), %rcx
leaq 0xeea6e(%rip), %rdx     # 0x105670
orq 0xe8(%rdx), %rcx
leaq 0xeea60(%rip), %rdx     # 0x105670
orq 0x168(%rdx), %rcx
leaq 0xeea52(%rip), %rdx     # 0x105670
orq 0x1a0(%rdx), %rcx
leaq 0xeea44(%rip), %rdx     # 0x105670
orq 0x190(%rdx), %rcx
leaq 0xeea36(%rip), %rdx     # 0x105670
orq 0x148(%rdx), %rcx
leaq 0xeea28(%rip), %rdx     # 0x105670
orq 0xc8(%rdx), %rcx
cmpq %rcx, %rax
jne 0x16c56
jmp 0x16c75
leaq 0x22bbe(%rip), %rdi     # 0x3981b
leaq 0x22c4a(%rip), %rsi     # 0x398ae
movl $0x1d, %edx
leaq 0x22c54(%rip), %rcx     # 0x398c4
callq 0x20c0
movq -0x1d8(%rbp), %rax
leaq 0xee9ed(%rip), %rcx     # 0x105670
movq 0x50(%rcx), %rcx
leaq 0xee9e2(%rip), %rdx     # 0x105670
orq 0x60(%rdx), %rcx
leaq 0xee9d7(%rip), %rdx     # 0x105670
orq 0xa8(%rdx), %rcx
leaq 0xee9c9(%rip), %rdx     # 0x105670
orq 0x128(%rdx), %rcx
leaq 0xee9bb(%rip), %rdx     # 0x105670
orq 0x160(%rdx), %rcx
leaq 0xee9ad(%rip), %rdx     # 0x105670
orq 0x150(%rdx), %rcx
leaq 0xee99f(%rip), %rdx     # 0x105670
orq 0x108(%rdx), %rcx
leaq 0xee991(%rip), %rdx     # 0x105670
orq 0x88(%rdx), %rcx
cmpq %rcx, %rax
jne 0x16ced
jmp 0x16d0c
leaq 0x22bef(%rip), %rdi     # 0x398e3
leaq 0x22bb3(%rip), %rsi     # 0x398ae
movl $0x22, %edx
leaq 0x22bbd(%rip), %rcx     # 0x398c4
callq 0x20c0
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
nopw %cs:(%rax,%rax)