// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x20(%rsi)
je 0x12663
movq 0x10(%r14), %r15
addq $0x8, %r14
movq 0x18(%r15), %rax
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x20(%r15), %rsi
callq 0xb6f0
leaq 0x28(%rbx), %rdi
leaq 0x40(%r15), %rsi
callq 0xb9d0
movzwl 0x68(%r15), %eax
movw %ax, 0x50(%rbx)
movq 0x60(%r15), %rax
movq %rax, 0x48(%rbx)
movq %r14, %rdi
movq %r15, %rsi
callq 0xb100
jmp 0x12771
movl %edx, 0x4(%rsp)
cmpb $0x0, 0x51(%r14)
jne 0x1271f
leaq 0x8(%rsp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movl $0x0, 0x40(%rsp)
movw $0xb, 0x44(%rsp)
movb $0x0, 0x46(%rsp)
movq (%r14), %rdx
movq 0x250(%rdx), %rsi
addq $0x260, %rdx            # imm = 0x260
movq (%rsi), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %rbp
leaq 0x18(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x40(%rsp)
movups (%rcx), %xmm0
movaps %xmm0, 0x30(%rsp)
movb 0x44(%rsp), %r13b
cmpb $0x10, %r13b
je 0x1271a
movl %r13d, %eax
andb $-0x2, %al
movq (%r14), %rdi
cmpb $0xe, %al
je 0x12783
movq %r12, 0x8(%rsp)
movl %ebp, 0x10(%rsp)
movw $0x10c, 0x14(%rsp)      # imm = 0x10C
movb $0x0, 0x16(%rsp)
movq %r14, %rsi
leaq 0x30(%rsp), %rdx
movq %r15, %rcx
callq 0xbf90
cmpb $0x1, 0x51(%r14)
jne 0x12677
jmp 0x1271f
movb $0x1, 0x51(%r14)
cmpb $0x0, 0x4(%rsp)
jne 0x127ec
movq (%r14), %rax
movq (%rax), %rdi
callq 0xbf80
movq %rax, (%rbx)
addq $0x8, %rax
movq %rax, 0x8(%rbx)
leaq 0x10(%rbx), %rcx
movq %rcx, 0x18(%rbx)
movq %rcx, 0x10(%rbx)
movq $0x0, 0x20(%rbx)
movq %rax, 0x28(%rbx)
leaq 0x30(%rbx), %rax
movq %rax, 0x38(%rbx)
movq %rax, 0x30(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rbx)
movw $0x10e, 0x50(%rbx)      # imm = 0x10E
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rdi), %rdi
callq 0xbf80
movq %rax, (%rbx)
addq $0x8, %rax
movq %rax, 0x8(%rbx)
leaq 0x10(%rbx), %rcx
movq %rcx, 0x18(%rbx)
movq %rcx, 0x10(%rbx)
movq $0x0, 0x20(%rbx)
movq %rax, 0x28(%rbx)
leaq 0x30(%rbx), %rax
movq %rax, 0x38(%rbx)
movq %rax, 0x30(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rbx)
movb %r13b, 0x50(%rbx)
xorl %eax, %eax
movb %al, 0x51(%rbx)
movq (%r14), %rdi
leaq 0x8(%rsp), %rsi
movq %r12, (%rsi)
movl %ebp, 0x8(%rsi)
movw $0x10c, 0xc(%rsi)       # imm = 0x10C
movb %al, 0xe(%rsi)
callq 0xb390
movq %rax, 0x48(%rbx)
jmp 0x12771
movl $0x28, %edi
callq 0xb3b0
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xbca3(%rip), %rsi      # 0x1e4ac
leaq 0xbcc3(%rip), %rdx      # 0x1e4d3
leaq 0x8(%rsp), %rdi
callq 0xb2e0
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xb1d0
xorl %ebp, %ebp
movq 0x147b5(%rip), %rsi     # 0x26fe8
movq 0x1470e(%rip), %rdx     # 0x26f48
movq %rbx, %rdi
callq 0xbe60
movq %rax, %r14
movq %rbx, %rdi
callq 0xc020
jmp 0x1287b
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x12869
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb940
testb %bpl, %bpl
jne 0x12873
jmp 0x1287b
movq %rax, %r14
movq %rbx, %rdi
callq 0xb610
movq %r14, %rdi
callq 0xbe90
nop