// File: /workspace/github_cpp_makefile_star2_O1/cpirc[P]Monochrome/src/position.cpp
// Function: print_position_struct(Position const&)
void print_position_struct(const Position &pos) {
    const char *piece_name[] = {"PAWN", "KNIGHT", "BISHOP",
                                "ROOK", "QUEEN",  "KING"};

    for (unsigned char p = PAWN; p <= KING; p++) {
        printf("%s positions:\n", piece_name[p]);
        PRINT_BITBOARD(pos.pieces[p]);
    }

    printf("Positions of our pieces:\n");
    PRINT_BITBOARD(pos.colours[US]);

    printf("Positions of their pieces:\n");
    PRINT_BITBOARD(pos.colours[THEM]);

    // printf("Side to move is: %s\n\n", (pos.flipped == true) ? "THEM" : "US");

    if ((pos.castle & (1 << 3))) printf("White king can castle kingside\n");
    if ((pos.castle & (1 << 2))) printf("White king can castle queenside\n");

    if ((pos.castle & (1 << 1))) printf("Black king can castle kingside\n");
    if ((pos.castle & (1 << 0))) printf("Black king can castle queenside\n");

    if (pos.epsq != INVALID_SQUARE)
        printf("\nEn passant square is: %u\n", (unsigned int)pos.epsq);

    printf("Number of half moves: %d\n", (int)pos.halfmoves);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x5b53(%rip), %r12      # 0xccd0
leaq 0x5b9d(%rip), %r15      # 0xcd21
xorl %r13d, %r13d
movslq (%r12,%r13,4), %rsi
addq %r12, %rsi
leaq 0x5b7d(%rip), %rdi      # 0xcd12
xorl %eax, %eax
callq 0x3040
xorl %r14d, %r14d
movq (%rbx,%r13,8), %rax
movl %r14d, %ecx
xorb $0x38, %cl
movzbl %cl, %ecx
xorl %esi, %esi
btq %rcx, %rax
setb %sil
movq %r15, %rdi
xorl %eax, %eax
callq 0x3040
incl %r14d
testb $0x7, %r14b
jne 0x71d3
movl $0xa, %edi
callq 0x3220
cmpl $0x40, %r14d
jne 0x719f
movl $0xa, %edi
callq 0x3220
incq %r13
cmpq $0x6, %r13
jne 0x7187
leaq 0x5ccb(%rip), %rdi      # 0xcebe
callq 0x3260
leaq 0x5b22(%rip), %r14      # 0xcd21
xorl %r15d, %r15d
movq 0x30(%rbx), %rax
movl %r15d, %ecx
xorb $0x38, %cl
movzbl %cl, %ecx
xorl %esi, %esi
btq %rcx, %rax
setb %sil
movq %r14, %rdi
xorl %eax, %eax
callq 0x3040
incl %r15d
testb $0x7, %r15b
jne 0x7236
movl $0xa, %edi
callq 0x3220
cmpl $0x40, %r15d
jne 0x7202
movl $0xa, %edi
callq 0x3220
leaq 0x5c8a(%rip), %rdi      # 0xced7
callq 0x3260
leaq 0x5ac8(%rip), %r14      # 0xcd21
xorl %r15d, %r15d
movq 0x38(%rbx), %rax
movl %r15d, %ecx
xorb $0x38, %cl
movzbl %cl, %ecx
xorl %esi, %esi
btq %rcx, %rax
setb %sil
movq %r14, %rdi
xorl %eax, %eax
callq 0x3040
incl %r15d
testb $0x7, %r15b
jne 0x7290
movl $0xa, %edi
callq 0x3220
cmpl $0x40, %r15d
jne 0x725c
movl $0xa, %edi
callq 0x3220
testb $0x8, 0x40(%rbx)
je 0x72b2
leaq 0x5c45(%rip), %rdi      # 0xcef2
callq 0x3260
testb $0x4, 0x40(%rbx)
je 0x72c4
leaq 0x5c52(%rip), %rdi      # 0xcf11
callq 0x3260
testb $0x2, 0x40(%rbx)
je 0x72d6
leaq 0x5c60(%rip), %rdi      # 0xcf31
callq 0x3260
testb $0x1, 0x40(%rbx)
je 0x72e8
leaq 0x5c6d(%rip), %rdi      # 0xcf50
callq 0x3260
movzbl 0x42(%rbx), %esi
cmpl $0x40, %esi
je 0x72ff
leaq 0x5a2d(%rip), %rdi      # 0xcd25
xorl %eax, %eax
callq 0x3040
movzbl 0x43(%rbx), %esi
leaq 0x5a36(%rip), %rdi      # 0xcd40
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3040