// File: SethKasmann[P]clever-girl/src/uci.cpp
// Function: go(std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char>>&, State&)
void go(std::istringstream & is, State & s)
{
    std::string token;
    SearchInfo search_info;
    Move m;

    while (is >> token)
    {
        if (token == "searchmoves")
        {
            while (is >> token)
            {
                m = get_uci_move(token, s);
                if (m != nullMove)
                    search_info.sm.push_back(m);
                else
                {
                    std::cout << "illegal move found: " << token << '\n';
                    return;
                }
            }
        }
        else if (token == "ponder")
            search_info.ponder = true;
        else if (token == "wtime")
            is >> search_info.time[white];
        else if (token == "btime")
            is >> search_info.time[black];
        else if (token == "winc")
            is >> search_info.inc[white];
        else if (token == "binc")
            is >> search_info.inc[black];
        else if (token == "movestogo")
            is >> search_info.moves_to_go;
        else if (token == "depth")
            is >> search_info.depth;
        else if (token == "nodes")
            is >> search_info.max_nodes;
        else if (token == "mate")
            is >> search_info.mate;
        else if (token == "movetime")
            is >> search_info.moveTime;
        else if (token == "infinite")
            search_info.infinite = true;
    }

    search_info.clock.set();
    if (!search_info.moveTime)
        search_info.moveTime = allocate_time(search_info.time[s.getOurColor()], 
                                              history.size() / 2, 
                                              search_info.moves_to_go);
    setup_search(s, search_info);
}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x100(%rsp)
movq %rsi, 0xf8(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x5390
leaq 0x80(%rsp), %rdi
callq 0x3c710
jmp 0x3dad3
jmp 0x3dad5
movq 0x100(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x5330
movq %rax, 0x60(%rsp)
jmp 0x3daf1
movq 0x60(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x5320
movb %al, 0x5f(%rsp)
jmp 0x3db0b
movb 0x5f(%rsp), %al
testb $0x1, %al
jne 0x3db18
jmp 0x3df0d
leaq 0x798d(%rip), %rsi      # 0x454ac
leaq 0xd8(%rsp), %rdi
callq 0x35540
movb %al, 0x5e(%rsp)
jmp 0x3db32
movb 0x5e(%rsp), %al
testb $0x1, %al
jne 0x3db3f
jmp 0x3dc5b
jmp 0x3db41
movq 0x100(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x5330
movq %rax, 0x50(%rsp)
jmp 0x3db5d
movq 0x50(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x5320
movb %al, 0x4f(%rsp)
jmp 0x3db77
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x3db84
jmp 0x3dc56
movq 0xf8(%rsp), %rsi
leaq 0xd8(%rsp), %rdi
callq 0x3d890
movw %ax, 0x4c(%rsp)
jmp 0x3dba0
movw 0x4c(%rsp), %ax
movw %ax, 0x72(%rsp)
movzwl 0x72(%rsp), %eax
cmpl $0x0, %eax
je 0x3dc00
leaq 0xc0(%rsp), %rdi
leaq 0x72(%rsp), %rsi
callq 0x3eb60
jmp 0x3dbc8
jmp 0x3dc51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
jmp 0x3dfdb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x3c8c0
jmp 0x3dfdb
movq 0x133b1(%rip), %rdi     # 0x50fb8
leaq 0x78aa(%rip), %rsi      # 0x454b8
callq 0x5290
movq %rax, 0x40(%rsp)
jmp 0x3dc1a
movq 0x40(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x5220
movq %rax, 0x38(%rsp)
jmp 0x3dc33
movq 0x38(%rsp), %rdi
movl $0xa, %esi
callq 0x5300
jmp 0x3dc44
movl $0x1, 0x6c(%rsp)
jmp 0x3dfb9
jmp 0x3db41
jmp 0x3df08
leaq 0x786b(%rip), %rsi      # 0x454cd
leaq 0xd8(%rsp), %rdi
callq 0x35540
movb %al, 0x37(%rsp)
jmp 0x3dc75
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x3dc7f
jmp 0x3dc8c
movb $0x1, 0xb9(%rsp)
jmp 0x3df06
leaq 0x7841(%rip), %rsi      # 0x454d4
leaq 0xd8(%rsp), %rdi
callq 0x35540
movb %al, 0x36(%rsp)
jmp 0x3dca6
movb 0x36(%rsp), %al
testb $0x1, %al
jne 0x3dcb0
jmp 0x3dccc
movq 0x100(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x5190
jmp 0x3dcc7
jmp 0x3df04
leaq 0x7807(%rip), %rsi      # 0x454da
leaq 0xd8(%rsp), %rdi
callq 0x35540
movb %al, 0x35(%rsp)
jmp 0x3dce6
movb 0x35(%rsp), %al
testb $0x1, %al
jne 0x3dcf0
jmp 0x3dd0c
movq 0x100(%rsp), %rdi
leaq 0x84(%rsp), %rsi
callq 0x5190
jmp 0x3dd07
jmp 0x3df02
leaq 0x77cd(%rip), %rsi      # 0x454e0
leaq 0xd8(%rsp), %rdi
callq 0x35540
movb %al, 0x34(%rsp)
jmp 0x3dd26
movb 0x34(%rsp), %al
testb $0x1, %al
jne 0x3dd30
jmp 0x3dd4c
movq 0x100(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x5190
jmp 0x3dd47
jmp 0x3df00
leaq 0x7792(%rip), %rsi      # 0x454e5
leaq 0xd8(%rsp), %rdi
callq 0x35540
movb %al, 0x33(%rsp)
jmp 0x3dd66
movb 0x33(%rsp), %al
testb $0x1, %al
jne 0x3dd70
jmp 0x3dd8c
movq 0x100(%rsp), %rdi
leaq 0x8c(%rsp), %rsi
callq 0x5190
jmp 0x3dd87
jmp 0x3defe
leaq 0x7757(%rip), %rsi      # 0x454ea
leaq 0xd8(%rsp), %rdi
callq 0x35540
movb %al, 0x32(%rsp)
jmp 0x3dda6
movb 0x32(%rsp), %al
testb $0x1, %al
jne 0x3ddb0
jmp 0x3ddcc
movq 0x100(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x5190
jmp 0x3ddc7
jmp 0x3defc
leaq 0x7721(%rip), %rsi      # 0x454f4
leaq 0xd8(%rsp), %rdi
callq 0x35540
movb %al, 0x31(%rsp)
jmp 0x3dde6
movb 0x31(%rsp), %al
testb $0x1, %al
jne 0x3ddf0
jmp 0x3de0c
movq 0x100(%rsp), %rdi
leaq 0x94(%rsp), %rsi
callq 0x5190
jmp 0x3de07
jmp 0x3defa
leaq 0x76e7(%rip), %rsi      # 0x454fa
leaq 0xd8(%rsp), %rdi
callq 0x35540
movb %al, 0x30(%rsp)
jmp 0x3de26
movb 0x30(%rsp), %al
testb $0x1, %al
jne 0x3de30
jmp 0x3de4c
movq 0x100(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x5190
jmp 0x3de47
jmp 0x3def8
leaq 0x76ad(%rip), %rsi      # 0x45500
leaq 0xd8(%rsp), %rdi
callq 0x35540
movb %al, 0x2f(%rsp)
jmp 0x3de66
movb 0x2f(%rsp), %al
testb $0x1, %al
jne 0x3de70
jmp 0x3de89
movq 0x100(%rsp), %rdi
leaq 0xa4(%rsp), %rsi
callq 0x5190
jmp 0x3de87
jmp 0x3def6
leaq 0x7675(%rip), %rsi      # 0x45505
leaq 0xd8(%rsp), %rdi
callq 0x35540
movb %al, 0x2e(%rsp)
jmp 0x3dea3
movb 0x2e(%rsp), %al
testb $0x1, %al
jne 0x3dead
jmp 0x3dec6
movq 0x100(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x5170
jmp 0x3dec4
jmp 0x3def4
leaq 0x7641(%rip), %rsi      # 0x4550e
leaq 0xd8(%rsp), %rdi
callq 0x35540
movb %al, 0x2d(%rsp)
jmp 0x3dee0
movb 0x2d(%rsp), %al
testb $0x1, %al
jne 0x3deea
jmp 0x3def2
movb $0x1, 0xb8(%rsp)
jmp 0x3def4
jmp 0x3def6
jmp 0x3def8
jmp 0x3defa
jmp 0x3defc
jmp 0x3defe
jmp 0x3df00
jmp 0x3df02
jmp 0x3df04
jmp 0x3df06
jmp 0x3df08
jmp 0x3dad5
leaq 0xb0(%rsp), %rdi
callq 0x30600
jmp 0x3df1c
cmpq $0x0, 0xa8(%rsp)
jne 0x3df9a
leaq 0x80(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x24ca0
movl %eax, 0x28(%rsp)
jmp 0x3df47
movq 0x20(%rsp), %rax
movl 0x28(%rsp), %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0x14(%rsp)
leaq 0x1d87e0(%rip), %rdi    # 0x216740
callq 0x3ebd0
movq %rax, 0x18(%rsp)
jmp 0x3df6c
movl 0x14(%rsp), %edi
movq 0x18(%rsp), %rax
shrq %rax
movl %eax, %esi
movl 0x90(%rsp), %edx
callq 0x3c7e0
movq %rax, 0x8(%rsp)
jmp 0x3df8d
movq 0x8(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xf8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x352f0
jmp 0x3dfb1
movl $0x0, 0x6c(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x3c8c0
leaq 0xd8(%rsp), %rdi
callq 0x5538
addq $0x108, %rsp            # imm = 0x108
retq
leaq 0xd8(%rsp), %rdi
callq 0x5538
movq 0x78(%rsp), %rdi
callq 0x54b0
nopw %cs:(%rax,%rax)