// File: /workspace/github_cpp_makefile_star2_O2/SethKasmann[P]clever-girl/src/uci.cpp
// Function: position(std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char>>&, State&)
void position(std::istringstream & is, State & s)
{
    std::string token, fen;
    Move m;
    bool start_flag = false;

    s = State(Start_fen);
    history.init();
    history.push(std::make_pair(nullMove, s.getKey()));

    is >> token;
    if (token == "fen")
    {
        while (is >> token && token != "moves")
            fen += token + " ";
    }
    else if (token == "startpos")
    {
        start_flag = true;
        is >> token;
    }
    else
    {
        std::cout << "unknown command\n";
        return;
    }

    while (is >> token)
    {
        m = get_uci_move(token, s);
        if (m == nullMove)
        {
            std::cout << "illegal move found: " << token << '\n' << s;
            return;
        }
        else
        {
            s.make_t(m);
            history.push(std::make_pair(m, s.getKey()));
        }
    }
    // If start flag is false, initialize board state with fen string.
    if (!start_flag)
        s = State(fen);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x558, %rsp            # imm = 0x558
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x23debe(%rip), %rsi    # 0x252e30
leaq 0x50(%rsp), %rdi
callq 0x12a50
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x12962
leaq 0x1d3720(%rip), %rdi    # 0x1e86b0
callq 0x1559c
movq 0x18(%rbx), %rax
leaq 0x50(%rsp), %rsi
andw $0x0, (%rsi)
movq %rax, 0x8(%rsi)
leaq 0x1d3703(%rip), %rdi    # 0x1e86b0
callq 0x1121a
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x42b0
leaq 0x647d(%rip), %rsi      # 0x1b443
leaq 0x10(%rsp), %rdi
callq 0x1270d
movb %al, 0xf(%rsp)
testb %al, %al
je 0x1503d
leaq 0x10(%rsp), %r15
leaq 0x63fa(%rip), %r12      # 0x1b3de
leaq 0x50(%rsp), %rbp
leaq 0x30(%rsp), %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x42b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x15063
movq %r15, %rdi
movq %r12, %rsi
callq 0x15630
testb %al, %al
je 0x15063
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x1f30(%rip), %rdx      # 0x16f53
callq 0x1563a
movq %r13, %rdi
movq %rbp, %rsi
callq 0x43f0
movq %rbp, %rdi
callq 0x4418
jmp 0x14fee
leaq 0x6403(%rip), %rsi      # 0x1b447
leaq 0x10(%rsp), %rdi
callq 0x1270d
testb %al, %al
je 0x15122
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x42b0
leaq 0x10(%rsp), %r15
leaq 0x1d3641(%rip), %r12    # 0x1e86b0
leaq 0x50(%rsp), %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x42b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x150c5
movq %r15, %rdi
movq %rbx, %rsi
callq 0x14b84
movl %eax, %ebp
testw %ax, %ax
je 0x150ea
movzwl %bp, %esi
movq %rbx, %rdi
callq 0x13694
movq 0x18(%rbx), %rax
movw %bp, 0x50(%rsp)
movq %rax, 0x58(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x1121a
jmp 0x15074
cmpb $0x0, 0xf(%rsp)
je 0x15135
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x12a50
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x12962
jmp 0x15135
movq 0xdea7(%rip), %rdi      # 0x22f98
leaq 0x62ec(%rip), %rsi      # 0x1b3e4
callq 0x4240
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x41e0
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x4290
movq %rax, %rdi
movq %rbx, %rsi
callq 0x13a3f
jmp 0x15135
movq 0xde6f(%rip), %rdi      # 0x22f98
leaq 0x6320(%rip), %rsi      # 0x1b450
callq 0x4240
leaq 0x30(%rsp), %rdi
callq 0x4418
leaq 0x10(%rsp), %rdi
callq 0x4418
addq $0x558, %rsp            # imm = 0x558
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x15178
jmp 0x15178
jmp 0x15178
jmp 0x15178
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4418
jmp 0x1517b
jmp 0x15178
jmp 0x15178
jmp 0x15178
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4418
leaq 0x10(%rsp), %rdi
callq 0x4418
movq %rbx, %rdi
callq 0x43d0