// File: /workspace/github_cpp_makefile_star2_O1/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
movq 0x40(%rsi), %rax
testq %rax, %rax
je 0x129c8
leaq 0x28(%r14), %r15
movq 0x30(%r14), %r12
movq 0x28(%r12), %rcx
movq %rcx, 0x10(%rbx)
movups 0x18(%r12), %xmm0
movups %xmm0, (%rbx)
decq %rax
movq %rax, 0x40(%r14)
movq %r12, %rdi
callq 0xbd90
movq %r15, %rdi
movq %r12, %rsi
callq 0xb700
jmp 0x12b74
movl %edx, 0xc(%rsp)
leaq 0x10(%rsp), %r15
cmpb $0x0, 0x51(%r14)
jne 0x12b56
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movl $0x0, 0x10(%rbx)
movw $0xb, 0x14(%rbx)
movb $0x0, 0x16(%rbx)
movq (%r14), %rdx
movq 0x250(%rdx), %rsi
addq $0x260, %rdx            # imm = 0x260
movq (%rsi), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %r12
leaq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rbx)
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movb 0x14(%rbx), %bpl
cmpb $0x10, %bpl
jne 0x12a43
movb $0x1, 0x51(%r14)
movl $0x3, %ebp
jmp 0x12b49
movl %ebp, %eax
andb $-0x2, %al
movq (%r14), %r15
cmpb $0xe, %al
jne 0x12afa
movq (%r15), %rdi
callq 0xbf80
movq %rax, 0x10(%rsp)
addq $0x8, %rax
movq %rax, 0x18(%rsp)
leaq 0x20(%rsp), %rcx
movq %rcx, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq %rax, 0x38(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x48(%rsp)
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rcx)
movb %bpl, 0x60(%rsp)
movb $0x1, 0x61(%rsp)
movq %r13, 0x68(%rsp)
movl %r12d, 0x70(%rsp)
movw $0x10c, 0x74(%rsp)      # imm = 0x10C
movb $0x0, 0x76(%rsp)
movq %r15, %rdi
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
leaq 0x68(%rsp), %rcx
callq 0xb470
movq %rax, %r15
movq 0x40(%rsp), %r12
leaq 0x40(%rsp), %r13
cmpq %r13, %r12
je 0x12b2a
movq %r12, %rsi
movq (%r12), %r12
movq 0x38(%rsp), %rdi
movl $0x30, %edx
callq 0xb3c0
jmp 0x12add
movq %r13, 0x10(%rsp)
movl %r12d, 0x18(%rsp)
movw $0x10c, 0x1c(%rsp)      # imm = 0x10C
movb $0x0, 0x1e(%rsp)
movq %r15, %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0xb390
movq %rax, (%rbx)
movl $0x1, %ebp
jmp 0x12b49
leaq 0x18(%rsp), %rdi
callq 0xbab0
addq $0x8, %r15
xorl %ebp, %ebp
movq %r15, %rdi
xorl %esi, %esi
callq 0xb9f0
leaq 0x10(%rsp), %r15
testl %ebp, %ebp
je 0x129d1
cmpl $0x1, %ebp
je 0x12b74
cmpb $0x0, 0xc(%rsp)
jne 0x12b86
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
movl $0x28, %edi
callq 0xb3b0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
movq %rax, (%rdi)
leaq 0xc92d(%rip), %rsi      # 0x1f4d4
leaq 0xc94e(%rip), %rdx      # 0x1f4fc
callq 0xb2e0
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0xb1d0
xorl %ebp, %ebp
movq 0x1541c(%rip), %rsi     # 0x27fe8
movq 0x15375(%rip), %rdx     # 0x27f48
movq %rbx, %rdi
callq 0xbe60
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x12c02
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb940
jmp 0x12c02
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x12c1e
movq %rbx, %rdi
callq 0xb610
jmp 0x12c1e
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0xc020
movq %r14, %rdi
callq 0xbe90
movq %rax, %rdi
callq 0xf080