// File: /workspace/github_cpp_makefile_star2_O1/night-shift[P]Srl/src/lib/PSrl.cpp
// Function: Srl::PSrl::read(Srl::Lib::In&)
pair<Lib::MemBlock, Value> PSrl::read(In& source)
{
    Flag flag; MemBlock name;
    tie(flag, name) = this->read_head(source);

    if(!flag) {
        if(this->scope_stack.size() < 1) {
            error();
        }
        this->pop_scope();

        return { MemBlock(), Type::Scope_End };
    }

    if(is_scope(flag)) {
        auto tp = flag & FObject ? Type::Object : Type::Array;
        this->push_scope(tp);

        return { name, tp };
    }

    if(flag & FNum) {
        return this->read_num(flag, name, source);
    }


    if(flag & (FBinary | FString)) {
        auto size  = decode_integer(source);
        auto block = source.read_block(size, error);
        auto type = flag & FBinary ? Type::Binary : Type::String;

        return { name, Value(block, type, Encoding::UTF8) };
    }

    if(flag & FNull) {
        return { name, Type::Null };
    }

    /* shouldn't end down here */
    error();
    return { name, Type::Null };
;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0xbcf0
movzbl (%r12), %ebp
movups 0x8(%r12), %xmm0
movaps %xmm0, (%rsp)
testl %ebp, %ebp
je 0x1a3fc
cmpb $0x40, %bpl
setb %al
orb %bpl, %al
testb $0x1, %al
jne 0x1a481
xorl %esi, %esi
testb $0x40, %bpl
sete %sil
movl %esi, %ebp
orb $0xe, %bpl
orl $0xe, %esi
movq %r15, %rdi
callq 0xbed0
movaps (%rsp), %xmm0
movups %xmm0, (%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movl $0x0, 0x20(%rbx)
movb %bpl, 0x24(%rbx)
movw $0x0, 0x25(%rbx)
jmp 0x1a50b
movq 0xa8(%r15), %rax
movq 0xc0(%r15), %rcx
movq %rcx, %rdx
subq 0xa0(%r15), %rdx
shrq $0x3, %rdx
cmpq $0x1, %rcx
adcq $-0x1, %rdx
subq 0xb0(%r15), %rax
addq 0x98(%r15), %rax
shlq $0x9, %rdx
addq %rdx, %rax
cmpq 0x88(%r15), %rax
jne 0x1a459
cmpq $0x0, 0xf20a(%rip)      # 0x29650
je 0x1a558
leaq 0xf1ed(%rip), %rdi      # 0x29640
callq *0xf1ff(%rip)           # 0x29658
movq %r15, %rdi
callq 0xbf50
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movl $0x0, 0x20(%rbx)
movw $0x10, 0x24(%rbx)
movb $0x0, 0x26(%rbx)
jmp 0x1a50b
testb $0x1, %bpl
jne 0x1a4fb
testb $0x30, %bpl
je 0x1a51b
movq %r14, %rdi
callq 0x19f0f
movq %rax, %r15
movq 0x10(%r14), %rax
movq %rax, 0x48(%r14)
addq %r15, %rax
cmpq 0x8(%r14), %rax
jb 0x1a4bf
leaq 0xf18c(%rip), %rdx      # 0x29640
movq %r14, %rdi
movq %r15, %rsi
callq 0xb210
movq 0x10(%r14), %rax
movq %r15, %rcx
addq %rax, %rcx
movq %rcx, 0x10(%r14)
xorl %ecx, %ecx
movq %rcx, 0x48(%r14)
testb $0x10, %bpl
sete %dl
xorb $0xd, %dl
movaps (%rsp), %xmm0
movups %xmm0, (%rbx)
movq %rcx, 0x10(%rbx)
movq %rax, 0x18(%rbx)
movl %r15d, 0x20(%rbx)
movb %dl, 0x24(%rbx)
movw $0x1, 0x25(%rbx)
jmp 0x1a50b
movq %rsp, %rcx
movq %rbx, %rdi
movl %ebp, %edx
movq %r14, %r8
callq 0xbad0
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
testb $0x8, %bpl
jne 0x1a538
cmpq $0x0, 0xf127(%rip)      # 0x29650
je 0x1a558
leaq 0xf10e(%rip), %rdi      # 0x29640
callq *0xf120(%rip)           # 0x29658
movaps (%rsp), %xmm0
movups %xmm0, (%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movl $0x0, 0x20(%rbx)
movw $0xb, 0x24(%rbx)
jmp 0x1a478
callq 0xb2d0
nop