// File: jswaff[P]prophet3/test/apply__test.cpp
// Function: test_apply_move()
void test_apply_move() {
    position pos1;
    reset_pos(&pos1);

    move mv = to_move(PAWN,E2,E4);
    apply_move(&pos1,mv,gundos);

    position pos2;
    set_pos(&pos2,"rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1");
    assert(equal_pos(&pos1,&pos2,true));

    ////
    mv = to_move(PAWN,C7,C5);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2");
    assert(equal_pos(&pos1,&pos2,true));

    ////
    mv = to_move(KNIGHT,G1,F3);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2");
    assert(equal_pos(&pos1,&pos2,true));
    assert(pos2.fifty_counter==1);

    ////
    mv = to_move(QUEEN,D8,A5);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnb1kbnr/pp1ppppp/8/q1p5/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3");
    assert(equal_pos(&pos1,&pos2,true));
    assert(pos2.fifty_counter==2);

    /////
    mv = to_move(BISHOP,F1,E2);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnb1kbnr/pp1ppppp/8/q1p5/4P3/5N2/PPPPBPPP/RNBQK2R b KQkq - 3 3");
    assert(equal_pos(&pos1,&pos2,true));

    ////
    mv = to_capture(QUEEN,A5,D2,PAWN);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnb1kbnr/pp1ppppp/8/2p5/4P3/5N2/PPPqBPPP/RNBQK2R w KQkq - 0 4");
    assert(equal_pos(&pos1,&pos2,true));

    ////
    mv = to_capture(KNIGHT,B1,D2,QUEEN);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnb1kbnr/pp1ppppp/8/2p5/4P3/5N2/PPPNBPPP/R1BQK2R b KQkq - 0 4");
    assert(equal_pos(&pos1,&pos2,true));

    ///
    mv = to_move(PAWN,C5,C4);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnb1kbnr/pp1ppppp/8/8/2p1P3/5N2/PPPNBPPP/R1BQK2R w KQkq - 0 5");
    assert(equal_pos(&pos1,&pos2,true));

    ///
    mv = to_move(KING,E1,G1);
    set_castle(&mv);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnb1kbnr/pp1ppppp/8/8/2p1P3/5N2/PPPNBPPP/R1BQ1RK1 b kq - 0 5");
    assert(equal_pos(&pos1,&pos2,true));


    ///
    mv = to_move(KING,E8,D8);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnbk1bnr/pp1ppppp/8/8/2p1P3/5N2/PPPNBPPP/R1BQ1RK1 w - - 1 6");
    assert(equal_pos(&pos1,&pos2,true));

    ///
    mv = to_move(PAWN,B2,B4);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnbk1bnr/pp1ppppp/8/8/1Pp1P3/5N2/P1PNBPPP/R1BQ1RK1 b - b3 0 6");
    assert(equal_pos(&pos1,&pos2,true));

    ///
    mv = to_move(PAWN,C4,B3);
    set_epcapture(&mv);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnbk1bnr/pp1ppppp/8/8/4P3/1p3N2/P1PNBPPP/R1BQ1RK1 w - - 0 7");
    assert(equal_pos(&pos1,&pos2,true));

    ////
    mv = to_move(ROOK,F1,E1);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnbk1bnr/pp1ppppp/8/8/4P3/1p3N2/P1PNBPPP/R1BQR1K1 b - - 1 7");
    assert(equal_pos(&pos1,&pos2,true));

    ////
    mv = to_move(PAWN,B3,B2);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnbk1bnr/pp1ppppp/8/8/4P3/5N2/PpPNBPPP/R1BQR1K1 w - - 0 8");
    assert(equal_pos(&pos1,&pos2,true));

    ////
    mv = to_move(KING,G1,H1);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnbk1bnr/pp1ppppp/8/8/4P3/5N2/PpPNBPPP/R1BQR2K b - - 1 8");
    assert(equal_pos(&pos1,&pos2,true));

    ///
    mv = to_capture(PAWN,B2,A1,ROOK);
    set_promopiece(&mv,KNIGHT);
    apply_move(&pos1,mv,gundos);
    set_pos(&pos2,"rnbk1bnr/pp1ppppp/8/8/4P3/5N2/P1PNBPPP/n1BQR2K w - - 0 9");
    assert(equal_pos(&pos1,&pos2,true));

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3a0, %rsp            # imm = 0x3A0
leaq -0x1c8(%rbp), %rdi
callq 0xf390
movl $0x1, %edi
movl $0x34, %esi
movl $0x24, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbde09(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x23431(%rip), %rsi     # 0x392eb
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x15edd
jmp 0x15edf
jmp 0x15efe
leaq 0x2c346(%rip), %rdi     # 0x4222c
leaq 0x2343a(%rip), %rsi     # 0x39327
movl $0x16, %edx
leaq 0x23443(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x1, %edi
movl $0xa, %esi
movl $0x1a, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbdd82(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x23412(%rip), %rsi     # 0x39353
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x15f64
jmp 0x15f66
jmp 0x15f85
leaq 0x2c2bf(%rip), %rdi     # 0x4222c
leaq 0x233b3(%rip), %rsi     # 0x39327
movl $0x1c, %edx
leaq 0x233bc(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x2, %edi
movl $0x3e, %esi
movl $0x2d, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbdcfb(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x233c9(%rip), %rsi     # 0x39391
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x15feb
jmp 0x15fed
jmp 0x1600c
leaq 0x2c238(%rip), %rdi     # 0x4222c
leaq 0x2332c(%rip), %rsi     # 0x39327
movl $0x22, %edx
leaq 0x23335(%rip), %rcx     # 0x3933c
callq 0x20c0
cmpl $0x1, -0x250(%rbp)
jne 0x16017
jmp 0x16036
leaq 0x233b2(%rip), %rdi     # 0x393d0
leaq 0x23302(%rip), %rsi     # 0x39327
movl $0x23, %edx
leaq 0x2330b(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x5, %edi
movl $0x3, %esi
movl $0x18, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbdc4a(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x2336d(%rip), %rsi     # 0x393e6
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x1609c
jmp 0x1609e
jmp 0x160bd
leaq 0x2c187(%rip), %rdi     # 0x4222c
leaq 0x2327b(%rip), %rsi     # 0x39327
movl $0x29, %edx
leaq 0x23284(%rip), %rcx     # 0x3933c
callq 0x20c0
cmpl $0x2, -0x250(%rbp)
jne 0x160c8
jmp 0x160e7
leaq 0x23357(%rip), %rdi     # 0x39426
leaq 0x23251(%rip), %rsi     # 0x39327
movl $0x2a, %edx
leaq 0x2325a(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x3, %edi
movl $0x3d, %esi
movl $0x34, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbdb99(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x23312(%rip), %rsi     # 0x3943c
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x1614d
jmp 0x1614f
jmp 0x1616e
leaq 0x2c0d6(%rip), %rdi     # 0x4222c
leaq 0x231ca(%rip), %rsi     # 0x39327
movl $0x30, %edx
leaq 0x231d3(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x5, %edi
movl $0x18, %esi
movl $0x33, %edx
movl $0x1, %ecx
callq 0xa890
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbdb0d(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x232c5(%rip), %rsi     # 0x3947b
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x161d9
jmp 0x161db
jmp 0x161fa
leaq 0x2c04a(%rip), %rdi     # 0x4222c
leaq 0x2313e(%rip), %rsi     # 0x39327
movl $0x36, %edx
leaq 0x23147(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x2, %edi
movl $0x39, %esi
movl $0x33, %edx
movl $0x5, %ecx
callq 0xa890
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbda81(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x23277(%rip), %rsi     # 0x394b9
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x16265
jmp 0x16267
jmp 0x16286
leaq 0x2bfbe(%rip), %rdi     # 0x4222c
leaq 0x230b2(%rip), %rsi     # 0x39327
movl $0x3c, %edx
leaq 0x230bb(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x1, %edi
movl $0x1a, %esi
movl $0x22, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbd9fa(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x2322e(%rip), %rsi     # 0x394f7
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x162ec
jmp 0x162ee
jmp 0x1630d
leaq 0x2bf37(%rip), %rdi     # 0x4222c
leaq 0x2302b(%rip), %rsi     # 0x39327
movl $0x42, %edx
leaq 0x23034(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x6, %edi
movl $0x3c, %esi
movl $0x3e, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0xaa60
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbd967(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x231d9(%rip), %rsi     # 0x39535
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x1637f
jmp 0x16381
jmp 0x163a0
leaq 0x2bea4(%rip), %rdi     # 0x4222c
leaq 0x22f98(%rip), %rsi     # 0x39327
movl $0x49, %edx
leaq 0x22fa1(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x6, %edi
movl $0x4, %esi
movl $0x3, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbd8e0(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x2318f(%rip), %rsi     # 0x39572
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x16406
jmp 0x16408
jmp 0x16427
leaq 0x2be1d(%rip), %rdi     # 0x4222c
leaq 0x22f11(%rip), %rsi     # 0x39327
movl $0x50, %edx
leaq 0x22f1a(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x1, %edi
movl $0x31, %esi
movl $0x21, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbd859(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x23144(%rip), %rsi     # 0x395ae
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x1648d
jmp 0x1648f
jmp 0x164ae
leaq 0x2bd96(%rip), %rdi     # 0x4222c
leaq 0x22e8a(%rip), %rsi     # 0x39327
movl $0x56, %edx
leaq 0x22e93(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x1, %edi
movl $0x22, %esi
movl $0x29, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0xaa20
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbd7c6(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x230ef(%rip), %rsi     # 0x395ec
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x16520
jmp 0x16522
jmp 0x16541
leaq 0x2bd03(%rip), %rdi     # 0x4222c
leaq 0x22df7(%rip), %rsi     # 0x39327
movl $0x5d, %edx
leaq 0x22e00(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x4, %edi
movl $0x3d, %esi
movl $0x3c, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbd73f(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x230a4(%rip), %rsi     # 0x39628
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x165a7
jmp 0x165a9
jmp 0x165c8
leaq 0x2bc7c(%rip), %rdi     # 0x4222c
leaq 0x22d70(%rip), %rsi     # 0x39327
movl $0x63, %edx
leaq 0x22d79(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x1, %edi
movl $0x29, %esi
movl $0x31, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbd6b8(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x23059(%rip), %rsi     # 0x39664
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x1662e
jmp 0x16630
jmp 0x1664f
leaq 0x2bbf5(%rip), %rdi     # 0x4222c
leaq 0x22ce9(%rip), %rsi     # 0x39327
movl $0x69, %edx
leaq 0x22cf2(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x6, %edi
movl $0x3e, %esi
movl $0x3f, %edx
callq 0xa830
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbd631(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x2300c(%rip), %rsi     # 0x3969e
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x166b5
jmp 0x166b7
jmp 0x166d6
leaq 0x2bb6e(%rip), %rdi     # 0x4222c
leaq 0x22c62(%rip), %rsi     # 0x39327
movl $0x6f, %edx
leaq 0x22c6b(%rip), %rcx     # 0x3933c
callq 0x20c0
movl $0x1, %edi
movl $0x31, %esi
movl $0x38, %edx
movl $0x4, %ecx
callq 0xa890
movq %rax, -0x1d0(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x2, %esi
callq 0xa9e0
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xbd594(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x398(%rbp), %rdi
leaq 0x22fa8(%rip), %rsi     # 0x396d7
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x16752
jmp 0x16754
jmp 0x16773
leaq 0x2bad1(%rip), %rdi     # 0x4222c
leaq 0x22bc5(%rip), %rsi     # 0x39327
movl $0x76, %edx
leaq 0x22bce(%rip), %rcx     # 0x3933c
callq 0x20c0
addq $0x3a0, %rsp            # imm = 0x3A0
popq %rbp
retq
nopl (%rax)