// File: /workspace/github_cpp_makefile_star2_O3/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 0x5d2b(%rip), %r12      # 0xcc10
leaq 0x5d75(%rip), %r15      # 0xcc61
xorl %r13d, %r13d
movslq (%r12,%r13,4), %rsi
addq %r12, %rsi
leaq 0x5d55(%rip), %rdi      # 0xcc52
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 0x6f3b
movl $0xa, %edi
callq 0x3220
cmpl $0x40, %r14d
jne 0x6f07
movl $0xa, %edi
callq 0x3220
incq %r13
cmpq $0x6, %r13
jne 0x6eef
leaq 0x5ea3(%rip), %rdi      # 0xcdfe
callq 0x3260
leaq 0x5cfa(%rip), %r14      # 0xcc61
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 0x6f9e
movl $0xa, %edi
callq 0x3220
cmpl $0x40, %r15d
jne 0x6f6a
movl $0xa, %edi
callq 0x3220
leaq 0x5e62(%rip), %rdi      # 0xce17
callq 0x3260
leaq 0x5ca0(%rip), %r14      # 0xcc61
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 0x6ff8
movl $0xa, %edi
callq 0x3220
cmpl $0x40, %r15d
jne 0x6fc4
movl $0xa, %edi
callq 0x3220
movb 0x40(%rbx), %al
testb $0x8, %al
je 0x701e
leaq 0x5e1c(%rip), %rdi      # 0xce32
callq 0x3260
movb 0x40(%rbx), %al
testb $0x4, %al
je 0x7031
leaq 0x5e28(%rip), %rdi      # 0xce51
callq 0x3260
movb 0x40(%rbx), %al
testb $0x2, %al
je 0x7044
leaq 0x5e35(%rip), %rdi      # 0xce71
callq 0x3260
movb 0x40(%rbx), %al
testb $0x1, %al
je 0x7054
leaq 0x5e41(%rip), %rdi      # 0xce90
callq 0x3260
movzbl 0x42(%rbx), %esi
cmpl $0x40, %esi
je 0x706b
leaq 0x5c01(%rip), %rdi      # 0xcc65
xorl %eax, %eax
callq 0x3040
movzbl 0x43(%rbx), %esi
leaq 0x5c0a(%rip), %rdi      # 0xcc80
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3040