// File: SethKasmann[P]clever-girl/src/uci.cpp
// Function: uci()
void uci()
{
    State root(Start_fen);
    std::string command, token;

    std::setvbuf(stdin, NULL, _IONBF, 0);

    while (1)
    {
        std::getline(std::cin, command);
        std::istringstream is(command);
        is >> std::skipws >> token;

        if (token == "quit")
            break;
        else if (token == "isready")
            std::cout << "readyok" << std::endl;
        else if (token == "uci")
        {
            std::cout << "id name Clever Girl" << std::endl
                      << "id author Seth Kasmann" << std::endl
                      << "option name Hash type spin default 1 min 1 max 128" << std::endl;
            std::cout << "uciok" << std::endl;
        }
        else if (token == "setoption")
        {
            std::string name, value;

            is >> token;
            while (is >> token && token != "value")
                name += token;
            while (is >> token)
                value += token;

            set_option(name, value);
        }
        else if (token == "position")
            position(is, root);
        else if (token == "go")
            go(is, root);
    }
}

// Assembly:
subq $0x798, %rsp            # imm = 0x798
leaq 0x290(%rsp), %rdi
leaq 0x24298a(%rip), %rsi    # 0x280ec0
callq 0x36550
leaq 0x270(%rsp), %rdi
callq 0x5390
leaq 0x250(%rsp), %rdi
callq 0x5390
movq 0x12a54(%rip), %rax     # 0x50fb0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %ecx
movl $0x2, %edx
movq %rcx, %rsi
callq 0x5030
jmp 0x3e572
movq 0x12a5f(%rip), %rdi     # 0x50fd8
leaq 0x270(%rsp), %rsi
callq 0x5060
jmp 0x3e588
leaq 0xc0(%rsp), %rdi
leaq 0x270(%rsp), %rsi
movl $0x8, %edx
callq 0x5460
jmp 0x3e5a4
leaq 0x905(%rip), %rsi       # 0x3eeb0
leaq 0xc0(%rsp), %rdi
callq 0x5450
movq %rax, 0x70(%rsp)
jmp 0x3e5bf
movq 0x70(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x5330
jmp 0x3e5d3
leaq 0x4db6(%rip), %rsi      # 0x43390
leaq 0x250(%rsp), %rdi
callq 0x35540
movb %al, 0x6f(%rsp)
jmp 0x3e5ed
movb 0x6f(%rsp), %al
testb $0x1, %al
jne 0x3e5f7
jmp 0x3e639
movl $0x3, 0xbc(%rsp)
jmp 0x3e9a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x248(%rsp)
movl %eax, 0x244(%rsp)
jmp 0x3e9f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x248(%rsp)
movl %eax, 0x244(%rsp)
jmp 0x3e9c2
leaq 0x6eff(%rip), %rsi      # 0x4553f
leaq 0x250(%rsp), %rdi
callq 0x35540
movb %al, 0x6e(%rsp)
jmp 0x3e653
movb 0x6e(%rsp), %al
testb $0x1, %al
jne 0x3e65d
jmp 0x3e68f
movq 0x12954(%rip), %rdi     # 0x50fb8
leaq 0x6edc(%rip), %rsi      # 0x45547
callq 0x5290
movq %rax, 0x60(%rsp)
jmp 0x3e677
movq 0x60(%rsp), %rdi
movq 0x1290d(%rip), %rsi     # 0x50f90
callq 0x52c0
jmp 0x3e68a
jmp 0x3e994
leaq 0x6eb9(%rip), %rsi      # 0x4554f
leaq 0x250(%rsp), %rdi
callq 0x35540
movb %al, 0x5f(%rsp)
jmp 0x3e6a9
movb 0x5f(%rsp), %al
testb $0x1, %al
jne 0x3e6b6
jmp 0x3e775
movq 0x128fb(%rip), %rdi     # 0x50fb8
leaq 0x6e8f(%rip), %rsi      # 0x45553
callq 0x5290
movq %rax, 0x50(%rsp)
jmp 0x3e6d0
movq 0x50(%rsp), %rdi
movq 0x128b4(%rip), %rsi     # 0x50f90
callq 0x52c0
movq %rax, 0x48(%rsp)
jmp 0x3e6e8
movq 0x48(%rsp), %rdi
leaq 0x6e73(%rip), %rsi      # 0x45567
callq 0x5290
movq %rax, 0x40(%rsp)
jmp 0x3e700
movq 0x40(%rsp), %rdi
movq 0x12884(%rip), %rsi     # 0x50f90
callq 0x52c0
movq %rax, 0x38(%rsp)
jmp 0x3e718
movq 0x38(%rsp), %rdi
leaq 0x6e5a(%rip), %rsi      # 0x4557e
callq 0x5290
movq %rax, 0x30(%rsp)
jmp 0x3e730
movq 0x30(%rsp), %rdi
movq 0x12854(%rip), %rsi     # 0x50f90
callq 0x52c0
jmp 0x3e743
movq 0x1286e(%rip), %rdi     # 0x50fb8
leaq 0x6e60(%rip), %rsi      # 0x455b1
callq 0x5290
movq %rax, 0x28(%rsp)
jmp 0x3e75d
movq 0x28(%rsp), %rdi
movq 0x12827(%rip), %rsi     # 0x50f90
callq 0x52c0
jmp 0x3e770
jmp 0x3e992
leaq 0x6e3b(%rip), %rsi      # 0x455b7
leaq 0x250(%rsp), %rdi
callq 0x35540
movb %al, 0x27(%rsp)
jmp 0x3e78f
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x3e79c
jmp 0x3e912
leaq 0x98(%rsp), %rdi
callq 0x5390
leaq 0x78(%rsp), %rdi
callq 0x5390
leaq 0xc0(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x5330
jmp 0x3e7ca
jmp 0x3e7cc
leaq 0xc0(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x5330
movq %rax, 0x18(%rsp)
jmp 0x3e7e8
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x5320
movb %al, 0x17(%rsp)
jmp 0x3e802
movb 0x17(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x16(%rsp)
jne 0x3e813
jmp 0x3e837
leaq 0x6da7(%rip), %rsi      # 0x455c1
leaq 0x250(%rsp), %rdi
callq 0x3ed50
movb %al, 0x15(%rsp)
jmp 0x3e82d
movb 0x15(%rsp), %al
movb %al, 0x16(%rsp)
jmp 0x3e837
movb 0x16(%rsp), %al
testb $0x1, %al
jne 0x3e841
jmp 0x3e88d
leaq 0x98(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x5340
jmp 0x3e858
jmp 0x3e7cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x248(%rsp)
movl %eax, 0x244(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x5538
leaq 0x98(%rsp), %rdi
callq 0x5538
jmp 0x3e9c2
jmp 0x3e88f
leaq 0xc0(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x5330
movq %rax, 0x8(%rsp)
jmp 0x3e8ab
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x5320
movb %al, 0x7(%rsp)
jmp 0x3e8c5
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x3e8cf
jmp 0x3e8e5
leaq 0x78(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x5340
jmp 0x3e8e3
jmp 0x3e88f
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x3e4a0
jmp 0x3e8f9
leaq 0x78(%rsp), %rdi
callq 0x5538
leaq 0x98(%rsp), %rdi
callq 0x5538
jmp 0x3e990
leaq 0x6cae(%rip), %rsi      # 0x455c7
leaq 0x250(%rsp), %rdi
callq 0x35540
movb %al, 0x6(%rsp)
jmp 0x3e92c
movb 0x6(%rsp), %al
testb $0x1, %al
jne 0x3e936
jmp 0x3e94f
leaq 0xc0(%rsp), %rdi
leaq 0x290(%rsp), %rsi
callq 0x3e000
jmp 0x3e94d
jmp 0x3e98e
leaq 0x6b9b(%rip), %rsi      # 0x454f1
leaq 0x250(%rsp), %rdi
callq 0x35540
movb %al, 0x5(%rsp)
jmp 0x3e969
movb 0x5(%rsp), %al
testb $0x1, %al
jne 0x3e973
jmp 0x3e98c
leaq 0xc0(%rsp), %rdi
leaq 0x290(%rsp), %rsi
callq 0x3daa0
jmp 0x3e98a
jmp 0x3e98c
jmp 0x3e98e
jmp 0x3e990
jmp 0x3e992
jmp 0x3e994
jmp 0x3e996
movl $0x0, 0xbc(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x5130
movl 0xbc(%rsp), %eax
testl %eax, %eax
je 0x3e9bd
jmp 0x3e9bb
jmp 0x3e9d1
jmp 0x3e570
leaq 0xc0(%rsp), %rdi
callq 0x5130
jmp 0x3e9f3
leaq 0x250(%rsp), %rdi
callq 0x5538
leaq 0x270(%rsp), %rdi
callq 0x5538
addq $0x798, %rsp            # imm = 0x798
retq
leaq 0x250(%rsp), %rdi
callq 0x5538
leaq 0x270(%rsp), %rdi
callq 0x5538
movq 0x248(%rsp), %rdi
callq 0x54b0
nopw (%rax,%rax)