// File: /workspace/github_cpp_makefile_star2_O3/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 0x7548(%rip), %rsi      # 0x1fce4
leaq 0x7542(%rip), %rdx      # 0x1fce5
leaq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0xf78c
leaq 0x50(%rsp), %r12
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7521(%rip), %rsi      # 0x1fce6
leaq 0x751b(%rip), %rdx      # 0x1fce7
movq %r12, %rdi
callq 0xf78c
leaq 0x70(%rsp), %r12
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7b19(%rip), %rsi      # 0x20305
leaq 0x7b13(%rip), %rdx      # 0x20306
movq %r12, %rdi
callq 0xf78c
leaq 0x90(%rsp), %r12
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7b2b(%rip), %rsi      # 0x20341
leaq 0x7b25(%rip), %rdx      # 0x20342
movq %r12, %rdi
callq 0xf78c
leaq 0xb0(%rsp), %r12
leaq 0xc0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7b30(%rip), %rsi      # 0x20370
leaq 0x7b2a(%rip), %rdx      # 0x20371
movq %r12, %rdi
callq 0xf78c
leaq 0xd0(%rsp), %r12
leaq 0xe0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x769c(%rip), %rsi      # 0x1ff06
leaq 0x7696(%rip), %rdx      # 0x1ff07
movq %r12, %rdi
callq 0xf78c
leaq 0xf0(%rsp), %r12
leaq 0x100(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7454(%rip), %rsi      # 0x1fce8
leaq 0x744e(%rip), %rdx      # 0x1fce9
movq %r12, %rdi
callq 0xf78c
leaq 0x110(%rsp), %r12
leaq 0x120(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x7c0d(%rip), %rsi      # 0x204cb
leaq 0x7c07(%rip), %rdx      # 0x204cc
movq %r12, %rdi
callq 0xf78c
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x740d(%rip), %rsi      # 0x1fcea
leaq 0x7418(%rip), %rdx      # 0x1fcfc
leaq 0x10(%rsp), %rdi
callq 0xf78c
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 0xe0134(%rip), %rax     # 0xf8a70
movq (%rax,%r12,8), %r14
movl %r12d, %r15d
andl $0x7, %r15d
cmpl $0x7, %r15d
jne 0x1897d
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 0x34cd(%rip), %rsi      # 0x1be45
callq 0x4290
leaq 0x7330(%rip), %r13      # 0x1fcb4
movq 0x8(%rsp), %rax
testq %r14, 0x288(%rax)
jne 0x18a59
leaq 0x731b(%rip), %r13      # 0x1fcb8
testq %r14, 0x290(%rax)
jne 0x18a59
leaq 0x730b(%rip), %r13      # 0x1fcbc
testq %r14, 0x298(%rax)
jne 0x18a59
leaq 0x72fb(%rip), %r13      # 0x1fcc0
testq %r14, 0x2a0(%rax)
jne 0x18a59
leaq 0x72eb(%rip), %r13      # 0x1fcc4
testq %r14, 0x2a8(%rax)
jne 0x18a59
leaq 0x72df(%rip), %r13      # 0x1fcc8
testq %r14, 0x2b0(%rax)
jne 0x18a59
leaq 0x72d3(%rip), %r13      # 0x1fccc
testq %r14, 0x2b8(%rax)
jne 0x18a59
leaq 0x72c7(%rip), %r13      # 0x1fcd0
testq %r14, 0x2c0(%rax)
jne 0x18a59
leaq 0x72bb(%rip), %r13      # 0x1fcd4
testq %r14, 0x2c8(%rax)
jne 0x18a59
leaq 0x72af(%rip), %r13      # 0x1fcd8
testq %r14, 0x2d0(%rax)
jne 0x18a59
leaq 0x72a3(%rip), %r13      # 0x1fcdc
testq %r14, 0x2d8(%rax)
jne 0x18a59
leaq 0x3b32(%rip), %r13      # 0x1c57b
testq %r14, 0x2e0(%rax)
je 0x18a59
leaq 0x7287(%rip), %r13      # 0x1fce0
movq %r13, %rdi
callq 0x40f0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x4290
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x33c7(%rip), %rsi      # 0x1be45
callq 0x4290
testl %r15d, %r15d
jne 0x18ac8
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 0x18935
leaq 0x7224(%rip), %rsi      # 0x1fcfd
movl $0x12, %edx
movq %rbx, %rdi
callq 0x4290
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
leaq 0x721b(%rip), %rax      # 0x1fd10
leaq 0x7224(%rip), %rsi      # 0x1fd20
cmoveq %rax, %rsi
movl $0xf, %edx
movq %rbx, %rdi
callq 0x4290
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x18b29
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4250
movq $-0x100, %r14
movq -0x10(%rbp), %rdi
cmpq %rdi, %rbp
je 0x18b45
movq (%rbp), %rsi
incq %rsi
callq 0x4250
addq $-0x20, %rbp
addq $0x20, %r14
jne 0x18b30
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 0x18bc6
jmp 0x18b75
jmp 0x18b75
jmp 0x18b75
jmp 0x18b75
jmp 0x18b75
jmp 0x18b75
movq %rax, %rbx
addq $-0x10, %r12
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0x18b92
movq (%r12), %rsi
incq %rsi
callq 0x4250
leaq -0x20(%r12), %rax
addq $-0x10, %r12
cmpq %r15, %r12
movq %rax, %r12
jne 0x18b7c
jmp 0x18bf2
jmp 0x18ba7
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x18bc6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4250
xorl %r14d, %r14d
movq 0x110(%rsp,%r14), %rdi
leaq (%r14,%rbp), %rax
cmpq %rdi, %rax
je 0x18be5
movq (%rax), %rsi
incq %rsi
callq 0x4250
addq $-0x20, %r14
cmpq $-0x100, %r14
jne 0x18bc9
movq %rbx, %rdi
callq 0x43b0