// File: /workspace/github_cpp_makefile_star2_O3/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 0x1a044
cmpb $0x40, %bpl
setb %al
orb %bpl, %al
testb $0x1, %al
jne 0x1a0c9
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 0x1a154
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 0x1a0a1
cmpq $0x0, 0xe5c2(%rip)      # 0x28650
je 0x1a1a1
leaq 0xe5a5(%rip), %rdi      # 0x28640
callq *0xe5b7(%rip)           # 0x28658
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 0x1a154
testb $0x1, %bpl
jne 0x1a144
testb $0x30, %bpl
je 0x1a164
movq %r14, %rdi
callq 0x19b95
movq %rax, %r15
movq 0x10(%r14), %rax
movq %rax, 0x48(%r14)
leaq (%rax,%r15), %rcx
cmpq 0x8(%r14), %rcx
jb 0x1a10c
leaq 0xe543(%rip), %rdx      # 0x28640
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 0x1a154
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 0x1a181
cmpq $0x0, 0xe4de(%rip)      # 0x28650
je 0x1a1a1
leaq 0xe4c5(%rip), %rdi      # 0x28640
callq *0xe4d7(%rip)           # 0x28658
movaps (%rsp), %xmm0
movups %xmm0, (%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movl $0x0, 0x20(%rbx)
movw $0xb, 0x24(%rbx)
jmp 0x1a0c0
callq 0xb2d0