// File: 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
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
leaq -0x40(%rbp), %rdi
leaq 0x10c99(%rip), %rsi     # 0x1ad20
movl $0x30, %edx
callq 0x3190
movb $0x0, -0x41(%rbp)
movzbl -0x41(%rbp), %eax
cmpl $0x5, %eax
jg 0xa141
movzbl -0x41(%rbp), %eax
movq -0x40(%rbp,%rax,8), %rsi
leaq 0x9d48(%rip), %rdi      # 0x13dfa
movb $0x0, %al
callq 0x3030
movl $0x0, -0x48(%rbp)
cmpl $0x40, -0x48(%rbp)
jge 0xa12a
movq -0x8(%rbp), %rax
movzbl -0x41(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0x48(%rbp), %ecx
xorl $0x38, %ecx
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, %rcx
andq $0x1, %rcx
xorl %esi, %esi
movl $0x1, %eax
cmpq $0x0, %rcx
cmovnel %eax, %esi
leaq 0x9d10(%rip), %rdi      # 0x13e09
movb $0x0, %al
callq 0x3030
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl $0x8, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0xa11d
movl $0xa, %edi
callq 0x32a0
jmp 0xa11f
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0xa0c0
movl $0xa, %edi
callq 0x32a0
movb -0x41(%rbp), %al
addb $0x1, %al
movb %al, -0x41(%rbp)
jmp 0xa095
leaq 0x9cc5(%rip), %rdi      # 0x13e0d
movb $0x0, %al
callq 0x3030
movl $0x0, -0x4c(%rbp)
cmpl $0x40, -0x4c(%rbp)
jge 0xa1bc
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x4c(%rbp), %ecx
xorl $0x38, %ecx
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, %rcx
andq $0x1, %rcx
xorl %esi, %esi
movl $0x1, %eax
cmpq $0x0, %rcx
cmovnel %eax, %esi
leaq 0x9c7e(%rip), %rdi      # 0x13e09
movb $0x0, %al
callq 0x3030
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl $0x8, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0xa1af
movl $0xa, %edi
callq 0x32a0
jmp 0xa1b1
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xa156
movl $0xa, %edi
callq 0x32a0
leaq 0x9c5a(%rip), %rdi      # 0x13e27
movb $0x0, %al
callq 0x3030
movl $0x0, -0x50(%rbp)
cmpl $0x40, -0x50(%rbp)
jge 0xa241
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movl -0x50(%rbp), %ecx
xorl $0x38, %ecx
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, %rcx
andq $0x1, %rcx
xorl %esi, %esi
movl $0x1, %eax
cmpq $0x0, %rcx
cmovnel %eax, %esi
leaq 0x9bf9(%rip), %rdi      # 0x13e09
movb $0x0, %al
callq 0x3030
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl $0x8, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0xa234
movl $0xa, %edi
callq 0x32a0
jmp 0xa236
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0xa1db
movl $0xa, %edi
callq 0x32a0
movq -0x8(%rbp), %rax
movzbl 0x40(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xa269
leaq 0x9be1(%rip), %rdi      # 0x13e43
movb $0x0, %al
callq 0x3030
movq -0x8(%rbp), %rax
movzbl 0x40(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0xa287
leaq 0x9be3(%rip), %rdi      # 0x13e63
movb $0x0, %al
callq 0x3030
movq -0x8(%rbp), %rax
movzbl 0x40(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xa2a5
leaq 0x9be6(%rip), %rdi      # 0x13e84
movb $0x0, %al
callq 0x3030
movq -0x8(%rbp), %rax
movzbl 0x40(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xa2c3
leaq 0x9be8(%rip), %rdi      # 0x13ea4
movb $0x0, %al
callq 0x3030
movq -0x8(%rbp), %rax
movzbl 0x42(%rax), %eax
cmpl $0x40, %eax
je 0xa2e6
movq -0x8(%rbp), %rax
movzbl 0x42(%rax), %esi
leaq 0x9be6(%rip), %rdi      # 0x13ec5
movb $0x0, %al
callq 0x3030
movq -0x8(%rbp), %rax
movzbl 0x43(%rax), %esi
leaq 0x9beb(%rip), %rdi      # 0x13ee0
movb $0x0, %al
callq 0x3030
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)