// File: ATOMIC-LICHESS[P]ATOMKRAFT/uci.cpp
// Function: execute_uci_command(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool execute_uci_command(const string& cmd) {

  static Position pos(StartPositionFEN, false, 0); // The root position

  UCIParser up(cmd);
  string token;

  up >> token; // operator>>() skips any whitespace

  if (token == "quit")
      return false;

  if (token == "go")
      return go(pos, up);

  if (token == "ucinewgame")
      pos.from_fen(StartPositionFEN, false);

  else if (token == "isready")
      cout << "readyok" << endl;

  else if (token == "position")
      set_position(pos, up);

  else if (token == "setoption")
      set_option(up);

  else if (token == "perft")
      perft(pos, up);

  else if (token == "d")
      pos.print();

  else if (token == "flip")
      pos.flip();

  else if (token == "eval")
  {
      read_evaluation_uci_options(pos.side_to_move());
      cout << trace_evaluate(pos) << endl;
  }

  else if (token == "key")
      cout << "key: " << hex     << pos.get_key()
           << "\nmaterial key: " << pos.get_material_key()
           << "\npawn key: "     << pos.get_pawn_key() << endl;

  else if (token == "uci")
      cout << "id name "     << engine_name()
           << "\nid author " << engine_authors()
           << "\n"           << Options.print_all()
           << "\nuciok"      << endl;
  else
      cout << "Unknown command: " << cmd << endl;

  return true;
}

