// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa187
movq %rbx, %rdi
callq 0x1f138
pushq $0x2
popq %rdi
pushq $0x3e
popq %rsi
pushq $0x34
popq %rdx
callq 0x7284
movq %rbx, %rdi
movq %rax, %rsi
callq 0x89da
testb %al, %al
jne 0x1f47c
pushq $0x2
popq %rdi
pushq $0x39
popq %rsi
pushq $0x22
popq %rdx
callq 0x7284
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x89da
testb %al, %al
jne 0x1f49b
leaq 0x142de(%rip), %rsi     # 0x334f7
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
movq %rbx, %rdi
callq 0x1f138
pushq $0x1
popq %rdi
pushq $0x8
popq %rsi
xorl %edx, %edx
callq 0x7284
movq %rbx, %rdi
movq %rax, %rsi
callq 0x89da
testb %al, %al
jne 0x1f4ba
pushq $0x8
popq %rsi
pushq $0x1
popq %rdi
movl %edi, %edx
callq 0x7284
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x89da
testb %al, %al
jne 0x1f4d9
pushq $0x8
popq %rsi
pushq $0x1
popq %rcx
movl %ecx, %edi
movl %ecx, %edx
callq 0x72a3
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x89da
testb %al, %al
jne 0x1f4f8
pushq $0x1
popq %rdi
pushq $0x8
popq %rsi
pushq $0x6
popq %rcx
xorl %edx, %edx
callq 0x72a3
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x89da
testb %al, %al
jne 0x1f517
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa64d
movq %rbx, %rdi
callq 0x1f138
leaq 0x142f0(%rip), %rsi     # 0x335c5
movq %rbx, %rdi
callq 0xa1b8
pushq $0x1
popq %rdi
pushq $0x37
popq %rsi
pushq $0x27
popq %rdx
callq 0x7284
movq %rbx, %rdi
movq %rax, %rsi
callq 0x89da
testb %al, %al
jne 0x1f536
leaq 0x14309(%rip), %rsi     # 0x3360e
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
movq %rbx, %rdi
callq 0x1f138
xorl %r14d, %r14d
pushq $0x2
popq %rbp
pushq $0x1e
popq %r15
movq %rsp, %r12
cmpq $0x40, %r14
je 0x1f380
movl %ebp, %edi
movl %r15d, %esi
movl %r14d, %edx
callq 0x7284
movq %rax, (%rsp)
movl 0x8(%rsp,%r14,4), %esi
testl %esi, %esi
je 0x1f353
movq %r12, %rdi
callq 0x72df
movq (%rsp), %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x89da
cmpq $0x24, %r14
setne %cl
movl %r14d, %edx
andl $0x1d, %edx
cmpl $0xd, %edx
setne %dl
andb %cl, %dl
cmpb %al, %dl
je 0x1f45d
incq %r14
jmp 0x1f327
leaq 0x142ec(%rip), %rsi     # 0x33673
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
movq %rbx, %rdi
callq 0x1f138
pushq $0x3
popq %rdi
pushq $0x23
popq %rsi
pushq $0x15
popq %rdx
pushq $0x5
popq %rcx
callq 0x72a3
movq %rbx, %rdi
movq %rax, %rsi
callq 0x89da
testb %al, %al
jne 0x1f555
leaq 0x142ff(%rip), %rsi     # 0x336c6
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
movq %rbx, %rdi
callq 0x1f138
leaq 0x14309(%rip), %rsi     # 0x336ec
movq %rbx, %rdi
callq 0xa1b8
movq %rbx, %rdi
callq 0x1f138
leaq 0x14318(%rip), %rsi     # 0x33712
movq %rbx, %rdi
callq 0xa1b8
movq %rbx, %rdi
callq 0x21176
testb %al, %al
je 0x1f574
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x1f138
pushq $0x4
popq %rsi
pushq $0x6
popq %rdi
movl %edi, %edx
callq 0x7284
movq %rsp, %r14
movq %rax, (%r14)
movq %r14, %rdi
callq 0x7366
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x89da
testb %al, %al
jne 0x1f593
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x141c8(%rip), %rdi     # 0x3362c
leaq 0x13600(%rip), %rsi     # 0x32a6b
leaq 0x14048(%rip), %rcx     # 0x334ba
movl $0x21d, %edx            # imm = 0x21D
callq 0x20c0
leaq 0x14010(%rip), %rdi     # 0x33493
leaq 0x135e1(%rip), %rsi     # 0x32a6b
leaq 0x14029(%rip), %rcx     # 0x334ba
movl $0x204, %edx            # imm = 0x204
callq 0x20c0
leaq 0x1402e(%rip), %rdi     # 0x334d0
leaq 0x135c2(%rip), %rsi     # 0x32a6b
leaq 0x1400a(%rip), %rcx     # 0x334ba
movl $0x205, %edx            # imm = 0x205
callq 0x20c0
leaq 0x14060(%rip), %rdi     # 0x33521
leaq 0x135a3(%rip), %rsi     # 0x32a6b
leaq 0x13feb(%rip), %rcx     # 0x334ba
movl $0x20a, %edx            # imm = 0x20A
callq 0x20c0
leaq 0x14066(%rip), %rdi     # 0x33546
leaq 0x13584(%rip), %rsi     # 0x32a6b
leaq 0x13fcc(%rip), %rcx     # 0x334ba
movl $0x20b, %edx            # imm = 0x20B
callq 0x20c0
leaq 0x1406c(%rip), %rdi     # 0x3356b
leaq 0x13565(%rip), %rsi     # 0x32a6b
leaq 0x13fad(%rip), %rcx     # 0x334ba
movl $0x20c, %edx            # imm = 0x20C
callq 0x20c0
leaq 0x1407a(%rip), %rdi     # 0x33598
leaq 0x13546(%rip), %rsi     # 0x32a6b
leaq 0x13f8e(%rip), %rcx     # 0x334ba
movl $0x20d, %edx            # imm = 0x20D
callq 0x20c0
leaq 0x140ac(%rip), %rdi     # 0x335e9
leaq 0x13527(%rip), %rsi     # 0x32a6b
leaq 0x13f6f(%rip), %rcx     # 0x334ba
movl $0x213, %edx            # imm = 0x213
callq 0x20c0
leaq 0x1413a(%rip), %rdi     # 0x33696
leaq 0x13508(%rip), %rsi     # 0x32a6b
leaq 0x13f50(%rip), %rcx     # 0x334ba
movl $0x223, %edx            # imm = 0x223
callq 0x20c0
leaq 0x141bd(%rip), %rdi     # 0x33738
leaq 0x134e9(%rip), %rsi     # 0x32a6b
leaq 0x13f31(%rip), %rcx     # 0x334ba
movl $0x22f, %edx            # imm = 0x22F
callq 0x20c0
leaq 0x141b9(%rip), %rdi     # 0x33753
leaq 0x134ca(%rip), %rsi     # 0x32a6b
leaq 0x13f12(%rip), %rcx     # 0x334ba
movl $0x233, %edx            # imm = 0x233
callq 0x20c0