// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movq %rdi, %rbx
cmpq $0x0, 0x40(%rsi)
je 0x1803f
movq 0x30(%r14), %rsi
addq $0x28, %r14
movq 0x28(%rsi), %rax
movq %rax, 0x10(%rbx)
movups 0x18(%rsi), %xmm0
movups %xmm0, (%rbx)
movq %r14, %rdi
callq 0x12a50
jmp 0x18199
movl %edx, %r13d
leaq 0x20(%rsp), %r15
movq %rbx, 0x8(%rsp)
cmpb $0x0, 0x51(%r14)
jne 0x18158
movq (%r14), %rdx
movq 0x250(%rdx), %rsi
addq $0x260, %rdx            # imm = 0x260
movq (%rsi), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq 0x20(%rsp), %r15
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), %bpl
cmpb $0x10, %bpl
je 0x18153
movl %r13d, %ebx
movl %ebp, %eax
andb $-0x2, %al
movq (%r14), %r13
cmpb $0xe, %al
jne 0x18173
movq (%r13), %rdi
callq 0x12af0
movq %rax, 0x20(%rsp)
addq $0x8, %rax
movq %rax, 0x28(%rsp)
leaq 0x30(%rsp), %rcx
movq %rcx, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
movq %rax, 0x48(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, 0x58(%rsp)
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rcx)
movb %bpl, 0x70(%rsp)
movb $0x1, 0x71(%rsp)
movq %r15, 0x10(%rsp)
movl %r12d, 0x18(%rsp)
movw $0x10c, 0x1c(%rsp)      # imm = 0x10C
movb $0x0, 0x1e(%rsp)
movq %r13, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %r15
movq %r15, %rdx
leaq 0x10(%rsp), %rcx
callq 0x11700
movq %rax, %r13
movq %r15, %rdi
callq 0x12c70
addq $0x8, %r13
movq %r13, %rdi
xorl %esi, %esi
callq 0x12040
movl %ebx, %r13d
movq 0x8(%rsp), %rbx
jmp 0x1804c
movb $0x1, 0x51(%r14)
testb %r13b, %r13b
jne 0x181ab
andl $0x0, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movw $0xb, 0x14(%rbx)
movb $0x0, 0x16(%rbx)
jmp 0x18199
leaq 0x20(%rsp), %rsi
movq %r15, (%rsi)
movl %r12d, 0x8(%rsi)
movw $0x10c, 0xc(%rsi)       # imm = 0x10C
movb $0x0, 0xe(%rsi)
movq %r13, %rdi
callq 0x115c0
movq 0x8(%rsp), %rbx
movq %rax, (%rbx)
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x115e0
movq %rax, %rbx
leaq 0x9357(%rip), %rsi      # 0x21514
leaq 0x20(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x128f0
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x11300
xorl %ebp, %ebp
movq 0x13e03(%rip), %rsi     # 0x2bfe8
movq 0x13d5c(%rip), %rdx     # 0x2bf48
movq %rbx, %rdi
callq 0x12920
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x12cd8
testb %bpl, %bpl
jne 0x1820b
jmp 0x18222
movq %rax, %r14
movq %rbx, %rdi
callq 0x119b0
jmp 0x18222
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x12c70
movq %r14, %rdi
callq 0x12990