// File: jswaff[P]prophet3/test/movegen__test.cpp
// Function: test_gen_pawn_moves()
void test_gen_pawn_moves() {
    position pos;
    set_pos(&pos,"2b1k3/PP6/8/3pP3/4P3/8/6P1/4K3 w - d6 0 1");
    move moves[20],*mp,mv;

    mp = gen_pawn_moves(moves,&pos,true,true);

    assert((mp - moves)==17);
    assert(is_in_move_list(to_move(PAWN,G2,G3),moves,mp));
    assert(is_in_move_list(to_move(PAWN,G2,G4),moves,mp));

    mv = to_move(PAWN,A7,A8);
    set_promopiece(&mv,QUEEN);
    assert(is_in_move_list(mv,moves,mp));
    set_promopiece(&mv,ROOK);
    assert(is_in_move_list(mv,moves,mp));
    set_promopiece(&mv,BISHOP);
    assert(is_in_move_list(mv,moves,mp));
    set_promopiece(&mv,KNIGHT);
    assert(is_in_move_list(mv,moves,mp));

    mv = to_move(PAWN,B7,B8);
    set_promopiece(&mv,QUEEN);
    assert(is_in_move_list(mv,moves,mp));
    set_promopiece(&mv,ROOK);
    assert(is_in_move_list(mv,moves,mp));
    set_promopiece(&mv,BISHOP);
    assert(is_in_move_list(mv,moves,mp));
    set_promopiece(&mv,KNIGHT);
    assert(is_in_move_list(mv,moves,mp));

    mv = to_capture(PAWN,B7,C8,BISHOP);
    set_promopiece(&mv,QUEEN);
    assert(is_in_move_list(mv,moves,mp));
    set_promopiece(&mv,ROOK);
    assert(is_in_move_list(mv,moves,mp));
    set_promopiece(&mv,BISHOP);
    assert(is_in_move_list(mv,moves,mp));
    set_promopiece(&mv,KNIGHT);
    assert(is_in_move_list(mv,moves,mp));

    mv = to_capture(PAWN,E4,D5,PAWN);
    assert(is_in_move_list(mv,moves,mp));

    assert(is_in_move_list(to_move(PAWN,E5,E6),moves,mp));
    mv = to_move(PAWN,E5,D6);
    set_epcapture(&mv);
    assert(is_in_move_list(mv,moves,mp));

    // from black
    set_pos(&pos,"rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1");
    mp = gen_pawn_moves(moves,&pos,true,true);

    assert((mp - moves)==16);
    assert(is_in_move_list(to_move(PAWN,D7,D6),moves,mp));
    assert(is_in_move_list(to_move(PAWN,D7,D5),moves,mp));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x280, %rsp            # imm = 0x280
leaq -0x1c8(%rbp), %rdi
leaq 0x19791(%rip), %rsi     # 0x4092a
callq 0xf3e0
leaq -0x270(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
movl $0x1, %ecx
movl %ecx, %edx
callq 0xae70
movq %rax, -0x278(%rbp)
movq -0x278(%rbp), %rax
leaq -0x270(%rbp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
cmpq $0x11, %rax
jne 0x271dc
jmp 0x271fb
leaq 0x19771(%rip), %rdi     # 0x40954
leaq 0x18406(%rip), %rsi     # 0x3f5f0
movl $0x178, %edx            # imm = 0x178
leaq 0x1976f(%rip), %rcx     # 0x40965
callq 0x20c0
movl $0x1, %edi
movl $0x36, %esi
movl $0x2e, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x2722b
jmp 0x2722d
jmp 0x2724c
leaq 0x1974c(%rip), %rdi     # 0x40980
leaq 0x183b5(%rip), %rsi     # 0x3f5f0
movl $0x179, %edx            # imm = 0x179
leaq 0x1971e(%rip), %rcx     # 0x40965
callq 0x20c0
movl $0x1, %edi
movl $0x36, %esi
movl $0x26, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x2727c
jmp 0x2727e
jmp 0x2729d
leaq 0x19729(%rip), %rdi     # 0x409ae
leaq 0x18364(%rip), %rsi     # 0x3f5f0
movl $0x17a, %edx            # imm = 0x17A
leaq 0x196cd(%rip), %rcx     # 0x40965
callq 0x20c0
movl $0x1, %edi
movl $0x8, %esi
xorl %edx, %edx
callq 0xa830
movq %rax, -0x280(%rbp)
leaq -0x280(%rbp), %rdi
movl $0x5, %esi
callq 0xa9e0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x272e6
jmp 0x272e8
jmp 0x27307
leaq 0x192f5(%rip), %rdi     # 0x405e4
leaq 0x182fa(%rip), %rsi     # 0x3f5f0
movl $0x17e, %edx            # imm = 0x17E
leaq 0x19663(%rip), %rcx     # 0x40965
callq 0x20c0
leaq -0x280(%rbp), %rdi
movl $0x4, %esi
callq 0xa9e0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x27338
jmp 0x2733a
jmp 0x27359
leaq 0x192a3(%rip), %rdi     # 0x405e4
leaq 0x182a8(%rip), %rsi     # 0x3f5f0
movl $0x180, %edx            # imm = 0x180
leaq 0x19611(%rip), %rcx     # 0x40965
callq 0x20c0
leaq -0x280(%rbp), %rdi
movl $0x3, %esi
callq 0xa9e0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x2738a
jmp 0x2738c
jmp 0x273ab
leaq 0x19251(%rip), %rdi     # 0x405e4
leaq 0x18256(%rip), %rsi     # 0x3f5f0
movl $0x182, %edx            # imm = 0x182
leaq 0x195bf(%rip), %rcx     # 0x40965
callq 0x20c0
leaq -0x280(%rbp), %rdi
movl $0x2, %esi
callq 0xa9e0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x273dc
jmp 0x273de
jmp 0x273fd
leaq 0x191ff(%rip), %rdi     # 0x405e4
leaq 0x18204(%rip), %rsi     # 0x3f5f0
movl $0x184, %edx            # imm = 0x184
leaq 0x1956d(%rip), %rcx     # 0x40965
callq 0x20c0
movl $0x1, %edx
movl $0x9, %esi
movl %edx, %edi
callq 0xa830
movq %rax, -0x280(%rbp)
leaq -0x280(%rbp), %rdi
movl $0x5, %esi
callq 0xa9e0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x27446
jmp 0x27448
jmp 0x27467
leaq 0x19195(%rip), %rdi     # 0x405e4
leaq 0x1819a(%rip), %rsi     # 0x3f5f0
movl $0x188, %edx            # imm = 0x188
leaq 0x19503(%rip), %rcx     # 0x40965
callq 0x20c0
leaq -0x280(%rbp), %rdi
movl $0x4, %esi
callq 0xa9e0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x27498
jmp 0x2749a
jmp 0x274b9
leaq 0x19143(%rip), %rdi     # 0x405e4
leaq 0x18148(%rip), %rsi     # 0x3f5f0
movl $0x18a, %edx            # imm = 0x18A
leaq 0x194b1(%rip), %rcx     # 0x40965
callq 0x20c0
leaq -0x280(%rbp), %rdi
movl $0x3, %esi
callq 0xa9e0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x274ea
jmp 0x274ec
jmp 0x2750b
leaq 0x190f1(%rip), %rdi     # 0x405e4
leaq 0x180f6(%rip), %rsi     # 0x3f5f0
movl $0x18c, %edx            # imm = 0x18C
leaq 0x1945f(%rip), %rcx     # 0x40965
callq 0x20c0
leaq -0x280(%rbp), %rdi
movl $0x2, %esi
callq 0xa9e0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x2753c
jmp 0x2753e
jmp 0x2755d
leaq 0x1909f(%rip), %rdi     # 0x405e4
leaq 0x180a4(%rip), %rsi     # 0x3f5f0
movl $0x18e, %edx            # imm = 0x18E
leaq 0x1940d(%rip), %rcx     # 0x40965
callq 0x20c0
movl $0x1, %edi
movl $0x9, %esi
movl $0x2, %edx
movl $0x3, %ecx
callq 0xa890
movq %rax, -0x280(%rbp)
leaq -0x280(%rbp), %rdi
movl $0x5, %esi
callq 0xa9e0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x275ae
jmp 0x275b0
jmp 0x275cf
leaq 0x1902d(%rip), %rdi     # 0x405e4
leaq 0x18032(%rip), %rsi     # 0x3f5f0
movl $0x192, %edx            # imm = 0x192
leaq 0x1939b(%rip), %rcx     # 0x40965
callq 0x20c0
leaq -0x280(%rbp), %rdi
movl $0x4, %esi
callq 0xa9e0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x27600
jmp 0x27602
jmp 0x27621
leaq 0x18fdb(%rip), %rdi     # 0x405e4
leaq 0x17fe0(%rip), %rsi     # 0x3f5f0
movl $0x194, %edx            # imm = 0x194
leaq 0x19349(%rip), %rcx     # 0x40965
callq 0x20c0
leaq -0x280(%rbp), %rdi
movl $0x3, %esi
callq 0xa9e0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x27652
jmp 0x27654
jmp 0x27673
leaq 0x18f89(%rip), %rdi     # 0x405e4
leaq 0x17f8e(%rip), %rsi     # 0x3f5f0
movl $0x196, %edx            # imm = 0x196
leaq 0x192f7(%rip), %rcx     # 0x40965
callq 0x20c0
leaq -0x280(%rbp), %rdi
movl $0x2, %esi
callq 0xa9e0
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x276a4
jmp 0x276a6
jmp 0x276c5
leaq 0x18f37(%rip), %rdi     # 0x405e4
leaq 0x17f3c(%rip), %rsi     # 0x3f5f0
movl $0x198, %edx            # imm = 0x198
leaq 0x192a5(%rip), %rcx     # 0x40965
callq 0x20c0
movl $0x1, %ecx
movl $0x24, %esi
movl $0x1b, %edx
movl %ecx, %edi
callq 0xa890
movq %rax, -0x280(%rbp)
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x27702
jmp 0x27704
jmp 0x27723
leaq 0x18ed9(%rip), %rdi     # 0x405e4
leaq 0x17ede(%rip), %rsi     # 0x3f5f0
movl $0x19b, %edx            # imm = 0x19B
leaq 0x19247(%rip), %rcx     # 0x40965
callq 0x20c0
movl $0x1, %edi
movl $0x1c, %esi
movl $0x14, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x27753
jmp 0x27755
jmp 0x27774
leaq 0x19280(%rip), %rdi     # 0x409dc
leaq 0x17e8d(%rip), %rsi     # 0x3f5f0
movl $0x19d, %edx            # imm = 0x19D
leaq 0x191f6(%rip), %rcx     # 0x40965
callq 0x20c0
movl $0x1, %edi
movl $0x1c, %esi
movl $0x13, %edx
callq 0xa830
movq %rax, -0x280(%rbp)
leaq -0x280(%rbp), %rdi
callq 0xaa20
movq -0x280(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x277bb
jmp 0x277bd
jmp 0x277dc
leaq 0x18e20(%rip), %rdi     # 0x405e4
leaq 0x17e25(%rip), %rsi     # 0x3f5f0
movl $0x1a0, %edx            # imm = 0x1A0
leaq 0x1918e(%rip), %rcx     # 0x40965
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x11b01(%rip), %rsi     # 0x392eb
callq 0xf3e0
leaq -0x270(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
movl $0x1, %ecx
movl %ecx, %edx
callq 0xae70
movq %rax, -0x278(%rbp)
movq -0x278(%rbp), %rax
leaq -0x270(%rbp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
cmpq $0x10, %rax
jne 0x2782d
jmp 0x2784c
leaq 0x191d6(%rip), %rdi     # 0x40a0a
leaq 0x17db5(%rip), %rsi     # 0x3f5f0
movl $0x1a6, %edx            # imm = 0x1A6
leaq 0x1911e(%rip), %rcx     # 0x40965
callq 0x20c0
movl $0x1, %edi
movl $0xb, %esi
movl $0x13, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x2787c
jmp 0x2787e
jmp 0x2789d
leaq 0x19196(%rip), %rdi     # 0x40a1b
leaq 0x17d64(%rip), %rsi     # 0x3f5f0
movl $0x1a7, %edx            # imm = 0x1A7
leaq 0x190cd(%rip), %rcx     # 0x40965
callq 0x20c0
movl $0x1, %edi
movl $0xb, %esi
movl $0x1b, %edx
callq 0xa830
movq %rax, %rdi
leaq -0x270(%rbp), %rsi
movq -0x278(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x278cd
jmp 0x278cf
jmp 0x278ee
leaq 0x19173(%rip), %rdi     # 0x40a49
leaq 0x17d13(%rip), %rsi     # 0x3f5f0
movl $0x1a8, %edx            # imm = 0x1A8
leaq 0x1907c(%rip), %rcx     # 0x40965
callq 0x20c0
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
nopw (%rax,%rax)