// Assembly:
subq $0x328, %rsp            # imm = 0x328
movq %rdi, 0x318(%rsp)
cmpb $0x0, 0x3aad62(%rip)    # 0x3fd218
jne 0x524ee
leaq 0x3aad59(%rip), %rdi    # 0x3fd218
callq 0x69c0
cmpl $0x0, %eax
je 0x524ee
leaq 0x3a9408(%rip), %rdi    # 0x3fb8d8
leaq 0x3a93e1(%rip), %rsi    # 0x3fb8b8
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x36520
jmp 0x524e2
leaq 0x3aad2f(%rip), %rdi    # 0x3fd218
callq 0x62f0
movq 0x318(%rsp), %rsi
leaq 0x188(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
movl $0x8, %edx
callq 0x68e0
leaq 0x168(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0x6730
movq 0xd0(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x6680
jmp 0x5253c
leaq 0x8e93(%rip), %rsi      # 0x5b3d6
leaq 0x168(%rsp), %rdi
callq 0x28180
movb %al, 0xcf(%rsp)
jmp 0x52559
movb 0xcf(%rsp), %al
testb $0x1, %al
jne 0x52566
jmp 0x525bc
movb $0x0, 0x327(%rsp)
movl $0x1, 0x164(%rsp)
jmp 0x52c39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
leaq 0x3aac7f(%rip), %rdi    # 0x3fd218
callq 0x62e0
jmp 0x52c7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x52c64
leaq 0x98fb(%rip), %rsi      # 0x5bebe
leaq 0x168(%rsp), %rdi
callq 0x28180
movb %al, 0xce(%rsp)
jmp 0x525d9
movb 0xce(%rsp), %al
testb $0x1, %al
jne 0x525e6
jmp 0x52623
leaq 0x3a92eb(%rip), %rdi    # 0x3fb8d8
leaq 0x188(%rsp), %rsi
callq 0x52c90
movb %al, 0xcd(%rsp)
jmp 0x52603
movb 0xcd(%rsp), %al
andb $0x1, %al
movb %al, 0x327(%rsp)
movl $0x1, 0x164(%rsp)
jmp 0x52c39
leaq 0x97a6(%rip), %rsi      # 0x5bdd0
leaq 0x168(%rsp), %rdi
callq 0x28180
movb %al, 0xcc(%rsp)
jmp 0x52640
movb 0xcc(%rsp), %al
testb $0x1, %al
jne 0x5264d
jmp 0x52669
leaq 0x3a9284(%rip), %rdi    # 0x3fb8d8
leaq 0x3a925d(%rip), %rsi    # 0x3fb8b8
xorl %edx, %edx
callq 0x36580
jmp 0x52664
jmp 0x52c26
leaq 0x976b(%rip), %rsi      # 0x5bddb
leaq 0x168(%rsp), %rdi
callq 0x28180
movb %al, 0xcb(%rsp)
jmp 0x52686
movb 0xcb(%rsp), %al
testb $0x1, %al
jne 0x52693
jmp 0x526cb
movq 0x1991e(%rip), %rdi     # 0x6bfb8
leaq 0x9742(%rip), %rsi      # 0x5bde3
callq 0x64b0
movq %rax, 0xc0(%rsp)
jmp 0x526b0
movq 0xc0(%rsp), %rdi
movq 0x198d1(%rip), %rsi     # 0x6bf90
callq 0x6520
jmp 0x526c6
jmp 0x52c24
leaq 0x9719(%rip), %rsi      # 0x5bdeb
leaq 0x168(%rsp), %rdi
callq 0x28180
movb %al, 0xbf(%rsp)
jmp 0x526e8
movb 0xbf(%rsp), %al
testb $0x1, %al
jne 0x526f5
jmp 0x52710
leaq 0x3a91dc(%rip), %rdi    # 0x3fb8d8
leaq 0x188(%rsp), %rsi
callq 0x53100
jmp 0x5270b
jmp 0x52c22
leaq 0x96dd(%rip), %rsi      # 0x5bdf4
leaq 0x168(%rsp), %rdi
callq 0x28180
movb %al, 0xbe(%rsp)
jmp 0x5272d
movb 0xbe(%rsp), %al
testb $0x1, %al
jne 0x5273a
jmp 0x5274e
leaq 0x188(%rsp), %rdi
callq 0x53470
jmp 0x52749
jmp 0x52c20
leaq 0x96a9(%rip), %rsi      # 0x5bdfe
leaq 0x168(%rsp), %rdi
callq 0x28180
movb %al, 0xbd(%rsp)
jmp 0x5276b
movb 0xbd(%rsp), %al
testb $0x1, %al
jne 0x52778
jmp 0x52793
leaq 0x3a9159(%rip), %rdi    # 0x3fb8d8
leaq 0x188(%rsp), %rsi
callq 0x53800
jmp 0x5278e
jmp 0x52c1e
leaq 0x6e8a(%rip), %rsi      # 0x59624
leaq 0x168(%rsp), %rdi
callq 0x28180
movb %al, 0xbc(%rsp)
jmp 0x527b0
movb 0xbc(%rsp), %al
testb $0x1, %al
jne 0x527bd
jmp 0x527d2
leaq 0x3a9114(%rip), %rdi    # 0x3fb8d8
xorl %esi, %esi
callq 0x38590
jmp 0x527cd
jmp 0x52c1c
leaq 0x962b(%rip), %rsi      # 0x5be04
leaq 0x168(%rsp), %rdi
callq 0x28180
movb %al, 0xbb(%rsp)
jmp 0x527ef
movb 0xbb(%rsp), %al
testb $0x1, %al
jne 0x527fc
jmp 0x5280f
leaq 0x3a90d5(%rip), %rdi    # 0x3fb8d8
callq 0x3d7e0
jmp 0x5280a
jmp 0x52c1a
leaq 0x95f3(%rip), %rsi      # 0x5be09
leaq 0x168(%rsp), %rdi
callq 0x28180
movb %al, 0xba(%rsp)
jmp 0x5282c
movb 0xba(%rsp), %al
testb $0x1, %al
jne 0x5283c
jmp 0x528e1
leaq 0x3a9095(%rip), %rdi    # 0x3fb8d8
callq 0xf5d0
movl %eax, 0xb4(%rsp)
jmp 0x52851
movl 0xb4(%rsp), %edi
callq 0x1e0c0
jmp 0x5285f
leaq 0x3a9072(%rip), %rsi    # 0x3fb8d8
leaq 0x140(%rsp), %rdi
callq 0x1ea80
jmp 0x52875
movq 0x1973c(%rip), %rdi     # 0x6bfb8
leaq 0x140(%rsp), %rsi
callq 0x6420
movq %rax, 0xa8(%rsp)
jmp 0x52893
movq 0xa8(%rsp), %rdi
movq 0x196ee(%rip), %rsi     # 0x6bf90
callq 0x6520
jmp 0x528a9
leaq 0x140(%rsp), %rdi
callq 0x6a78
jmp 0x52c18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x6a78
jmp 0x52c64
leaq 0x9526(%rip), %rsi      # 0x5be0e
leaq 0x168(%rsp), %rdi
callq 0x28180
movb %al, 0xa7(%rsp)
jmp 0x528fe
movb 0xa7(%rsp), %al
testb $0x1, %al
jne 0x5290e
jmp 0x52a1b
movq 0x196a3(%rip), %rdi     # 0x6bfb8
leaq 0x9500(%rip), %rsi      # 0x5be1c
callq 0x64b0
movq %rax, 0x98(%rsp)
jmp 0x5292b
movq 0x98(%rsp), %rdi
leaq 0xfc6(%rip), %rsi       # 0x53900
callq 0x6170
movq %rax, 0x90(%rsp)
jmp 0x52949
leaq 0x3a8f88(%rip), %rdi    # 0x3fb8d8
callq 0x4ea00
movq %rax, 0x88(%rsp)
jmp 0x5295f
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdi
callq 0x6120
movq %rax, 0x80(%rsp)
jmp 0x5297e
movq 0x80(%rsp), %rdi
leaq 0x9485(%rip), %rsi      # 0x5be12
callq 0x64b0
movq %rax, 0x78(%rsp)
jmp 0x52999
leaq 0x3a8f38(%rip), %rdi    # 0x3fb8d8
callq 0x1c6e0
movq %rax, 0x70(%rsp)
jmp 0x529ac
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdi
callq 0x6120
movq %rax, 0x68(%rsp)
jmp 0x529c2
movq 0x68(%rsp), %rdi
leaq 0x9454(%rip), %rsi      # 0x5be22
callq 0x64b0
movq %rax, 0x60(%rsp)
jmp 0x529da
leaq 0x3a8ef7(%rip), %rdi    # 0x3fb8d8
callq 0x34c20
movq %rax, 0x58(%rsp)
jmp 0x529ed
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdi
callq 0x6120
movq %rax, 0x50(%rsp)
jmp 0x52a03
movq 0x50(%rsp), %rdi
movq 0x19581(%rip), %rsi     # 0x6bf90
callq 0x6520
jmp 0x52a16
jmp 0x52c16
leaq 0x940c(%rip), %rsi      # 0x5be2e
leaq 0x168(%rsp), %rdi
callq 0x28180
movb %al, 0x4f(%rsp)
jmp 0x52a35
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x52a42
jmp 0x52bce
movq 0x1956f(%rip), %rdi     # 0x6bfb8
leaq 0x93e2(%rip), %rsi      # 0x5be32
callq 0x64b0
movq %rax, 0x40(%rsp)
jmp 0x52a5c
leaq 0x120(%rsp), %rdi
callq 0x2b7d0
jmp 0x52a6b
movq 0x40(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x6420
movq %rax, 0x38(%rsp)
jmp 0x52a84
movq 0x38(%rsp), %rdi
leaq 0x93ab(%rip), %rsi      # 0x5be3b
callq 0x64b0
movq %rax, 0x30(%rsp)
jmp 0x52a9c
leaq 0x100(%rsp), %rdi
callq 0x2be80
jmp 0x52aab
movq 0x30(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x6420
movq %rax, 0x28(%rsp)
jmp 0x52ac4
movq 0x28(%rsp), %rdi
leaq 0x815b(%rip), %rsi      # 0x5ac2b
callq 0x64b0
movq %rax, 0x20(%rsp)
jmp 0x52adc
leaq 0x3aa745(%rip), %rsi    # 0x3fd228
leaq 0xe0(%rsp), %rdi
callq 0x560b0
jmp 0x52af2
movq 0x20(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x6420
movq %rax, 0x18(%rsp)
jmp 0x52b0b
movq 0x18(%rsp), %rdi
leaq 0x9330(%rip), %rsi      # 0x5be47
callq 0x64b0
movq %rax, 0x10(%rsp)
jmp 0x52b23
movq 0x10(%rsp), %rdi
movq 0x19461(%rip), %rsi     # 0x6bf90
callq 0x6520
jmp 0x52b36
leaq 0xe0(%rsp), %rdi
callq 0x6a78
leaq 0x100(%rsp), %rdi
callq 0x6a78
leaq 0x120(%rsp), %rdi
callq 0x6a78
jmp 0x52c14
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x52bbc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x52baf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x6a78
leaq 0x100(%rsp), %rdi
callq 0x6a78
leaq 0x120(%rsp), %rdi
callq 0x6a78
jmp 0x52c64
movq 0x193e3(%rip), %rdi     # 0x6bfb8
leaq 0x9272(%rip), %rsi      # 0x5be4e
callq 0x64b0
movq %rax, 0x8(%rsp)
jmp 0x52be8
movq 0x8(%rsp), %rdi
movq 0x318(%rsp), %rsi
callq 0x6420
movq %rax, (%rsp)
jmp 0x52c00
movq (%rsp), %rdi
movq 0x19385(%rip), %rsi     # 0x6bf90
callq 0x6520
jmp 0x52c12
jmp 0x52c14
jmp 0x52c16
jmp 0x52c18
jmp 0x52c1a
jmp 0x52c1c
jmp 0x52c1e
jmp 0x52c20
jmp 0x52c22
jmp 0x52c24
jmp 0x52c26
movb $0x1, 0x327(%rsp)
movl $0x1, 0x164(%rsp)
leaq 0x168(%rsp), %rdi
callq 0x6a78
leaq 0x188(%rsp), %rdi
callq 0x6230
movb 0x327(%rsp), %al
andb $0x1, %al
addq $0x328, %rsp            # imm = 0x328
retq
leaq 0x168(%rsp), %rdi
callq 0x6a78
leaq 0x188(%rsp), %rdi
callq 0x6230
movq 0x310(%rsp), %rdi
callq 0x6970
nopl (%rax,%rax)