// File: /workspace/github_cpp_makefile_star2_O3/night-shift[P]Srl/src/lib/Node.cpp
// Function: Srl::Node::consume_value(bool, unsigned long)
Value Node::consume_value(bool throw_ex, size_t)
{
    if(this->values.size() > 0) {
        auto itr = this->values.begin();
        auto stored_field = move(itr->field);
        this->values.erase(itr);

        return stored_field;
    }

    while(!this->parsed) {
        MemBlock seg_name; Value val;
        tie(seg_name, val) = this->env->parser->read(this->env->in);

        auto tp = val.type();

        if(tp == Type::Scope_End) {
            this->parsed = true;
            break;
        }

        if(!TpTools::is_scope(tp)) {
            val.name_ptr = this->env->store_string(seg_name).first;
            return val;

        } else {
            auto* link = this->env->store_node(*this, Node(this->env->tree, tp), seg_name);
            link->field.read_source();
        }
    }

    if(throw_ex) {
        throw Exception("Cannot access Value. Index out of bounds");
    }

    return Value(Type::Null);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r13
movq %rdi, %rbx
movq 0x40(%rsi), %rax
testq %rax, %rax
je 0x128da
leaq 0x28(%r13), %r15
movq 0x30(%r13), %r12
movq 0x28(%r12), %rcx
movq %rcx, 0x10(%rbx)
movups 0x18(%r12), %xmm0
movups %xmm0, (%rbx)
decq %rax
movq %rax, 0x40(%r13)
movq %r12, %rdi
callq 0xbd90
movq %r15, %rdi
movq %r12, %rsi
callq 0xb700
jmp 0x12a3a
movl %edx, 0xc(%rsp)
cmpb $0x0, 0x51(%r13)
jne 0x12a1c
leaq 0x50(%rsp), %rbp
leaq 0x20(%rsp), %r14
movq %rbx, (%rsp)
movq (%r13), %rdx
movq 0x250(%rdx), %rsi
addq $0x260, %rdx            # imm = 0x260
movq (%rsi), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %r12
leaq 0x30(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rbx)
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movb 0x14(%rbx), %bl
cmpb $0x10, %bl
je 0x12a13
movl %ebx, %eax
andb $-0x2, %al
movq (%r13), %r15
cmpb $0xe, %al
jne 0x12a4c
movq (%r15), %rdi
callq 0xbf80
movq %rax, 0x20(%rsp)
addq $0x8, %rax
movq %rax, 0x28(%rsp)
leaq 0x30(%rsp), %rcx
movq %rcx, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq %rax, 0x48(%rsp)
movq %rbp, 0x58(%rsp)
movq %rbp, 0x50(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rcx)
movb %bl, 0x70(%rsp)
movb $0x1, 0x71(%rsp)
movq %r14, 0x10(%rsp)
movl %r12d, 0x18(%rsp)
movw $0x10c, 0x1c(%rsp)      # imm = 0x10C
movb $0x0, 0x1e(%rsp)
movq %r15, %rdi
movq %r13, %rsi
leaq 0x20(%rsp), %r14
movq %r14, %rdx
leaq 0x10(%rsp), %rcx
callq 0xb470
movq %rax, %r15
movq 0x50(%rsp), %rbx
cmpq %rbp, %rbx
je 0x129ea
movq %rbx, %rsi
movq (%rbx), %rbx
movq 0x48(%rsp), %rdi
movl $0x30, %edx
callq 0xb3c0
jmp 0x129ce
leaq 0x28(%rsp), %rdi
callq 0xbab0
addq $0x8, %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0xb9f0
cmpb $0x1, 0x51(%r13)
movq (%rsp), %rbx
jne 0x128f7
jmp 0x12a1c
movb $0x1, 0x51(%r13)
movq (%rsp), %rbx
cmpb $0x0, 0xc(%rsp)
jne 0x12a73
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movl $0x0, 0x10(%rbx)
movw $0xb, 0x14(%rbx)
movb $0x0, 0x16(%rbx)
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20(%rsp), %rsi
movq %r14, (%rsi)
movl %r12d, 0x8(%rsi)
movw $0x10c, 0xc(%rsi)       # imm = 0x10C
movb $0x0, 0xe(%rsi)
movq %r15, %rdi
callq 0xb390
movq (%rsp), %rbx
movq %rax, (%rbx)
jmp 0x12a3a
movl $0x28, %edi
callq 0xb3b0
movq %rax, %rbx
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xba44(%rip), %rsi      # 0x1e4d4
leaq 0xba65(%rip), %rdx      # 0x1e4fc
leaq 0x20(%rsp), %rdi
callq 0xb2e0
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0xb1d0
xorl %ebp, %ebp
movq 0x1452e(%rip), %rsi     # 0x26fe8
movq 0x14487(%rip), %rdx     # 0x26f48
movq %rbx, %rdi
callq 0xbe60
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x12ae3
movq 0x30(%rsp), %rsi
incq %rsi
callq 0xb940
testb %bpl, %bpl
jne 0x12aed
jmp 0x12b04
movq %rax, %r14
movq %rbx, %rdi
callq 0xb610
jmp 0x12b04
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0xc020
movq %r14, %rdi
callq 0xbe90
movq %rax, %rdi
callq 0xf059