// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x20(%rsi)
je 0x12719
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 0x128c1
movl %edx, 0x4(%rsp)
leaq 0x10(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x30(%rbx), %rax
movq %rax, 0x38(%rsp)
leaq 0x40(%rbx), %rax
movq %rax, 0x60(%rsp)
leaq 0x8(%rsp), %r15
cmpb $0x0, 0x51(%r14)
jne 0x12871
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movl $0x0, 0x50(%rsp)
movw $0xb, 0x54(%rsp)
movb $0x0, 0x56(%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), %rbp
movq 0x10(%rsp), %r12
leaq 0x18(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x50(%rsp)
movups (%rcx), %xmm0
movaps %xmm0, 0x40(%rsp)
movb 0x54(%rsp), %r13b
cmpb $0x10, %r13b
jne 0x127b8
movb $0x1, 0x51(%r14)
movl $0x3, %eax
jmp 0x12864
movl %r13d, %eax
andb $-0x2, %al
movq (%r14), %rdi
cmpb $0xe, %al
jne 0x1283c
movq (%rdi), %rdi
callq 0xbf80
movq %rax, (%rbx)
addq $0x8, %rax
movq %rax, 0x8(%rbx)
movq 0x30(%rsp), %rcx
movq %rcx, 0x18(%rbx)
movq %rcx, 0x10(%rbx)
movq $0x0, 0x20(%rbx)
movq %rax, 0x28(%rbx)
movq 0x38(%rsp), %rax
movq %rax, 0x38(%rbx)
movq %rax, 0x30(%rbx)
movq 0x60(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movb %r13b, 0x50(%rbx)
xorl %eax, %eax
movb %al, 0x51(%rbx)
movq (%r14), %rdi
movq %rbp, 0x8(%rsp)
movl %r12d, 0x10(%rsp)
movw $0x10c, 0x14(%rsp)      # imm = 0x10C
movb %al, 0x16(%rsp)
movq %r15, %rsi
callq 0xb390
movq %rax, 0x48(%rbx)
movl $0x1, %eax
jmp 0x12864
movq %rbp, 0x8(%rsp)
movl %r12d, 0x10(%rsp)
movw $0x10c, 0x14(%rsp)      # imm = 0x10C
movb $0x0, 0x16(%rsp)
movq %r14, %rsi
leaq 0x40(%rsp), %rdx
movq %r15, %rcx
callq 0xbf90
xorl %eax, %eax
testl %eax, %eax
je 0x1273d
cmpl $0x1, %eax
je 0x128c1
cmpb $0x0, 0x4(%rsp)
jne 0x128d3
movq (%r14), %rax
movq (%rax), %rdi
callq 0xbf80
movq %rax, (%rbx)
addq $0x8, %rax
movq %rax, 0x8(%rbx)
movq 0x30(%rsp), %rcx
movq %rcx, 0x18(%rbx)
movq %rcx, 0x10(%rbx)
movq $0x0, 0x20(%rbx)
movq %rax, 0x28(%rbx)
movq 0x38(%rsp), %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 $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0xb3b0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
movq %rax, (%rdi)
leaq 0xcbb8(%rip), %rsi      # 0x1f4ac
leaq 0xcbd8(%rip), %rdx      # 0x1f4d3
callq 0xb2e0
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xb1d0
xorl %ebp, %ebp
movq 0x156cf(%rip), %rsi     # 0x27fe8
movq 0x15628(%rip), %rdx     # 0x27f48
movq %rbx, %rdi
callq 0xbe60
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1294f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb940
jmp 0x1294f
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x12969
movq %rbx, %rdi
callq 0xb610
jmp 0x12969
movq %rax, %r14
movq %rbx, %rdi
callq 0xc020
movq %r14, %rdi
callq 0xbe90
nop