// File: jswaff[P]prophet3/test/movegen__test.cpp
// Function: test_gen_king_noncaptures()
void test_gen_king_noncaptures() {
    position pos;

    set_pos(&pos,"8/8/3k4/2n1P3/8/8/3rP3/R3K2R b KQ - 0 1");
    move moves[20];
    move *mp = gen_king_moves(moves,&pos,false,true);
    assert((mp - moves) == 6);
    assert(is_in_move_list(to_move(KING,D6,D7),moves,mp));
    assert(is_in_move_list(to_move(KING,D6,E7),moves,mp));
    assert(is_in_move_list(to_move(KING,D6,E6),moves,mp));
    assert(is_in_move_list(to_move(KING,D6,D5),moves,mp));
    assert(is_in_move_list(to_move(KING,D6,C6),moves,mp));
    assert(is_in_move_list(to_move(KING,D6,C7),moves,mp));

    // flip sides
    set_pos(&pos,"8/8/3k4/2n1P3/8/8/3rP3/RN2K2R w KQ - 0 1");
    mp = gen_king_moves(moves,&pos,false,true);
    assert((mp - moves)==4);
    assert(is_in_move_list(to_move(KING,E1,F2),moves,mp));
    assert(is_in_move_list(to_move(KING,E1,F1),moves,mp));
    assert(is_in_move_list(to_move(KING,E1,D1),moves,mp)); // NOTE: illegal move
    move mv = to_move(KING,E1,G1);
    set_castle(&mv);
    assert(is_in_move_list(mv,moves,mp));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x280, %rsp            # imm = 0x280
leaq -0x1c8(%rbp), %rdi
leaq 0x1961c(%rip), %rsi     # 0x40375
callq 0xf3e0
leaq -0x270(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0xb900
movq %rax, -0x278(%rbp)
movq -0x278(%rbp), %rax
leaq -0x270(%rbp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
cmpq $0x6, %rax
jne 0x26d9c
jmp 0x26dbb
leaq 0x19b54(%rip), %rdi     # 0x408f7
leaq 0x18846(%rip), %rsi     # 0x3f5f0
movl $0x15d, %edx            # imm = 0x15D
leaq 0x19b53(%rip), %rcx     # 0x40909
callq 0x20c0
movl $0x6, %edi
movl $0x13, %esi
movl $0xb, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x26deb
jmp 0x26ded
jmp 0x26e0c
leaq 0x195d6(%rip), %rdi     # 0x403ca
leaq 0x187f5(%rip), %rsi     # 0x3f5f0
movl $0x15e, %edx            # imm = 0x15E
leaq 0x19b02(%rip), %rcx     # 0x40909
callq 0x20c0
movl $0x6, %edi
movl $0x13, %esi
movl $0xc, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x26e3c
jmp 0x26e3e
jmp 0x26e5d
leaq 0x195b3(%rip), %rdi     # 0x403f8
leaq 0x187a4(%rip), %rsi     # 0x3f5f0
movl $0x15f, %edx            # imm = 0x15F
leaq 0x19ab1(%rip), %rcx     # 0x40909
callq 0x20c0
movl $0x6, %edi
movl $0x13, %esi
movl $0x14, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x26e8d
jmp 0x26e8f
jmp 0x26eae
leaq 0x19590(%rip), %rdi     # 0x40426
leaq 0x18753(%rip), %rsi     # 0x3f5f0
movl $0x160, %edx            # imm = 0x160
leaq 0x19a60(%rip), %rcx     # 0x40909
callq 0x20c0
movl $0x6, %edi
movl $0x13, %esi
movl $0x1b, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x26ede
jmp 0x26ee0
jmp 0x26eff
leaq 0x195a3(%rip), %rdi     # 0x4048a
leaq 0x18702(%rip), %rsi     # 0x3f5f0
movl $0x161, %edx            # imm = 0x161
leaq 0x19a0f(%rip), %rcx     # 0x40909
callq 0x20c0
movl $0x6, %edi
movl $0x13, %esi
movl $0x12, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x26f2f
jmp 0x26f31
jmp 0x26f50
leaq 0x19580(%rip), %rdi     # 0x404b8
leaq 0x186b1(%rip), %rsi     # 0x3f5f0
movl $0x162, %edx            # imm = 0x162
leaq 0x199be(%rip), %rcx     # 0x40909
callq 0x20c0
movl $0x6, %edi
movl $0x13, %esi
movl $0xa, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x26f80
jmp 0x26f82
jmp 0x26fa1
leaq 0x1955d(%rip), %rdi     # 0x404e6
leaq 0x18660(%rip), %rsi     # 0x3f5f0
movl $0x163, %edx            # imm = 0x163
leaq 0x1996d(%rip), %rcx     # 0x40909
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x13cb8(%rip), %rsi     # 0x3ac67
callq 0xf3e0
leaq -0x270(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0xb900
movq %rax, -0x278(%rbp)
movq -0x278(%rbp), %rax
leaq -0x270(%rbp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
cmpq $0x4, %rax
jne 0x26ff2
jmp 0x27011
leaq 0x1978c(%rip), %rdi     # 0x40785
leaq 0x185f0(%rip), %rsi     # 0x3f5f0
movl $0x168, %edx            # imm = 0x168
leaq 0x198fd(%rip), %rcx     # 0x40909
callq 0x20c0
movl $0x6, %edi
movl $0x3c, %esi
movl $0x35, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x27041
jmp 0x27043
jmp 0x27062
leaq 0x194da(%rip), %rdi     # 0x40524
leaq 0x1859f(%rip), %rsi     # 0x3f5f0
movl $0x169, %edx            # imm = 0x169
leaq 0x198ac(%rip), %rcx     # 0x40909
callq 0x20c0
movl $0x6, %edi
movl $0x3c, %esi
movl $0x3d, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x27092
jmp 0x27094
jmp 0x270b3
leaq 0x194b7(%rip), %rdi     # 0x40552
leaq 0x1854e(%rip), %rsi     # 0x3f5f0
movl $0x16a, %edx            # imm = 0x16A
leaq 0x1985b(%rip), %rcx     # 0x40909
callq 0x20c0
movl $0x6, %edi
movl $0x3c, %esi
movl $0x3b, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x270e3
jmp 0x270e5
jmp 0x27104
leaq 0x19494(%rip), %rdi     # 0x40580
leaq 0x184fd(%rip), %rsi     # 0x3f5f0
movl $0x16b, %edx            # imm = 0x16B
leaq 0x1980a(%rip), %rcx     # 0x40909
callq 0x20c0
movl $0x6, %edi
movl $0x3c, %esi
movl $0x3e, %edx
callq 0xa830
movq %rax, -0x280(%rbp)
leaq -0x280(%rbp), %rdi
callq 0xaa60
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x2714b
jmp 0x2714d
jmp 0x2716c
leaq 0x19490(%rip), %rdi     # 0x405e4
leaq 0x18495(%rip), %rsi     # 0x3f5f0
movl $0x16e, %edx            # imm = 0x16E
leaq 0x197a2(%rip), %rcx     # 0x40909
callq 0x20c0
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
nopw %cs:(%rax,%rax)