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

    position pos2;
    assert(set_pos(&pos2,"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"));
    assert(equal_pos(&pos1,&pos2,true));

    /////
    assert(set_pos(&pos2,"8/7p/5k2/5p2/p1p2P2/Pr1pPK2/1P1R3P/8 b - - 12 47"));
    for (int32 sq=A8;sq<=G7;sq++) {
        assert(pos2.piece[sq]==NO_PIECE);
    }
    assert(pos2.piece[H7]==-PAWN);
    for (int32 sq=A6;sq<=E6;sq++) {
        assert(pos2.piece[sq]==NO_PIECE);
    }
    assert(pos2.piece[F6]==-KING);
    assert(pos2.black_king==F6);
    for (int32 sq=G6;sq<=E5;sq++) {
        assert(pos2.piece[sq]==NO_PIECE);
    }
    assert(pos2.piece[F5]==-PAWN);
    assert(pos2.piece[G5]==NO_PIECE);
    assert(pos2.piece[H5]==NO_PIECE);
    assert(pos2.piece[A4]==-PAWN);
    assert(pos2.piece[B4]==NO_PIECE);
    assert(pos2.piece[C4]==-PAWN);
    assert(pos2.piece[D4]==NO_PIECE);
    assert(pos2.piece[E4]==NO_PIECE);
    assert(pos2.piece[F4]==PAWN);
    assert(pos2.piece[G4]==NO_PIECE);
    assert(pos2.piece[H4]==NO_PIECE);
    assert(pos2.piece[A3]==PAWN);
    assert(pos2.piece[B3]==-ROOK);
    assert(pos2.piece[C3]==NO_PIECE);
    assert(pos2.piece[D3]==-PAWN);
    assert(pos2.piece[E3]==PAWN);
    assert(pos2.piece[F3]==KING);
    assert(pos2.white_king==F3);
    assert(pos2.piece[G3]==NO_PIECE);
    assert(pos2.piece[H3]==NO_PIECE);
    assert(pos2.piece[A2]==NO_PIECE);
    assert(pos2.piece[B2]==PAWN);
    assert(pos2.piece[C2]==NO_PIECE);
    assert(pos2.piece[D2]==ROOK);
    assert(pos2.piece[E2]==NO_PIECE);
    assert(pos2.piece[F2]==NO_PIECE);
    assert(pos2.piece[G2]==NO_PIECE);
    assert(pos2.piece[H2]==PAWN);
    for (int32 sq=A1;sq<=H1;sq++) {
        assert(pos2.piece[sq]==NO_PIECE);
    }
    assert(pos2.player==BLACK);
    assert(pos2.ep_sq==NO_SQUARE);
    assert(pos2.castling_rights==0);
    assert(pos2.fifty_counter==12);
    assert(pos2.move_counter==93);

    //////
    assert(set_pos(&pos2,"rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1"));
    assert(pos2.player==BLACK);
    assert(can_castle_wk(&pos2));
    assert(can_castle_wq(&pos2));
    assert(can_castle_bk(&pos2));
    assert(can_castle_bq(&pos2));
    assert(pos2.ep_sq==E3);
    assert(pos2.fifty_counter==0);
    assert(pos2.move_counter==1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3a0, %rsp            # imm = 0x3A0
leaq -0x1c8(%rbp), %rdi
callq 0xf390
leaq -0x390(%rbp), %rdi
leaq 0xa1fc(%rip), %rsi      # 0x370e1
callq 0xf3e0
testb $0x1, %al
jne 0x2cef0
jmp 0x2cef2
jmp 0x2cf11
leaq 0x1534f(%rip), %rdi     # 0x42248
leaq 0x1505d(%rip), %rsi     # 0x41f5d
movl $0x90, %edx
leaq 0x15386(%rip), %rcx     # 0x42292
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq -0x390(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
testb $0x1, %al
jne 0x2cf2f
jmp 0x2cf31
jmp 0x2cf50
leaq 0x152f4(%rip), %rdi     # 0x4222c
leaq 0x1501e(%rip), %rsi     # 0x41f5d
movl $0x91, %edx
leaq 0x15347(%rip), %rcx     # 0x42292
callq 0x20c0
leaq -0x390(%rbp), %rdi
leaq 0x15348(%rip), %rsi     # 0x422a6
callq 0xf3e0
testb $0x1, %al
jne 0x2cf69
jmp 0x2cf6b
jmp 0x2cf8a
leaq 0x15365(%rip), %rdi     # 0x422d7
leaq 0x14fe4(%rip), %rsi     # 0x41f5d
movl $0x94, %edx
leaq 0x1530d(%rip), %rcx     # 0x42292
callq 0x20c0
movl $0x0, -0x394(%rbp)
cmpl $0xe, -0x394(%rbp)
jg 0x2cfe2
movslq -0x394(%rbp), %rax
cmpl $0x0, -0x390(%rbp,%rax,4)
jne 0x2cfb0
jmp 0x2cfcf
leaq 0x15362(%rip), %rdi     # 0x42319
leaq 0x14f9f(%rip), %rsi     # 0x41f5d
movl $0x96, %edx
leaq 0x152c8(%rip), %rcx     # 0x42292
callq 0x20c0
jmp 0x2cfd1
movl -0x394(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x394(%rbp)
jmp 0x2cf94
cmpl $-0x1, -0x354(%rbp)
jne 0x2cfed
jmp 0x2d00c
leaq 0x1533e(%rip), %rdi     # 0x42332
leaq 0x14f62(%rip), %rsi     # 0x41f5d
movl $0x98, %edx
leaq 0x1528b(%rip), %rcx     # 0x42292
callq 0x20c0
movl $0x10, -0x398(%rbp)
cmpl $0x14, -0x398(%rbp)
jg 0x2d064
movslq -0x398(%rbp), %rax
cmpl $0x0, -0x390(%rbp,%rax,4)
jne 0x2d032
jmp 0x2d051
leaq 0x152e0(%rip), %rdi     # 0x42319
leaq 0x14f1d(%rip), %rsi     # 0x41f5d
movl $0x9a, %edx
leaq 0x15246(%rip), %rcx     # 0x42292
callq 0x20c0
jmp 0x2d053
movl -0x398(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x398(%rbp)
jmp 0x2d016
cmpl $-0x6, -0x33c(%rbp)
jne 0x2d06f
jmp 0x2d08e
leaq 0x152d2(%rip), %rdi     # 0x42348
leaq 0x14ee0(%rip), %rsi     # 0x41f5d
movl $0x9c, %edx
leaq 0x15209(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x15, -0x240(%rbp)
jne 0x2d099
jmp 0x2d0b8
leaq 0x152be(%rip), %rdi     # 0x4235e
leaq 0x14eb6(%rip), %rsi     # 0x41f5d
movl $0x9d, %edx
leaq 0x151df(%rip), %rcx     # 0x42292
callq 0x20c0
movl $0x16, -0x39c(%rbp)
cmpl $0x1c, -0x39c(%rbp)
jg 0x2d110
movslq -0x39c(%rbp), %rax
cmpl $0x0, -0x390(%rbp,%rax,4)
jne 0x2d0de
jmp 0x2d0fd
leaq 0x15234(%rip), %rdi     # 0x42319
leaq 0x14e71(%rip), %rsi     # 0x41f5d
movl $0x9f, %edx
leaq 0x1519a(%rip), %rcx     # 0x42292
callq 0x20c0
jmp 0x2d0ff
movl -0x39c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x39c(%rbp)
jmp 0x2d0c2
cmpl $-0x1, -0x31c(%rbp)
jne 0x2d11b
jmp 0x2d13a
leaq 0x15250(%rip), %rdi     # 0x42372
leaq 0x14e34(%rip), %rsi     # 0x41f5d
movl $0xa1, %edx
leaq 0x1515d(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x318(%rbp)
jne 0x2d145
jmp 0x2d164
leaq 0x1523c(%rip), %rdi     # 0x42388
leaq 0x14e0a(%rip), %rsi     # 0x41f5d
movl $0xa2, %edx
leaq 0x15133(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x314(%rbp)
jne 0x2d16f
jmp 0x2d18e
leaq 0x1522b(%rip), %rdi     # 0x423a1
leaq 0x14de0(%rip), %rsi     # 0x41f5d
movl $0xa3, %edx
leaq 0x15109(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $-0x1, -0x310(%rbp)
jne 0x2d199
jmp 0x2d1b8
leaq 0x1521a(%rip), %rdi     # 0x423ba
leaq 0x14db6(%rip), %rsi     # 0x41f5d
movl $0xa4, %edx
leaq 0x150df(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x30c(%rbp)
jne 0x2d1c3
jmp 0x2d1e2
leaq 0x15206(%rip), %rdi     # 0x423d0
leaq 0x14d8c(%rip), %rsi     # 0x41f5d
movl $0xa5, %edx
leaq 0x150b5(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $-0x1, -0x308(%rbp)
jne 0x2d1ed
jmp 0x2d20c
leaq 0x151f5(%rip), %rdi     # 0x423e9
leaq 0x14d62(%rip), %rsi     # 0x41f5d
movl $0xa6, %edx
leaq 0x1508b(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x304(%rbp)
jne 0x2d217
jmp 0x2d236
leaq 0x151e1(%rip), %rdi     # 0x423ff
leaq 0x14d38(%rip), %rsi     # 0x41f5d
movl $0xa7, %edx
leaq 0x15061(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x300(%rbp)
jne 0x2d241
jmp 0x2d260
leaq 0x151d0(%rip), %rdi     # 0x42418
leaq 0x14d0e(%rip), %rsi     # 0x41f5d
movl $0xa8, %edx
leaq 0x15037(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x1, -0x2fc(%rbp)
jne 0x2d26b
jmp 0x2d28a
leaq 0x151bf(%rip), %rdi     # 0x42431
leaq 0x14ce4(%rip), %rsi     # 0x41f5d
movl $0xa9, %edx
leaq 0x1500d(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x2f8(%rbp)
jne 0x2d295
jmp 0x2d2b4
leaq 0x151aa(%rip), %rdi     # 0x42446
leaq 0x14cba(%rip), %rsi     # 0x41f5d
movl $0xaa, %edx
leaq 0x14fe3(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x2f4(%rbp)
jne 0x2d2bf
jmp 0x2d2de
leaq 0x15199(%rip), %rdi     # 0x4245f
leaq 0x14c90(%rip), %rsi     # 0x41f5d
movl $0xab, %edx
leaq 0x14fb9(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x1, -0x2f0(%rbp)
jne 0x2d2e9
jmp 0x2d308
leaq 0x15188(%rip), %rdi     # 0x42478
leaq 0x14c66(%rip), %rsi     # 0x41f5d
movl $0xac, %edx
leaq 0x14f8f(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $-0x4, -0x2ec(%rbp)
jne 0x2d313
jmp 0x2d332
leaq 0x15173(%rip), %rdi     # 0x4248d
leaq 0x14c3c(%rip), %rsi     # 0x41f5d
movl $0xad, %edx
leaq 0x14f65(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x2e8(%rbp)
jne 0x2d33d
jmp 0x2d35c
leaq 0x1515f(%rip), %rdi     # 0x424a3
leaq 0x14c12(%rip), %rsi     # 0x41f5d
movl $0xae, %edx
leaq 0x14f3b(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $-0x1, -0x2e4(%rbp)
jne 0x2d367
jmp 0x2d386
leaq 0x1514e(%rip), %rdi     # 0x424bc
leaq 0x14be8(%rip), %rsi     # 0x41f5d
movl $0xaf, %edx
leaq 0x14f11(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x1, -0x2e0(%rbp)
jne 0x2d391
jmp 0x2d3b0
leaq 0x1513a(%rip), %rdi     # 0x424d2
leaq 0x14bbe(%rip), %rsi     # 0x41f5d
movl $0xb0, %edx
leaq 0x14ee7(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x6, -0x2dc(%rbp)
jne 0x2d3bb
jmp 0x2d3da
leaq 0x15125(%rip), %rdi     # 0x424e7
leaq 0x14b94(%rip), %rsi     # 0x41f5d
movl $0xb1, %edx
leaq 0x14ebd(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x2d, -0x244(%rbp)
jne 0x2d3e5
jmp 0x2d404
leaq 0x15110(%rip), %rdi     # 0x424fc
leaq 0x14b6a(%rip), %rsi     # 0x41f5d
movl $0xb2, %edx
leaq 0x14e93(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x2d8(%rbp)
jne 0x2d40f
jmp 0x2d42e
leaq 0x150fa(%rip), %rdi     # 0x42510
leaq 0x14b40(%rip), %rsi     # 0x41f5d
movl $0xb3, %edx
leaq 0x14e69(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x2d4(%rbp)
jne 0x2d439
jmp 0x2d458
leaq 0x150e9(%rip), %rdi     # 0x42529
leaq 0x14b16(%rip), %rsi     # 0x41f5d
movl $0xb4, %edx
leaq 0x14e3f(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x2d0(%rbp)
jne 0x2d463
jmp 0x2d482
leaq 0x150d8(%rip), %rdi     # 0x42542
leaq 0x14aec(%rip), %rsi     # 0x41f5d
movl $0xb5, %edx
leaq 0x14e15(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x1, -0x2cc(%rbp)
jne 0x2d48d
jmp 0x2d4ac
leaq 0x150c7(%rip), %rdi     # 0x4255b
leaq 0x14ac2(%rip), %rsi     # 0x41f5d
movl $0xb6, %edx
leaq 0x14deb(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x2c8(%rbp)
jne 0x2d4b7
jmp 0x2d4d6
leaq 0x150b2(%rip), %rdi     # 0x42570
leaq 0x14a98(%rip), %rsi     # 0x41f5d
movl $0xb7, %edx
leaq 0x14dc1(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x4, -0x2c4(%rbp)
jne 0x2d4e1
jmp 0x2d500
leaq 0x150a1(%rip), %rdi     # 0x42589
leaq 0x14a6e(%rip), %rsi     # 0x41f5d
movl $0xb8, %edx
leaq 0x14d97(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x2c0(%rbp)
jne 0x2d50b
jmp 0x2d52a
leaq 0x1508c(%rip), %rdi     # 0x4259e
leaq 0x14a44(%rip), %rsi     # 0x41f5d
movl $0xb9, %edx
leaq 0x14d6d(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x2bc(%rbp)
jne 0x2d535
jmp 0x2d554
leaq 0x1507b(%rip), %rdi     # 0x425b7
leaq 0x14a1a(%rip), %rsi     # 0x41f5d
movl $0xba, %edx
leaq 0x14d43(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x2b8(%rbp)
jne 0x2d55f
jmp 0x2d57e
leaq 0x1506a(%rip), %rdi     # 0x425d0
leaq 0x149f0(%rip), %rsi     # 0x41f5d
movl $0xbb, %edx
leaq 0x14d19(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x1, -0x2b4(%rbp)
jne 0x2d589
jmp 0x2d5a8
leaq 0x15059(%rip), %rdi     # 0x425e9
leaq 0x149c6(%rip), %rsi     # 0x41f5d
movl $0xbc, %edx
leaq 0x14cef(%rip), %rcx     # 0x42292
callq 0x20c0
movl $0x38, -0x3a0(%rbp)
cmpl $0x3f, -0x3a0(%rbp)
jg 0x2d600
movslq -0x3a0(%rbp), %rax
cmpl $0x0, -0x390(%rbp,%rax,4)
jne 0x2d5ce
jmp 0x2d5ed
leaq 0x14d44(%rip), %rdi     # 0x42319
leaq 0x14981(%rip), %rsi     # 0x41f5d
movl $0xbe, %edx
leaq 0x14caa(%rip), %rcx     # 0x42292
callq 0x20c0
jmp 0x2d5ef
movl -0x3a0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3a0(%rbp)
jmp 0x2d5b2
cmpl $0x0, -0x258(%rbp)
jne 0x2d60b
jmp 0x2d62a
leaq 0x14fec(%rip), %rdi     # 0x425fe
leaq 0x14944(%rip), %rsi     # 0x41f5d
movl $0xc0, %edx
leaq 0x14c6d(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x40, -0x254(%rbp)
jne 0x2d635
jmp 0x2d654
leaq 0x14fd5(%rip), %rdi     # 0x42611
leaq 0x1491a(%rip), %rsi     # 0x41f5d
movl $0xc1, %edx
leaq 0x14c43(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x250(%rbp)
jne 0x2d65f
jmp 0x2d67e
leaq 0x14fc1(%rip), %rdi     # 0x42627
leaq 0x148f0(%rip), %rsi     # 0x41f5d
movl $0xc2, %edx
leaq 0x14c19(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0xc, -0x248(%rbp)
jne 0x2d689
jmp 0x2d6a8
leaq 0x14faf(%rip), %rdi     # 0x4263f
leaq 0x148c6(%rip), %rsi     # 0x41f5d
movl $0xc3, %edx
leaq 0x14bef(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x5d, -0x24c(%rbp)
jne 0x2d6b3
jmp 0x2d6d2
leaq 0x14f9c(%rip), %rdi     # 0x42656
leaq 0x1489c(%rip), %rsi     # 0x41f5d
movl $0xc4, %edx
leaq 0x14bc5(%rip), %rcx     # 0x42292
callq 0x20c0
leaq -0x390(%rbp), %rdi
leaq 0xbc0b(%rip), %rsi      # 0x392eb
callq 0xf3e0
testb $0x1, %al
jne 0x2d6eb
jmp 0x2d6ed
jmp 0x2d70c
leaq 0x14f78(%rip), %rdi     # 0x4266c
leaq 0x14862(%rip), %rsi     # 0x41f5d
movl $0xc7, %edx
leaq 0x14b8b(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x258(%rbp)
jne 0x2d717
jmp 0x2d736
leaq 0x14ee0(%rip), %rdi     # 0x425fe
leaq 0x14838(%rip), %rsi     # 0x41f5d
movl $0xc8, %edx
leaq 0x14b61(%rip), %rcx     # 0x42292
callq 0x20c0
leaq -0x390(%rbp), %rdi
callq 0xf1e0
testb $0x1, %al
jne 0x2d748
jmp 0x2d74a
jmp 0x2d769
leaq 0x14f68(%rip), %rdi     # 0x426b9
leaq 0x14805(%rip), %rsi     # 0x41f5d
movl $0xc9, %edx
leaq 0x14b2e(%rip), %rcx     # 0x42292
callq 0x20c0
leaq -0x390(%rbp), %rdi
callq 0xf200
testb $0x1, %al
jne 0x2d77b
jmp 0x2d77d
jmp 0x2d79c
leaq 0x14f4a(%rip), %rdi     # 0x426ce
leaq 0x147d2(%rip), %rsi     # 0x41f5d
movl $0xca, %edx
leaq 0x14afb(%rip), %rcx     # 0x42292
callq 0x20c0
leaq -0x390(%rbp), %rdi
callq 0xf220
testb $0x1, %al
jne 0x2d7ae
jmp 0x2d7b0
jmp 0x2d7cf
leaq 0x14f2c(%rip), %rdi     # 0x426e3
leaq 0x1479f(%rip), %rsi     # 0x41f5d
movl $0xcb, %edx
leaq 0x14ac8(%rip), %rcx     # 0x42292
callq 0x20c0
leaq -0x390(%rbp), %rdi
callq 0xf240
testb $0x1, %al
jne 0x2d7e1
jmp 0x2d7e3
jmp 0x2d802
leaq 0x14f0e(%rip), %rdi     # 0x426f8
leaq 0x1476c(%rip), %rsi     # 0x41f5d
movl $0xcc, %edx
leaq 0x14a95(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x2c, -0x254(%rbp)
jne 0x2d80d
jmp 0x2d82c
leaq 0x14ef9(%rip), %rdi     # 0x4270d
leaq 0x14742(%rip), %rsi     # 0x41f5d
movl $0xcd, %edx
leaq 0x14a6b(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x0, -0x248(%rbp)
jne 0x2d837
jmp 0x2d856
leaq 0x14ede(%rip), %rdi     # 0x4271c
leaq 0x14718(%rip), %rsi     # 0x41f5d
movl $0xce, %edx
leaq 0x14a41(%rip), %rcx     # 0x42292
callq 0x20c0
cmpl $0x1, -0x24c(%rbp)
jne 0x2d861
jmp 0x2d880
leaq 0x14eca(%rip), %rdi     # 0x42732
leaq 0x146ee(%rip), %rsi     # 0x41f5d
movl $0xcf, %edx
leaq 0x14a17(%rip), %rcx     # 0x42292
callq 0x20c0
addq $0x3a0, %rsp            # imm = 0x3A0
popq %rbp
retq
nopl (%rax)