// File: cpirc[P]Monochrome/src/position.cpp
// Function: print_position(Position const&)
void print_position(const Position &pos) {
    Position npos = pos;
    if (pos.flipped) {
        flip_position(npos);
        calculate_key(npos);
    }

    int sq = A8;
    while (sq >= 0) {
        Piece piece = get_piece_on_square(npos, (std::uint64_t)1 << sq);
        bool white = ((std::uint64_t)1 << sq) & get_colour(npos, US);

        if (white)
            printf("%c", Piece_ASCII[piece]);
        else
            printf("%c", tolower(Piece_ASCII[piece]));

        if (sq % 8 == 7) {
            printf("\n");
            sq -= 16;
        }
        sq++;
    }

    printf("Flipped: %i\n", pos.flipped);
    printf("Eval: %i\n", evaluate(npos));
    printf("Hash: %" PRIx64 "\n", pos.hash_key);
    printf("Halfmoves: %i\n", pos.halfmoves);
    printf("History: %" PRIu64 "\n", pos.history.size());
    for (auto &i : pos.history) {
        printf("  %" PRIx64 "\n", i);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x6a30
movq -0x8(%rbp), %rax
testb $0x1, 0x41(%rax)
je 0xa428
leaq -0x70(%rbp), %rdi
callq 0x42a0
jmp 0xa401
leaq -0x70(%rbp), %rdi
callq 0x9a00
jmp 0xa40c
jmp 0xa428
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x6b60
jmp 0xa665
movl $0x38, -0x80(%rbp)
cmpl $0x0, -0x80(%rbp)
jl 0xa536
movb -0x80(%rbp), %cl
movl $0x1, %esi
shlq %cl, %rsi
leaq -0x70(%rbp), %rdi
callq 0x7850
movb %al, -0xa9(%rbp)
jmp 0xa455
movb -0xa9(%rbp), %al
movb %al, -0x81(%rbp)
movb -0x80(%rbp), %cl
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0xc0(%rbp)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
callq 0x4420
movq %rax, -0xb8(%rbp)
jmp 0xa487
movq -0xb8(%rbp), %rcx
movq -0xc0(%rbp), %rax
andq %rcx, %rax
cmpq $0x0, %rax
setne %al
andb $0x1, %al
movb %al, -0x82(%rbp)
testb $0x1, -0x82(%rbp)
je 0xa4d4
movzbl -0x81(%rbp), %eax
leaq 0x9912(%rip), %rcx      # 0x13dd0
movsbl (%rax,%rcx), %esi
leaq 0x9b3f(%rip), %rdi      # 0x14008
xorl %eax, %eax
callq 0x3030
jmp 0xa4d2
jmp 0xa4ff
movzbl -0x81(%rbp), %eax
leaq 0x98ee(%rip), %rcx      # 0x13dd0
movsbl (%rax,%rcx), %edi
callq 0x32c0
movl %eax, %esi
leaq 0x9b14(%rip), %rdi      # 0x14008
xorl %eax, %eax
callq 0x3030
jmp 0xa4fd
jmp 0xa4ff
movl -0x80(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
cmpl $0x7, %edx
jne 0xa528
leaq 0x94ab(%rip), %rdi      # 0x139c1
xorl %eax, %eax
callq 0x3030
jmp 0xa51f
movl -0x80(%rbp), %eax
subl $0x10, %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0xa42f
movq -0x8(%rbp), %rax
movzbl 0x41(%rax), %esi
andl $0x1, %esi
leaq 0x9ac3(%rip), %rdi      # 0x1400b
xorl %eax, %eax
callq 0x3030
jmp 0xa551
leaq -0x70(%rbp), %rdi
callq 0x3bb0
movl %eax, -0xc4(%rbp)
jmp 0xa562
movl -0xc4(%rbp), %esi
leaq 0x9aa9(%rip), %rdi      # 0x14018
xorl %eax, %eax
callq 0x3030
jmp 0xa578
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rsi
leaq 0x9a9b(%rip), %rdi      # 0x14022
xorl %eax, %eax
callq 0x3030
jmp 0xa590
movq -0x8(%rbp), %rax
movzbl 0x43(%rax), %esi
leaq 0x9a8e(%rip), %rdi      # 0x1402d
xorl %eax, %eax
callq 0x3030
jmp 0xa5a8
movq -0x8(%rbp), %rdi
addq $0x50, %rdi
callq 0x6d10
movq %rax, %rsi
leaq 0x9a7d(%rip), %rdi      # 0x1403c
xorl %eax, %eax
callq 0x3030
jmp 0xa5c8
movq -0x8(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x6e30
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rdi
callq 0x6e60
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xa8f0
testb $0x1, %al
jne 0xa616
jmp 0xa653
leaq -0x98(%rbp), %rdi
callq 0xa930
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq (%rax), %rsi
leaq 0x9a10(%rip), %rdi      # 0x1404a
xorl %eax, %eax
callq 0x3030
jmp 0xa643
jmp 0xa645
leaq -0x98(%rbp), %rdi
callq 0xa950
jmp 0xa5fd
leaq -0x70(%rbp), %rdi
callq 0x6b60
addq $0xd0, %rsp
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x3350
nop