// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0xa
popq %r15
leaq 0x5565(%rip), %r12      # 0xac01
xorl %r14d, %r14d
cmpq $0x6, %r14
je 0x570b
leaq 0x5504(%rip), %rax      # 0xabb0
movslq (%rax,%r14,4), %rsi
addq %rax, %rsi
xorl %r13d, %r13d
leaq 0x5535(%rip), %rdi      # 0xabf2
xorl %eax, %eax
callq 0x2030
cmpl $0x40, %r13d
je 0x56fe
movq (%rbx,%r14,8), %rax
movl %r13d, %ecx
xorb $0x38, %cl
movzbl %cl, %ecx
xorl %esi, %esi
btq %rcx, %rax
setb %sil
movq %r12, %rdi
xorl %eax, %eax
callq 0x2030
incl %r13d
testb $0x7, %r13b
jne 0x56c4
movl %r15d, %edi
callq 0x21f0
jmp 0x56c4
movl %r15d, %edi
callq 0x21f0
incq %r14
jmp 0x569f
leaq 0x568c(%rip), %rdi      # 0xad9e
callq 0x2230
leaq 0x54e3(%rip), %r14      # 0xac01
pushq $0xa
popq %r15
xorl %r12d, %r12d
cmpl $0x40, %r12d
je 0x575f
movq 0x30(%rbx), %rax
movl %r12d, %ecx
xorb $0x38, %cl
movzbl %cl, %ecx
xorl %esi, %esi
btq %rcx, %rax
setb %sil
movq %r14, %rdi
xorl %eax, %eax
callq 0x2030
incl %r12d
testb $0x7, %r12b
jne 0x5725
movl %r15d, %edi
callq 0x21f0
jmp 0x5725
pushq $0xa
popq %r14
movl %r14d, %edi
callq 0x21f0
leaq 0x5645(%rip), %rdi      # 0xadb7
callq 0x2230
leaq 0x5483(%rip), %r15      # 0xac01
xorl %r12d, %r12d
cmpl $0x40, %r12d
je 0x57bb
movq 0x38(%rbx), %rax
movl %r12d, %ecx
xorb $0x38, %cl
movzbl %cl, %ecx
xorl %esi, %esi
btq %rcx, %rax
setb %sil
movq %r15, %rdi
xorl %eax, %eax
callq 0x2030
incl %r12d
testb $0x7, %r12b
jne 0x5781
movl %r14d, %edi
callq 0x21f0
jmp 0x5781
pushq $0xa
popq %rdi
callq 0x21f0
movb 0x40(%rbx), %al
testb $0x8, %al
je 0x57d9
leaq 0x5601(%rip), %rdi      # 0xadd2
callq 0x2230
movb 0x40(%rbx), %al
testb $0x4, %al
je 0x57ec
leaq 0x560d(%rip), %rdi      # 0xadf1
callq 0x2230
movb 0x40(%rbx), %al
testb $0x2, %al
je 0x57ff
leaq 0x561a(%rip), %rdi      # 0xae11
callq 0x2230
movb 0x40(%rbx), %al
testb $0x1, %al
je 0x580f
leaq 0x5626(%rip), %rdi      # 0xae30
callq 0x2230
movzbl 0x42(%rbx), %esi
cmpl $0x40, %esi
je 0x5826
leaq 0x53e6(%rip), %rdi      # 0xac05
xorl %eax, %eax
callq 0x2030
movzbl 0x43(%rbx), %esi
leaq 0x53ef(%rip), %rdi      # 0xac20
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2030