// File: /workspace/github_cpp_makefile_star2_O2/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 0x25bd(%rip), %rsi      # 0x1601a
leaq 0x30(%rsp), %r15
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0x40d0
leaq 0x50(%rsp), %r12
leaq 0x25b7(%rip), %rsi      # 0x16032
leaq 0x9(%rsp), %rdx
movq %r12, %rdi
callq 0x40d0
leaq 0x70(%rsp), %r12
leaq 0x25ad(%rip), %rsi      # 0x16041
leaq 0xf(%rsp), %rdx
movq %r12, %rdi
callq 0x40d0
leaq 0x90(%rsp), %r12
leaq 0x7884(%rip), %rsi      # 0x1b334
leaq 0xe(%rsp), %rdx
movq %r12, %rdi
callq 0x40d0
leaq 0xb0(%rsp), %r12
leaq 0x258a(%rip), %rsi      # 0x16056
leaq 0xd(%rsp), %rdx
movq %r12, %rdi
callq 0x40d0
leaq 0xd0(%rsp), %r12
leaq 0x257d(%rip), %rsi      # 0x16065
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
callq 0x40d0
leaq 0xf0(%rsp), %r12
leaq 0x2579(%rip), %rsi      # 0x1607d
leaq 0xb(%rsp), %rdx
movq %r12, %rdi
callq 0x40d0
leaq 0x110(%rsp), %r12
leaq 0x79bb(%rip), %rsi      # 0x1b4db
leaq 0xa(%rsp), %rdx
movq %r12, %rdi
callq 0x40d0
leaq 0x71a0(%rip), %rsi      # 0x1acd4
leaq 0x10(%rsp), %rdi
leaq 0x9(%rsp), %rdx
callq 0x40d0
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x41e0
movq %rax, %rdi
callq 0x4120
pushq $0x3f
popq %r12
leaq 0x2f72(%rip), %r15      # 0x16ad5
testl %r12d, %r12d
js 0x13cc6
movl %r12d, %eax
leaq 0x112f0a(%rip), %rcx    # 0x126a80
movq (%rcx,%rax,8), %rbp
movl %r12d, %r13d
andl $0x7, %r13d
cmpl $0x7, %r13d
jne 0x13bac
movl %r12d, %eax
shrl $0x3, %eax
shlq $0x5, %rax
leaq (%rsp,%rax), %rsi
addq $0x30, %rsi
movq %rbx, %rdi
callq 0x41e0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4240
leaq 0x70f1(%rip), %rsi      # 0x1aca4
testq %rbp, 0x288(%r14)
jne 0x13c83
leaq 0x70e1(%rip), %rsi      # 0x1aca8
testq %rbp, 0x290(%r14)
jne 0x13c83
leaq 0x70d1(%rip), %rsi      # 0x1acac
testq %rbp, 0x298(%r14)
jne 0x13c83
leaq 0x70c1(%rip), %rsi      # 0x1acb0
testq %rbp, 0x2a0(%r14)
jne 0x13c83
leaq 0x70b1(%rip), %rsi      # 0x1acb4
testq %rbp, 0x2a8(%r14)
jne 0x13c83
leaq 0x70a5(%rip), %rsi      # 0x1acb8
testq %rbp, 0x2b0(%r14)
jne 0x13c83
leaq 0x7099(%rip), %rsi      # 0x1acbc
testq %rbp, 0x2b8(%r14)
jne 0x13c83
leaq 0x708d(%rip), %rsi      # 0x1acc0
testq %rbp, 0x2c0(%r14)
jne 0x13c83
leaq 0x7081(%rip), %rsi      # 0x1acc4
testq %rbp, 0x2c8(%r14)
jne 0x13c83
leaq 0x7075(%rip), %rsi      # 0x1acc8
testq %rbp, 0x2d0(%r14)
jne 0x13c83
leaq 0x7069(%rip), %rsi      # 0x1accc
testq %rbp, 0x2d8(%r14)
jne 0x13c83
leaq 0x32e0(%rip), %rsi      # 0x16f53
testq %rbp, 0x2e0(%r14)
je 0x13c83
leaq 0x704d(%rip), %rsi      # 0x1acd0
movq %rbx, %rdi
callq 0x4240
movq %rax, %rdi
movq %r15, %rsi
callq 0x4240
testl %r13d, %r13d
jne 0x13cbe
movq %rbx, %rdi
pushq $0xa
popq %rsi
callq 0x4290
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x41e0
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x4290
decl %r12d
jmp 0x13b63
leaq 0x701a(%rip), %rsi      # 0x1ace7
movq %rbx, %rdi
callq 0x4240
cmpl $0x0, (%r14)
leaq 0x701a(%rip), %rax      # 0x1acfa
leaq 0x7023(%rip), %rsi      # 0x1ad0a
cmoveq %rax, %rsi
movq %rbx, %rdi
callq 0x4240
leaq 0x10(%rsp), %rdi
callq 0x4418
movl $0xe0, %r14d
leaq (%rsp,%r14), %rdi
addq $0x30, %rdi
callq 0x4418
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x13d03
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 0x13d65
jmp 0x13d40
jmp 0x13d40
jmp 0x13d40
jmp 0x13d40
jmp 0x13d40
jmp 0x13d40
movq %rax, %rbx
addq $-0x20, %r12
movq %r12, %rdi
callq 0x4418
cmpq %r15, %r12
jne 0x13d43
jmp 0x13d82
jmp 0x13d58
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4418
movl $0xe0, %r14d
leaq (%rsp,%r14), %rdi
addq $0x30, %rdi
callq 0x4418
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x13d6b
movq %rbx, %rdi
callq 0x43d0