// File: jswaff[P]prophet3/test/next__test.cpp
// Function: test_good_move()
void test_good_move() {
    position pos;
    reset_pos(&pos);

    // all moves from the initial position
    assert_all_moves_good(&pos);

    // some moves that are not legal from the initial position
    assert(!good_move(&pos,to_move(KNIGHT,G1,E2)));
    assert(!good_move(&pos,to_move(KNIGHT,B1,C4)));

    // some pawn tests
    set_pos(&pos,"k7/P6P/8/4Pp2/1p6/3p4/1PPP4/K7 w - f6 0 1");
    assert_all_moves_good(&pos);
    assert(!good_move(&pos,to_move(PAWN,A7,A8)));
    assert(!good_move(&pos,to_move(PAWN,A7,B8)));
    assert(!good_move(&pos,to_capture(PAWN,A7,B8,PAWN)));
    assert(!good_move(&pos,to_capture(PAWN,A7,A8,KING)));

    flip_board(&pos);
    assert_all_moves_good(&pos);

    set_pos(&pos,"r5k1/6rp/5B2/8/8/7R/7P/7K w - - 0 1");
    assert(!good_move(&pos,to_move(PAWN,H2,H4)));

    // some knight tests
    set_pos(&pos,"k7/8/4p3/6n1/4P3/8/8/K7 b - -");
    assert_all_moves_good(&pos);
    for (int i=0;i<64;i++) {
        move test_move = to_move(KNIGHT,G5,(square_t)i);
        if (pos.piece[i] != NO_PIECE) {
            set_capture(&test_move,(piece_t)pos.piece[i]);
        }
        assert(good_move(&pos,test_move)==(i==F7 || i==H7 || i==E4 || i==F3 || i==H3));
    }

    // some bishop tests
    set_pos(&pos,"k7/8/1Q3q2/8/3b4/8/8/1K6 b - - 0 1");
    assert_all_moves_good(&pos);
    assert(!good_move(&pos,to_capture(BISHOP,D4,F6,QUEEN)));

    // some rook tests
    set_pos(&pos,"k7/8/1Q3q2/8/2PR1p2/8/8/1K6 w - - 0 1");
    assert_all_moves_good(&pos);

    // some queen tests
    set_pos(&pos,"k7/8/1Q3q2/8/2PQ1p2/8/8/1K6 w - - 0 1");
    assert_all_moves_good(&pos);

    // king tests
    set_pos(&pos,"r3kb1r/8/8/8/8/8/8/R3K2R b KQkq - 0 1");
    assert(test_pos_consistency(&pos));
    assert_all_moves_good(&pos);
    move bogus = to_move(KING,E8,G8);
    set_castle(&bogus);
    assert(!good_move(&pos,bogus)); // bishop in the path
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
leaq -0x1c8(%rbp), %rdi
callq 0xf390
leaq -0x1c8(%rbp), %rdi
callq 0x2bc50
movl $0x2, %edi
movl $0x3e, %esi
movl $0x34, %edx
callq 0xa830
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xcef0
xorb $-0x1, %al
testb $0x1, %al
jne 0x2bd5e
jmp 0x2bd60
jmp 0x2bd7f
leaq 0x15f0b(%rip), %rdi     # 0x41c72
leaq 0x154dc(%rip), %rsi     # 0x4124a
movl $0x204, %edx            # imm = 0x204
leaq 0x15f1f(%rip), %rcx     # 0x41c99
callq 0x20c0
movl $0x2, %edi
movl $0x39, %esi
movl $0x22, %edx
callq 0xa830
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xcef0
xorb $-0x1, %al
testb $0x1, %al
jne 0x2bdaa
jmp 0x2bdac
jmp 0x2bdcb
leaq 0x15efc(%rip), %rdi     # 0x41caf
leaq 0x15490(%rip), %rsi     # 0x4124a
movl $0x205, %edx            # imm = 0x205
leaq 0x15ed3(%rip), %rcx     # 0x41c99
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x15efd(%rip), %rsi     # 0x41cd6
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
callq 0x2bc50
movl $0x1, %edi
movl $0x8, %esi
xorl %edx, %edx
callq 0xa830
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xcef0
xorb $-0x1, %al
testb $0x1, %al
jne 0x2be12
jmp 0x2be14
jmp 0x2be33
leaq 0x15ee5(%rip), %rdi     # 0x41d00
leaq 0x15428(%rip), %rsi     # 0x4124a
movl $0x20a, %edx            # imm = 0x20A
leaq 0x15e6b(%rip), %rcx     # 0x41c99
callq 0x20c0
movl $0x1, %edx
movl $0x8, %esi
movl %edx, %edi
callq 0xa830
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xcef0
xorb $-0x1, %al
testb $0x1, %al
jne 0x2be5b
jmp 0x2be5d
jmp 0x2be7c
leaq 0x15ec1(%rip), %rdi     # 0x41d25
leaq 0x153df(%rip), %rsi     # 0x4124a
movl $0x20b, %edx            # imm = 0x20B
leaq 0x15e22(%rip), %rcx     # 0x41c99
callq 0x20c0
movl $0x1, %ecx
movl $0x8, %esi
movl %ecx, %edi
movl %ecx, %edx
callq 0xa890
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xcef0
xorb $-0x1, %al
testb $0x1, %al
jne 0x2bea6
jmp 0x2bea8
jmp 0x2bec7
leaq 0x15e9b(%rip), %rdi     # 0x41d4a
leaq 0x15394(%rip), %rsi     # 0x4124a
movl $0x20c, %edx            # imm = 0x20C
leaq 0x15dd7(%rip), %rcx     # 0x41c99
callq 0x20c0
movl $0x1, %edi
movl $0x8, %esi
xorl %edx, %edx
movl $0x6, %ecx
callq 0xa890
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xcef0
xorb $-0x1, %al
testb $0x1, %al
jne 0x2bef4
jmp 0x2bef6
jmp 0x2bf15
leaq 0x15e7a(%rip), %rdi     # 0x41d77
leaq 0x15346(%rip), %rsi     # 0x4124a
movl $0x20d, %edx            # imm = 0x20D
leaq 0x15d89(%rip), %rcx     # 0x41c99
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
callq 0xfc80
leaq -0x1c8(%rbp), %rdi
callq 0x2bc50
leaq -0x1c8(%rbp), %rdi
leaq 0x15e69(%rip), %rsi     # 0x41da4
callq 0xf3e0
movl $0x1, %edi
movl $0x37, %esi
movl $0x27, %edx
callq 0xa830
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xcef0
xorb $-0x1, %al
testb $0x1, %al
jne 0x2bf6b
jmp 0x2bf6d
jmp 0x2bf8c
leaq 0x15e54(%rip), %rdi     # 0x41dc8
leaq 0x152cf(%rip), %rsi     # 0x4124a
movl $0x213, %edx            # imm = 0x213
leaq 0x15d12(%rip), %rcx     # 0x41c99
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x15e53(%rip), %rsi     # 0x41ded
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
callq 0x2bc50
movl $0x0, -0x1cc(%rbp)
cmpl $0x40, -0x1cc(%rbp)
jge 0x2c0c8
movl -0x1cc(%rbp), %edx
movl $0x2, %edi
movl $0x1e, %esi
callq 0xa830
movq %rax, -0x1d8(%rbp)
movslq -0x1cc(%rbp), %rax
cmpl $0x0, -0x1c8(%rbp,%rax,4)
je 0x2c009
movslq -0x1cc(%rbp), %rax
movl -0x1c8(%rbp,%rax,4), %esi
leaq -0x1d8(%rbp), %rdi
callq 0xa920
movq -0x1d8(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xcef0
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x1e8(%rbp)
movb $0x1, %al
cmpl $0xd, -0x1cc(%rbp)
movb %al, -0x1e1(%rbp)
je 0x2c07b
movb $0x1, %al
cmpl $0xf, -0x1cc(%rbp)
movb %al, -0x1e1(%rbp)
je 0x2c07b
movb $0x1, %al
cmpl $0x24, -0x1cc(%rbp)
movb %al, -0x1e1(%rbp)
je 0x2c07b
movb $0x1, %al
cmpl $0x2d, -0x1cc(%rbp)
movb %al, -0x1e1(%rbp)
je 0x2c07b
cmpl $0x2f, -0x1cc(%rbp)
sete %al
movb %al, -0x1e1(%rbp)
movl -0x1e8(%rbp), %eax
movb -0x1e1(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x2c093
jmp 0x2c0b2
leaq 0x15d71(%rip), %rdi     # 0x41e0b
leaq 0x151a9(%rip), %rsi     # 0x4124a
movl $0x21d, %edx            # imm = 0x21D
leaq 0x15bec(%rip), %rcx     # 0x41c99
callq 0x20c0
jmp 0x2c0b4
movl -0x1cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1cc(%rbp)
jmp 0x2bfb5
leaq -0x1c8(%rbp), %rdi
leaq 0x15d7c(%rip), %rsi     # 0x41e52
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
callq 0x2bc50
movl $0x3, %edi
movl $0x23, %esi
movl $0x15, %edx
movl $0x5, %ecx
callq 0xa890
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xcef0
xorb $-0x1, %al
testb $0x1, %al
jne 0x2c117
jmp 0x2c119
jmp 0x2c138
leaq 0x15d55(%rip), %rdi     # 0x41e75
leaq 0x15123(%rip), %rsi     # 0x4124a
movl $0x223, %edx            # imm = 0x223
leaq 0x15b66(%rip), %rcx     # 0x41c99
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x15d5f(%rip), %rsi     # 0x41ea5
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
callq 0x2bc50
leaq -0x1c8(%rbp), %rdi
leaq 0x15d66(%rip), %rsi     # 0x41ecb
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
callq 0x2bc50
leaq -0x1c8(%rbp), %rdi
leaq 0x15d6d(%rip), %rsi     # 0x41ef1
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
callq 0x2e0c0
testb $0x1, %al
jne 0x2c19b
jmp 0x2c19d
jmp 0x2c1bc
leaq 0x15d73(%rip), %rdi     # 0x41f17
leaq 0x1509f(%rip), %rsi     # 0x4124a
movl $0x22f, %edx            # imm = 0x22F
leaq 0x15ae2(%rip), %rcx     # 0x41c99
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
callq 0x2bc50
movl $0x6, %edx
movl $0x4, %esi
movl %edx, %edi
callq 0xa830
movq %rax, -0x1e0(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0xaa60
movq -0x1e0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xcef0
xorb $-0x1, %al
testb $0x1, %al
jne 0x2c207
jmp 0x2c209
jmp 0x2c228
leaq 0x15d22(%rip), %rdi     # 0x41f32
leaq 0x15033(%rip), %rsi     # 0x4124a
movl $0x233, %edx            # imm = 0x233
leaq 0x15a76(%rip), %rcx     # 0x41c99
callq 0x20c0
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
nopw %cs:(%rax,%rax)