// File: ATOMIC-LICHESS[P]ATOMKRAFT/uci.cpp
// Function: (anonymous namespace)::set_position(Position&, std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char>>&)
void set_position(Position& pos, UCIParser& up) {

    string token, fen;

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

    if (token == "startpos")
    {
        pos.from_fen(StartPositionFEN, false);
        up >> token; // Consume "moves" token if any
    }
    else if (token == "fen")
    {
        while (up >> token && token != "moves")
            fen += token + " ";

        pos.from_fen(fen, Options["UCI_Chess960"].value<bool>());
    }
    else return;

    // Parse move list (if any)
    while (up >> token)
        pos.do_setup_move(move_from_uci(pos, token));
  }

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x100(%rsp)
movq %rsi, 0xf8(%rsp)
leaq 0xd8(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x6730
leaq 0xb8(%rsp), %rdi
callq 0x6730
movq 0x58(%rsp), %rsi
movq 0xf8(%rsp), %rdi
callq 0x6680
jmp 0x5314a
leaq 0x8d0f(%rip), %rsi      # 0x5be60
leaq 0xd8(%rsp), %rdi
callq 0x28180
movb %al, 0x57(%rsp)
jmp 0x53164
movb 0x57(%rsp), %al
testb $0x1, %al
jne 0x5316e
jmp 0x531bb
movq 0x100(%rsp), %rdi
leaq 0x3a873b(%rip), %rsi    # 0x3fb8b8
xorl %edx, %edx
callq 0x36580
jmp 0x53186
movq 0xf8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x6680
jmp 0x5319d
jmp 0x533a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
jmp 0x53443
leaq 0x8ca7(%rip), %rsi      # 0x5be69
leaq 0xd8(%rsp), %rdi
callq 0x28180
movb %al, 0x56(%rsp)
jmp 0x531d5
movb 0x56(%rsp), %al
testb $0x1, %al
jne 0x531e2
jmp 0x53399
jmp 0x531e4
movq 0xf8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x6680
movq %rax, 0x48(%rsp)
jmp 0x53200
movq 0x48(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x6670
movb %al, 0x47(%rsp)
jmp 0x5321a
movb 0x47(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x46(%rsp)
jne 0x5322b
jmp 0x5324f
leaq 0x8caa(%rip), %rsi      # 0x5bedc
leaq 0xd8(%rsp), %rdi
callq 0x4ee40
movb %al, 0x45(%rsp)
jmp 0x53245
movb 0x45(%rsp), %al
movb %al, 0x46(%rsp)
jmp 0x5324f
movb 0x46(%rsp), %al
testb $0x1, %al
jne 0x53259
jmp 0x532c6
leaq 0x6300(%rip), %rdx      # 0x59560
leaq 0x88(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x2c3a0
jmp 0x53277
leaq 0xb8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x6690
jmp 0x5328e
leaq 0x88(%rsp), %rdi
callq 0x6a78
jmp 0x531e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x6a78
jmp 0x53443
movq 0x100(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x67(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x6980
movq 0x38(%rsp), %rdx
leaq 0x8b7f(%rip), %rsi      # 0x5be6d
leaq 0x68(%rsp), %rdi
callq 0x12070
jmp 0x532fa
leaq 0x3a9f27(%rip), %rdi    # 0x3fd228
leaq 0x68(%rsp), %rsi
callq 0x27f60
movq %rax, 0x28(%rsp)
jmp 0x53312
movq 0x28(%rsp), %rdi
callq 0x28050
movb %al, 0x27(%rsp)
jmp 0x53322
movq 0x30(%rsp), %rdi
movb 0x27(%rsp), %al
movzbl %al, %edx
andl $0x1, %edx
leaq 0xb8(%rsp), %rsi
callq 0x36580
jmp 0x53340
leaq 0x68(%rsp), %rdi
callq 0x6a78
leaq 0x67(%rsp), %rdi
callq 0x6550
jmp 0x533a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
jmp 0x5338a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x6a78
leaq 0x67(%rsp), %rdi
callq 0x6550
jmp 0x53443
movl $0x1, 0x60(%rsp)
jmp 0x53421
jmp 0x533a5
jmp 0x533a7
movq 0xf8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x6680
movq %rax, 0x18(%rsp)
jmp 0x533c3
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x6670
movb %al, 0x17(%rsp)
jmp 0x533dd
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x533e7
jmp 0x53419
movq 0x100(%rsp), %rdi
movq %rdi, 0x8(%rsp)
leaq 0xd8(%rsp), %rsi
callq 0x2cdf0
movl %eax, 0x10(%rsp)
jmp 0x53407
movl 0x10(%rsp), %esi
movq 0x8(%rsp), %rdi
callq 0x3a310
jmp 0x53417
jmp 0x533a7
movl $0x0, 0x60(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x6a78
leaq 0xd8(%rsp), %rdi
callq 0x6a78
addq $0x108, %rsp            # imm = 0x108
retq
leaq 0xb8(%rsp), %rdi
callq 0x6a78
leaq 0xd8(%rsp), %rdi
callq 0x6a78
movq 0xb0(%rsp), %rdi
callq 0x6970
nopw (%rax,%rax)