// File: /workspace/github_cpp_makefile_star2_O2/night-shift[P]Srl/src/lib/Node.cpp
// Function: Srl::Node::consume_node(bool, unsigned long)
Node Node::consume_node(bool throw_ex, size_t)
{
    if(this->nodes.size() > 0) {
        auto itr = this->nodes.begin();
        auto stored_field = move(itr->field);
        this->nodes.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)) {
            Node node(this->env->tree, tp, false);
            node.name_ptr = this->env->store_string(seg_name).first;

            return node;

        } else {
            this->env->store_value(*this, val, seg_name);
        }
    }

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

    return Node(*this->env->tree);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x20(%rsi)
je 0x17e6a
movq 0x10(%r14), %r15
addq $0x8, %r14
leaq 0x18(%r15), %rsi
movq %rbx, %rdi
callq 0x11fe0
movq %r14, %rdi
movq %r15, %rsi
callq 0x12900
movq %rbx, %rax
jmp 0x17f74
movl %edx, 0xc(%rsp)
movq %rbx, 0x28(%rsp)
leaq 0x40(%rsp), %r13
leaq 0x30(%rsp), %r15
leaq 0x10(%rsp), %r12
cmpb $0x0, 0x51(%r14)
jne 0x17f1f
andl $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movw $0xb, 0x24(%rsp)
movb $0x0, 0x26(%rsp)
movq (%r14), %rdx
movq 0x250(%rdx), %rsi
addq $0x260, %rdx            # imm = 0x260
movq (%rsi), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %rbp
movq 0x10(%r13), %rax
movq %rax, 0x20(%rsp)
movups (%r13), %xmm0
movaps %xmm0, 0x10(%rsp)
movb 0x24(%rsp), %al
cmpb $0x10, %al
je 0x17f1a
movl %eax, %ecx
andb $-0x2, %cl
movq (%r14), %rdi
cmpb $0xe, %cl
je 0x17f3b
movq %rbx, 0x30(%rsp)
movl %ebp, 0x38(%rsp)
movw $0x10c, 0x3c(%rsp)      # imm = 0x10C
movb $0x0, 0x3e(%rsp)
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x12b00
jmp 0x17e82
movb $0x1, 0x51(%r14)
cmpb $0x0, 0xc(%rsp)
jne 0x17f83
movq (%r14), %rax
movq (%rax), %rsi
movq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x12c50
jmp 0x17f71
movq (%rdi), %rsi
movzbl %al, %edx
movq 0x28(%rsp), %r15
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x11530
movq (%r14), %rdi
leaq 0x30(%rsp), %rsi
movq %rbx, (%rsi)
movl %ebp, 0x8(%rsi)
movw $0x10c, 0xc(%rsi)       # imm = 0x10C
movb $0x0, 0xe(%rsi)
callq 0x115c0
movq %rax, 0x48(%r15)
movq %r15, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x115e0
movq %rax, %rbx
leaq 0x9557(%rip), %rsi      # 0x214ec
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x128f0
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x11300
xorl %ebp, %ebp
movq 0x1402b(%rip), %rsi     # 0x2bfe8
movq 0x13f84(%rip), %rdx     # 0x2bf48
movq %rbx, %rdi
callq 0x12920
movq %rax, %r14
movq %r15, %rdi
callq 0x12c70
jmp 0x17ff8
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x12cd8
testb %bpl, %bpl
jne 0x17ff0
jmp 0x17ff8
movq %rax, %r14
movq %rbx, %rdi
callq 0x119b0
movq %r14, %rdi
callq 0x12990