// File: /workspace/github_cpp_makefile_star2_O1/SethKasmann[P]clever-girl/src/state.cpp
// Function: operator<<(std::ostream&, State const&)
std::ostream & operator << (std::ostream & o, const State & s)
{
    const char * W_pawn   = "\u2659";
    const char * W_knight = "\u2658";
    const char * W_bishop = "\u2657";
    const char * W_rook   = "\u2656";
    const char * W_queen  = "\u2655";
    const char * W_king   = "\u2654";
    const char * B_pawn   = "\u265F";
    const char * B_knight = "\u265E";
    const char * B_bishop = "\u265D";
    const char * B_rook   = "\u265C";
    const char * B_queen  = "\u265B";
    const char * B_king   = "\u265A";
    const char * Empty    = " ";

    std::string nums[8] = {"1", "2", "3", "4", "5", "6", "7", "8"};
    const std::string bar = " +-+-+-+-+-+-+-+-+";

    o << bar << std::endl;
    for (int i = 63; i >= 0; --i)
    {
        U64 bit = square_bb[i];
        if (i % 8 == 7)
            o << nums[i / 8] << "|";

        o << (bit & s.getPieceBB<pawn>(white)   ? W_pawn
            : bit & s.getPieceBB<knight>(white) ? W_knight
            : bit & s.getPieceBB<bishop>(white) ? W_bishop
            : bit & s.getPieceBB<rook>(white)   ? W_rook
            : bit & s.getPieceBB<queen>(white)  ? W_queen
            : bit & s.getPieceBB<king>(white)   ? W_king
            : bit & s.getPieceBB<pawn>(black)   ? B_pawn
            : bit & s.getPieceBB<knight>(black) ? B_knight
            : bit & s.getPieceBB<bishop>(black) ? B_bishop
            : bit & s.getPieceBB<rook>(black)   ? B_rook
            : bit & s.getPieceBB<queen>(black)  ? B_queen
            : bit & s.getPieceBB<king>(black)   ? B_king
            : Empty) << "|";

        if (i % 8 == 0)
            o << '\n' << bar << '\n';
    }

    o << "  A B C D E F G H\n";

    if (s.mUs == white)
        o << "White to move.\n";
    else 
        o << "Black to move.\n";
    
    //o << "Color(mUs)" << s.mUs << '\n';
    //o << "Color(mThem)" << s.mThem << '\n';

    /*
    print_bb(s.getOccupancyBB(white));
    print_bb(s.getOccupancyBB(black));
    */
    //std::cout << s.getKey() << '\n';

    return o;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7525(%rip), %rsi      # 0x1fdd4
leaq 0x751f(%rip), %rdx      # 0x1fdd5
leaq 0x30(%rsp), %r12
movq %r12, %rdi
callq 0xf802
leaq 0x50(%rsp), %r15
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x74fe(%rip), %rsi      # 0x1fdd6
leaq 0x74f8(%rip), %rdx      # 0x1fdd7
movq %r15, %rdi
callq 0xf802
leaq 0x70(%rsp), %r15
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7af6(%rip), %rsi      # 0x203f5
leaq 0x7af0(%rip), %rdx      # 0x203f6
movq %r15, %rdi
callq 0xf802
leaq 0x90(%rsp), %r15
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7b08(%rip), %rsi      # 0x20431
leaq 0x7b02(%rip), %rdx      # 0x20432
movq %r15, %rdi
callq 0xf802
leaq 0xb0(%rsp), %r15
leaq 0xc0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7b0d(%rip), %rsi      # 0x20460
leaq 0x7b07(%rip), %rdx      # 0x20461
movq %r15, %rdi
callq 0xf802
leaq 0xd0(%rsp), %r15
leaq 0xe0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7679(%rip), %rsi      # 0x1fff6
leaq 0x7673(%rip), %rdx      # 0x1fff7
movq %r15, %rdi
callq 0xf802
leaq 0xf0(%rsp), %r15
leaq 0x100(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7431(%rip), %rsi      # 0x1fdd8
leaq 0x742b(%rip), %rdx      # 0x1fdd9
movq %r15, %rdi
callq 0xf802
leaq 0x110(%rsp), %r15
leaq 0x120(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x7bea(%rip), %rsi      # 0x205bb
leaq 0x7be4(%rip), %rdx      # 0x205bc
movq %r15, %rdi
callq 0xf802
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x73ea(%rip), %rsi      # 0x1fdda
leaq 0x73f5(%rip), %rdx      # 0x1fdec
leaq 0x10(%rsp), %rdi
callq 0xf802
movq %r14, 0x8(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x4290
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4230
movsbl %al, %esi
movq %r15, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4170
movl $0x3f, %r12d
leaq 0xe0021(%rip), %rax     # 0xf8a70
movq (%rax,%r12,8), %r14
movl %r12d, %r15d
andl $0x7, %r15d
cmpl $0x7, %r15d
jne 0x18a90
movl %r12d, %eax
shrl $0x3, %eax
shlq $0x5, %rax
movq 0x30(%rsp,%rax), %rsi
movq 0x38(%rsp,%rax), %rdx
movq %rbx, %rdi
callq 0x4290
movl $0x1, %edx
movq %rax, %rdi
leaq 0x34ba(%rip), %rsi      # 0x1bf45
callq 0x4290
leaq 0x730d(%rip), %r13      # 0x1fda4
movq 0x8(%rsp), %rax
testq %r14, 0x288(%rax)
jne 0x18b6c
leaq 0x72f8(%rip), %r13      # 0x1fda8
testq %r14, 0x290(%rax)
jne 0x18b6c
leaq 0x72e8(%rip), %r13      # 0x1fdac
testq %r14, 0x298(%rax)
jne 0x18b6c
leaq 0x72d8(%rip), %r13      # 0x1fdb0
testq %r14, 0x2a0(%rax)
jne 0x18b6c
leaq 0x72c8(%rip), %r13      # 0x1fdb4
testq %r14, 0x2a8(%rax)
jne 0x18b6c
leaq 0x72bc(%rip), %r13      # 0x1fdb8
testq %r14, 0x2b0(%rax)
jne 0x18b6c
leaq 0x72b0(%rip), %r13      # 0x1fdbc
testq %r14, 0x2b8(%rax)
jne 0x18b6c
leaq 0x72a4(%rip), %r13      # 0x1fdc0
testq %r14, 0x2c0(%rax)
jne 0x18b6c
leaq 0x7298(%rip), %r13      # 0x1fdc4
testq %r14, 0x2c8(%rax)
jne 0x18b6c
leaq 0x728c(%rip), %r13      # 0x1fdc8
testq %r14, 0x2d0(%rax)
jne 0x18b6c
leaq 0x7280(%rip), %r13      # 0x1fdcc
testq %r14, 0x2d8(%rax)
jne 0x18b6c
leaq 0x3b1f(%rip), %r13      # 0x1c67b
testq %r14, 0x2e0(%rax)
je 0x18b6c
leaq 0x7264(%rip), %r13      # 0x1fdd0
movq %r13, %rdi
callq 0x40f0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x4290
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x33b4(%rip), %rsi      # 0x1bf45
callq 0x4290
testl %r15d, %r15d
jne 0x18bdb
movb $0xa, 0x7(%rsp)
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x7(%rsp), %rsi
callq 0x4290
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rax, %rdi
callq 0x4290
movb $0xa, 0x7(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x7(%rsp), %rsi
callq 0x4290
addq $-0x1, %r12
jb 0x18a48
leaq 0x7201(%rip), %rsi      # 0x1fded
movl $0x12, %edx
movq %rbx, %rdi
callq 0x4290
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
leaq 0x71f8(%rip), %rax      # 0x1fe00
leaq 0x7201(%rip), %rsi      # 0x1fe10
cmoveq %rax, %rsi
movl $0xf, %edx
movq %rbx, %rdi
callq 0x4290
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x18c3c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4250
movq $-0x100, %r14
movq -0x10(%rbp), %rdi
cmpq %rdi, %rbp
je 0x18c58
movq (%rbp), %rsi
incq %rsi
callq 0x4250
addq $-0x20, %rbp
addq $0x20, %r14
jne 0x18c43
movq %rbx, %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x18cec
jmp 0x18c88
jmp 0x18c88
jmp 0x18c88
jmp 0x18c88
jmp 0x18c88
jmp 0x18c88
movq %rax, %rbx
cmpq %r15, %r12
je 0x18d18
addq $-0x10, %r15
leaq 0x30(%rsp), %r14
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x18cb1
movq (%r15), %rsi
incq %rsi
callq 0x4250
leaq -0x20(%r15), %rax
addq $-0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x18c9d
jmp 0x18d18
movq %rax, %rbx
movq %r12, %r15
jmp 0x18c8b
jmp 0x18ccd
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x18cec
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4250
xorl %r14d, %r14d
movq 0x110(%rsp,%r14), %rdi
leaq (%r14,%rbp), %rax
cmpq %rdi, %rax
je 0x18d0b
movq (%rax), %rsi
incq %rsi
callq 0x4250
addq $-0x20, %r14
cmpq $-0x100, %r14
jne 0x18cef
movq %rbx, %rdi
callq 0x43b0