// File: cpirc[P]Monochrome/src/uci.cpp
// Function: UCI::listen()
void listen() {
    std::cout << "id name Monochrome" << std::endl;
    std::cout << "id author flok Gikoskos kz04px mkchan ZirconiumX"
              << std::endl;
    std::cout << "uciok" << std::endl;

    std::string word;
    std::string line;
    while (true) {
        std::getline(std::cin, line);
        std::stringstream ss{line};
        ss >> word;

        if (word == "isready") {
            isready();
            break;
        } else if (word == "setoption") {
            setoption(ss);
        } else if (word == "quit") {
            return;
        }
    }

    tt_create(&sc.tt, 128);
    ucinewgame();

    bool quit = false;
    while (!quit) {
        std::getline(std::cin, line);
        std::stringstream ss{line};
        ss >> word;

        if (word == "isready") {
            isready();
        } else if (word == "ucinewgame") {
            ucinewgame();
        } else if (word == "position") {
            position(ss);
        } else if (word == "go") {
            go(ss);
        } else if (word == "print") {
            Extension::print();
        } else if (word == "perft") {
            Extension::perft(ss);
        } else if (word == "ttperft") {
            Extension::ttperft(ss);
        } else if (word == "moves") {
            moves(ss);
        } else if (word == "quit") {
            quit = true;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x390, %rsp            # imm = 0x390
movq 0xab3e(%rip), %rdi      # 0x1afd0
leaq 0x41f7(%rip), %rsi      # 0x14690
callq 0x31e0
movq %rax, %rdi
movq 0xab08(%rip), %rsi      # 0x1afb0
callq 0x3200
movq 0xab1c(%rip), %rdi      # 0x1afd0
leaq 0x41e8(%rip), %rsi      # 0x146a3
callq 0x31e0
movq %rax, %rdi
movq 0xaae6(%rip), %rsi      # 0x1afb0
callq 0x3200
movq 0xaafa(%rip), %rdi      # 0x1afd0
leaq 0x41f7(%rip), %rsi      # 0x146d4
callq 0x31e0
movq %rax, %rdi
movq 0xaac4(%rip), %rsi      # 0x1afb0
callq 0x3200
leaq -0x20(%rbp), %rdi
callq 0x3290
leaq -0x40(%rbp), %rdi
callq 0x3290
jmp 0x10505
movq 0xaad4(%rip), %rdi      # 0x1afe0
leaq -0x40(%rbp), %rsi
callq 0x3060
jmp 0x10517
movl $0x10, %edi
movl $0x8, %esi
callq 0x10b70
movl %eax, -0x36c(%rbp)
jmp 0x1052e
movl -0x36c(%rbp), %edx
leaq -0x1d8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3300
jmp 0x10546
leaq -0x1d8(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x3240
jmp 0x10558
leaq 0x417b(%rip), %rsi      # 0x146da
leaq -0x20(%rbp), %rdi
callq 0x58d0
movb %al, -0x36d(%rbp)
jmp 0x10570
movb -0x36d(%rbp), %al
testb $0x1, %al
jne 0x1057c
jmp 0x105c0
callq 0xfb50
jmp 0x10583
movl $0x3, -0x1dc(%rbp)
jmp 0x10632
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x10915
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x3170
jmp 0x10915
leaq 0x411b(%rip), %rsi      # 0x146e2
leaq -0x20(%rbp), %rdi
callq 0x58d0
movb %al, -0x36e(%rbp)
jmp 0x105d8
movb -0x36e(%rbp), %al
testb $0x1, %al
jne 0x105e4
jmp 0x105f4
leaq -0x1d8(%rbp), %rdi
callq 0xfb80
jmp 0x105f2
jmp 0x10626
leaq 0x3247(%rip), %rsi      # 0x13842
leaq -0x20(%rbp), %rdi
callq 0x58d0
movb %al, -0x36f(%rbp)
jmp 0x1060c
movb -0x36f(%rbp), %al
testb $0x1, %al
jne 0x10618
jmp 0x10624
movl $0x1, -0x1dc(%rbp)
jmp 0x10632
jmp 0x10626
jmp 0x10628
movl $0x0, -0x1dc(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x3170
movl -0x1dc(%rbp), %eax
movl %eax, -0x374(%rbp)
testl %eax, %eax
je 0x10660
jmp 0x10650
movl -0x374(%rbp), %eax
subl $0x3, %eax
je 0x10665
jmp 0x108fa
jmp 0x10503
leaq 0x2572ec(%rip), %rdi    # 0x267958
movl $0x80, %esi
callq 0xf210
jmp 0x10678
callq 0xfb20
jmp 0x1067f
movb $0x0, -0x1dd(%rbp)
movb -0x1dd(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x10697
jmp 0x108f0
movq 0xa942(%rip), %rdi      # 0x1afe0
leaq -0x40(%rbp), %rsi
callq 0x3060
jmp 0x106a9
movl $0x10, %edi
movl $0x8, %esi
callq 0x10b70
movl %eax, -0x378(%rbp)
jmp 0x106c0
movl -0x378(%rbp), %edx
leaq -0x368(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3300
jmp 0x106d8
leaq -0x368(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x3240
jmp 0x106ea
leaq 0x3fe9(%rip), %rsi      # 0x146da
leaq -0x20(%rbp), %rdi
callq 0x58d0
movb %al, -0x379(%rbp)
jmp 0x10702
movb -0x379(%rbp), %al
testb $0x1, %al
jne 0x1070e
jmp 0x10737
callq 0xfb50
jmp 0x10715
jmp 0x108df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x368(%rbp), %rdi
callq 0x3170
jmp 0x10915
leaq 0x3fae(%rip), %rsi      # 0x146ec
leaq -0x20(%rbp), %rdi
callq 0x58d0
movb %al, -0x37a(%rbp)
jmp 0x1074f
movb -0x37a(%rbp), %al
testb $0x1, %al
jne 0x1075b
jmp 0x10767
callq 0xfb20
jmp 0x10762
jmp 0x108dd
leaq 0x3f89(%rip), %rsi      # 0x146f7
leaq -0x20(%rbp), %rdi
callq 0x58d0
movb %al, -0x37b(%rbp)
jmp 0x1077f
movb -0x37b(%rbp), %al
testb $0x1, %al
jne 0x1078b
jmp 0x1079e
leaq -0x368(%rbp), %rdi
callq 0x10290
jmp 0x10799
jmp 0x108db
leaq 0x3ed5(%rip), %rsi      # 0x1467a
leaq -0x20(%rbp), %rdi
callq 0x58d0
movb %al, -0x37c(%rbp)
jmp 0x107b6
movb -0x37c(%rbp), %al
testb $0x1, %al
jne 0x107c2
jmp 0x107d5
leaq -0x368(%rbp), %rdi
callq 0xfec0
jmp 0x107d0
jmp 0x108d9
leaq 0x3f24(%rip), %rsi      # 0x14700
leaq -0x20(%rbp), %rdi
callq 0x58d0
movb %al, -0x37d(%rbp)
jmp 0x107ed
movb -0x37d(%rbp), %al
testb $0x1, %al
jne 0x107f9
jmp 0x10805
callq 0xf770
jmp 0x10800
jmp 0x108d7
leaq 0x3efc(%rip), %rsi      # 0x14708
leaq -0x20(%rbp), %rdi
callq 0x58d0
movb %al, -0x37e(%rbp)
jmp 0x1081d
movb -0x37e(%rbp), %al
testb $0x1, %al
jne 0x10829
jmp 0x1083c
leaq -0x368(%rbp), %rdi
callq 0xf790
jmp 0x10837
jmp 0x108d5
leaq 0x3ec3(%rip), %rsi      # 0x14706
leaq -0x20(%rbp), %rdi
callq 0x58d0
movb %al, -0x37f(%rbp)
jmp 0x10854
movb -0x37f(%rbp), %al
testb $0x1, %al
jne 0x10860
jmp 0x10870
leaq -0x368(%rbp), %rdi
callq 0xf950
jmp 0x1086e
jmp 0x108d3
leaq 0x3e06(%rip), %rsi      # 0x1467d
leaq -0x20(%rbp), %rdi
callq 0x58d0
movb %al, -0x380(%rbp)
jmp 0x10888
movb -0x380(%rbp), %al
testb $0x1, %al
jne 0x10894
jmp 0x108a4
leaq -0x368(%rbp), %rdi
callq 0x10190
jmp 0x108a2
jmp 0x108d1
leaq 0x2f97(%rip), %rsi      # 0x13842
leaq -0x20(%rbp), %rdi
callq 0x58d0
movb %al, -0x381(%rbp)
jmp 0x108bc
movb -0x381(%rbp), %al
testb $0x1, %al
jne 0x108c8
jmp 0x108cf
movb $0x1, -0x1dd(%rbp)
jmp 0x108d1
jmp 0x108d3
jmp 0x108d5
jmp 0x108d7
jmp 0x108d9
jmp 0x108db
jmp 0x108dd
jmp 0x108df
leaq -0x368(%rbp), %rdi
callq 0x3170
jmp 0x10686
movl $0x0, -0x1dc(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3120
leaq -0x20(%rbp), %rdi
callq 0x3120
addq $0x390, %rsp            # imm = 0x390
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x3120
leaq -0x20(%rbp), %rdi
callq 0x3120
movq -0x48(%rbp), %rdi
callq 0x3350