// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x398, %rsp            # imm = 0x398
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
callq 0xa187
pushq $0x1
popq %rbp
pushq $0x34
popq %rsi
pushq $0x24
popq %rdx
movl %ebp, %edi
callq 0x7284
movq %rax, (%rsp)
leaq 0xbd3a0(%rip), %rdx     # 0xcbaf0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1cd41(%rip), %rsi     # 0x2b4a3
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xa1b8
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x98c8
testb %al, %al
je 0xecd1
pushq $0x1
popq %rbx
pushq $0xa
popq %rsi
pushq $0x1a
popq %rdx
movl %ebx, %edi
callq 0x7284
leaq 0xbd355(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1cd56(%rip), %rsi     # 0x2b50b
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xa1b8
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x98c8
testb %al, %al
je 0xeced
pushq $0x2
popq %rdi
pushq $0x3e
popq %rsi
pushq $0x2d
popq %rdx
callq 0x7284
leaq 0xbd304(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1cd43(%rip), %rsi     # 0x2b549
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xa1b8
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x98c8
testb %al, %al
je 0xed09
cmpl $0x1, 0x150(%rsp)
jne 0xed25
pushq $0x5
popq %rdi
pushq $0x3
popq %rsi
pushq $0x18
popq %rdx
callq 0x7284
leaq 0xbd2a4(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1cd38(%rip), %rsi     # 0x2b59e
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xa1b8
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x98c8
testb %al, %al
je 0xed41
cmpl $0x2, 0x150(%rsp)
jne 0xed5d
pushq $0x3
popq %rdi
pushq $0x3d
popq %rsi
pushq $0x34
popq %rdx
callq 0x7284
movq %rax, (%rsp)
leaq 0xbd240(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1cd2a(%rip), %rsi     # 0x2b5f4
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xa1b8
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x98c8
testb %al, %al
je 0xed79
pushq $0x5
popq %rdi
pushq $0x18
popq %rsi
pushq $0x33
popq %rdx
pushq $0x1
popq %rbx
movl %ebx, %ecx
callq 0x72a3
leaq 0xbd1e9(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1cd12(%rip), %rsi     # 0x2b633
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xa1b8
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x98c8
testb %al, %al
je 0xed95
pushq $0x2
popq %rdi
pushq $0x39
popq %rsi
pushq $0x33
popq %rdx
pushq $0x5
popq %rcx
callq 0x72a3
leaq 0xbd195(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1ccfc(%rip), %rsi     # 0x2b671
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xa1b8
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x98c8
testb %al, %al
je 0xedb1
pushq $0x1
popq %rbx
pushq $0x1a
popq %rsi
pushq $0x22
popq %rdx
movl %ebx, %edi
callq 0x7284
leaq 0xbd141(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1cce6(%rip), %rsi     # 0x2b6af
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xa1b8
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x98c8
testb %al, %al
je 0xedcd
pushq $0x6
popq %rdi
pushq $0x3c
popq %rsi
pushq $0x3e
popq %rdx
callq 0x7284
movq %rsp, %rbx
movq %rax, (%rbx)
movq %rbx, %rdi
callq 0x7366
movq (%rbx), %rsi
leaq 0xbd0df(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
callq 0x2fa5
leaq 0x1ccc5(%rip), %rsi     # 0x2b6ed
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xa1b8
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x98c8
testb %al, %al
je 0xede9
pushq $0x6
popq %rdi
pushq $0x4
popq %rsi
pushq $0x3
popq %rdx
callq 0x7284
movq %rax, (%rsp)
leaq 0xbd08c(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1ccac(%rip), %rsi     # 0x2b72a
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xa1b8
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x98c8
testb %al, %al
je 0xee05
pushq $0x1
popq %rbx
pushq $0x31
popq %rsi
pushq $0x21
popq %rdx
movl %ebx, %edi
callq 0x7284
movq %rax, (%rsp)
leaq 0xbd034(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1cc90(%rip), %rsi     # 0x2b766
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xa1b8
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x98c8
testb %al, %al
je 0xee21
pushq $0x1
popq %rbx
pushq $0x22
popq %rsi
pushq $0x29
popq %rdx
movl %ebx, %edi
callq 0x7284
movq %rsp, %r14
movq %rax, (%r14)
movq %r14, %rdi
callq 0x7352
movq (%r14), %rsi
leaq 0xbcfd0(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %r14
movq %r14, %rdi
callq 0x2fa5
leaq 0x1cc6d(%rip), %rsi     # 0x2b7a4
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xa1b8
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x98c8
testb %al, %al
je 0xee3a
pushq $0x4
popq %rdi
pushq $0x3d
popq %rsi
pushq $0x3c
popq %rdx
callq 0x7284
movq %rax, (%rsp)
leaq 0xbcf7e(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1cc54(%rip), %rsi     # 0x2b7e0
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xa1b8
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x98c8
testb %al, %al
je 0xee53
pushq $0x1
popq %rbx
pushq $0x29
popq %rsi
pushq $0x31
popq %rdx
movl %ebx, %edi
callq 0x7284
movq %rax, (%rsp)
leaq 0xbcf26(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1cc38(%rip), %rsi     # 0x2b81c
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xa1b8
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x98c8
testb %al, %al
je 0xee6c
pushq $0x6
popq %rdi
pushq $0x3e
popq %rsi
pushq $0x3f
popq %rdx
callq 0x7284
movq %rax, (%rsp)
leaq 0xbced1(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2fa5
leaq 0x1cc1d(%rip), %rsi     # 0x2b856
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xa1b8
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x98c8
testb %al, %al
je 0xee85
pushq $0x1
popq %rbx
pushq $0x31
popq %rsi
pushq $0x38
popq %rdx
pushq $0x4
popq %rcx
movl %ebx, %edi
callq 0x72a3
movq %rsp, %r14
movq %rax, (%r14)
pushq $0x2
popq %rsi
movq %r14, %rdi
callq 0x733b
movq (%r14), %rsi
leaq 0xbce66(%rip), %rdx     # 0xcbaf0
leaq 0x1d0(%rsp), %r14
movq %r14, %rdi
callq 0x2fa5
leaq 0x1cbee(%rip), %rsi     # 0x2b88f
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xa1b8
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x98c8
testb %al, %al
je 0xee9e
addq $0x398, %rsp            # imm = 0x398
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x24dc3(%rip), %rdi     # 0x33a9b
leaq 0x1c800(%rip), %rsi     # 0x2b4df
leaq 0x1c80e(%rip), %rcx     # 0x2b4f4
pushq $0x16
jmp 0xeeb5
leaq 0x24da7(%rip), %rdi     # 0x33a9b
leaq 0x1c7e4(%rip), %rsi     # 0x2b4df
leaq 0x1c7f2(%rip), %rcx     # 0x2b4f4
pushq $0x1c
jmp 0xeeb5
leaq 0x24d8b(%rip), %rdi     # 0x33a9b
leaq 0x1c7c8(%rip), %rsi     # 0x2b4df
leaq 0x1c7d6(%rip), %rcx     # 0x2b4f4
pushq $0x22
jmp 0xeeb5
leaq 0x1c85c(%rip), %rdi     # 0x2b588
leaq 0x1c7ac(%rip), %rsi     # 0x2b4df
leaq 0x1c7ba(%rip), %rcx     # 0x2b4f4
pushq $0x23
jmp 0xeeb5
leaq 0x24d53(%rip), %rdi     # 0x33a9b
leaq 0x1c790(%rip), %rsi     # 0x2b4df
leaq 0x1c79e(%rip), %rcx     # 0x2b4f4
pushq $0x29
jmp 0xeeb5
leaq 0x1c87a(%rip), %rdi     # 0x2b5de
leaq 0x1c774(%rip), %rsi     # 0x2b4df
leaq 0x1c782(%rip), %rcx     # 0x2b4f4
pushq $0x2a
jmp 0xeeb5
leaq 0x24d1b(%rip), %rdi     # 0x33a9b
leaq 0x1c758(%rip), %rsi     # 0x2b4df
leaq 0x1c766(%rip), %rcx     # 0x2b4f4
pushq $0x30
jmp 0xeeb5
leaq 0x24cff(%rip), %rdi     # 0x33a9b
leaq 0x1c73c(%rip), %rsi     # 0x2b4df
leaq 0x1c74a(%rip), %rcx     # 0x2b4f4
pushq $0x36
jmp 0xeeb5
leaq 0x24ce3(%rip), %rdi     # 0x33a9b
leaq 0x1c720(%rip), %rsi     # 0x2b4df
leaq 0x1c72e(%rip), %rcx     # 0x2b4f4
pushq $0x3c
jmp 0xeeb5
leaq 0x24cc7(%rip), %rdi     # 0x33a9b
leaq 0x1c704(%rip), %rsi     # 0x2b4df
leaq 0x1c712(%rip), %rcx     # 0x2b4f4
pushq $0x42
jmp 0xeeb5
leaq 0x24cab(%rip), %rdi     # 0x33a9b
leaq 0x1c6e8(%rip), %rsi     # 0x2b4df
leaq 0x1c6f6(%rip), %rcx     # 0x2b4f4
pushq $0x49
jmp 0xeeb5
leaq 0x24c8f(%rip), %rdi     # 0x33a9b
leaq 0x1c6cc(%rip), %rsi     # 0x2b4df
leaq 0x1c6da(%rip), %rcx     # 0x2b4f4
pushq $0x50
jmp 0xeeb5
leaq 0x24c73(%rip), %rdi     # 0x33a9b
leaq 0x1c6b0(%rip), %rsi     # 0x2b4df
leaq 0x1c6be(%rip), %rcx     # 0x2b4f4
pushq $0x56
jmp 0xeeb5
leaq 0x24c5a(%rip), %rdi     # 0x33a9b
leaq 0x1c697(%rip), %rsi     # 0x2b4df
leaq 0x1c6a5(%rip), %rcx     # 0x2b4f4
pushq $0x5d
jmp 0xeeb5
leaq 0x24c41(%rip), %rdi     # 0x33a9b
leaq 0x1c67e(%rip), %rsi     # 0x2b4df
leaq 0x1c68c(%rip), %rcx     # 0x2b4f4
pushq $0x63
jmp 0xeeb5
leaq 0x24c28(%rip), %rdi     # 0x33a9b
leaq 0x1c665(%rip), %rsi     # 0x2b4df
leaq 0x1c673(%rip), %rcx     # 0x2b4f4
pushq $0x69
jmp 0xeeb5
leaq 0x24c0f(%rip), %rdi     # 0x33a9b
leaq 0x1c64c(%rip), %rsi     # 0x2b4df
leaq 0x1c65a(%rip), %rcx     # 0x2b4f4
pushq $0x6f
jmp 0xeeb5
leaq 0x24bf6(%rip), %rdi     # 0x33a9b
leaq 0x1c633(%rip), %rsi     # 0x2b4df
leaq 0x1c641(%rip), %rcx     # 0x2b4f4
pushq $0x76
popq %rdx
callq 0x20c0