// File: /workspace/github_cpp_makefile_star2_O2/night-shift[P]Srl/src/lib/PMsgPack.cpp
// Function: Srl::PMsgPack::read(Srl::Lib::In&)
pair<MemBlock, Value> PMsgPack::read(In& source)
{
    if(this->scope) {

        if(this->scope->elements < 1) {
            if(this->scope_stack.size() < 1) {
                error();
            }
            this->scope_stack.pop();
            this->scope = this->scope_stack.size() > 0 ? &this->scope_stack.top() : nullptr;

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

        this->scope->elements--;
    }

    MemBlock name;
    auto prefix = source.read_move<uint8_t>(error);



    if(this->scope && this->scope->type == Type::Object) {
        name = prefix_is_str(prefix) ? read_name(prefix, this->buffer, source) : name;
        prefix = source.read_move<uint8_t>(error);

    }

    if(prefix_is_scope(prefix)) {

        Type type; size_t size;
        tie(type, size) = get_scope_info(prefix, source);

        this->scope_stack.emplace(type, size);
        this->scope = &this->scope_stack.top();

        return { name, type };
    }

    if(prefix_is_str(prefix)) {
        return { name, read_str(prefix, source) };
    }

    if(prefix_is_scalar(prefix)) {
        return { name, read_scalar(prefix, source) };
    }


    if(prefix_is_bin(prefix)) {
        return { name, read_bin(prefix, source) };
    }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
movq 0x70(%rsi), %rax
testq %rax, %rax
je 0x1c3ce
movl 0x4(%rax), %ecx
testl %ecx, %ecx
je 0x1c44a
decl %ecx
movl %ecx, 0x4(%rax)
leaq 0x115eb(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x11a00
movq 0x70(%r13), %rcx
xorl %r14d, %r14d
testq %rcx, %rcx
je 0x1c442
cmpb $0xe, (%rcx)
movl $0x0, %r15d
jne 0x1c50f
movl %eax, %ecx
andb $-0x20, %cl
cmpb $-0x60, %cl
setne %cl
leal 0x27(%rax), %edx
cmpb $0x3, %dl
setae %dl
xorl %r14d, %r14d
movl $0x0, %r15d
testb %dl, %cl
jne 0x1c500
movzbl %al, %esi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r12, %rdx
callq 0x1c8fb
cmpb $0x0, 0x16(%r14)
jne 0x1c4bc
movq 0x18(%rsp), %r15
jmp 0x1c4c1
xorl %r15d, %r15d
jmp 0x1c50f
leaq 0x20(%r13), %r14
movq %r14, %rdi
callq 0x12740
testq %rax, %rax
jne 0x1c467
leaq 0x1155e(%rip), %rdi     # 0x2d9c0
callq 0x11e90
movq %r14, %rdi
callq 0x114a0
movq %r14, %rdi
callq 0x12740
testq %rax, %rax
je 0x1c499
movq 0x50(%r13), %rax
cmpq 0x58(%r13), %rax
jne 0x1c493
movq 0x68(%r13), %rcx
movl $0x1e0, %eax            # imm = 0x1E0
addq -0x8(%rcx), %rax
addq $-0x28, %rax
jmp 0x1c49b
xorl %eax, %eax
movq %rax, 0x70(%r13)
xorps %xmm0, %xmm0
andl $0x0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movw $0x10, 0x24(%rbx)
movb $0x0, 0x26(%rbx)
jmp 0x1c63c
leaq 0x18(%rsp), %r15
movl 0x20(%rsp), %r14d
cmpb $0x1, 0x18(%r12)
jne 0x1c500
leaq 0x8(%r13), %rbp
movq 0x8(%r13), %rdi
movq 0x10(%r13), %rax
subq %rdi, %rax
cmpq %r14, %rax
jae 0x1c4f1
movq %rbp, %rdi
movq %r14, %rsi
callq 0x11f70
movq (%rbp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x11bf0
movq (%rbp), %r15
leaq 0x114b9(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x11a00
cmpb $-0x60, %al
setge %cl
movl %eax, %edx
andb $-0x4, %dl
cmpb $-0x24, %dl
setne %dl
testb %dl, %cl
jne 0x1c53c
testb $0x40, %al
jne 0x1c56f
movzbl %al, %ecx
testb $0x10, %al
sete %bpl
xorb $0xf, %bpl
andl $0xf, %ecx
jmp 0x1c5e6
movl %eax, %ecx
andb $-0x20, %cl
cmpb $-0x60, %cl
setne %cl
leal 0x27(%rax), %edx
cmpb $0x3, %dl
setae %dl
testb %dl, %cl
jne 0x1c595
leaq 0x10(%rbx), %rdi
movzbl %al, %esi
movq %r12, %rdx
callq 0x1c8fb
movq %r15, (%rbx)
movq %r14, 0x8(%rbx)
jmp 0x1c63c
testb $0x2, %al
sete %bpl
orb $0xe, %bpl
leaq 0x11440(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
testb $0x1, %al
jne 0x1c5d8
callq 0x11160
rolw $0x8, %ax
movzwl %ax, %ecx
jmp 0x1c5e6
leal 0x36(%rax), %ecx
cmpb $0xa, %cl
setae %dl
leal 0x20(%rax), %esi
cmpb $-0x1c, %sil
setae %sil
testb %sil, %dl
jne 0x1c64e
movl %eax, %edx
andb $-0x2, %dl
cmpb $-0x3e, %dl
jne 0x1c683
xorl %ecx, %ecx
cmpb $-0x3d, %al
sete %cl
movq %rcx, 0x10(%rsp)
pushq $0x1
popq %rax
movb $0x1, %cl
xorl %edx, %edx
jmp 0x1c8d4
callq 0x11400
movl %eax, %edi
callq 0x1c24a
movl %eax, %ecx
leaq 0xf(%rsp), %rsi
movb %bpl, (%rsi)
leaq 0x10(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x20(%r13), %rdi
callq 0x118f0
movq 0x50(%r13), %rax
cmpq 0x58(%r13), %rax
jne 0x1c616
movq 0x68(%r13), %rcx
movl $0x1e0, %eax            # imm = 0x1E0
addq -0x8(%rcx), %rax
addq $-0x28, %rax
movq %rax, 0x70(%r13)
movq %r15, (%rbx)
movq %r14, 0x8(%rbx)
movb 0xf(%rsp), %al
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
andl $0x0, 0x20(%rbx)
movb %al, 0x24(%rbx)
andw $0x0, 0x25(%rbx)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leal 0x3c(%rax), %ecx
cmpb $0x2, %cl
ja 0x1c6c5
cmpb $-0x3b, %al
je 0x1c6ff
movzbl %al, %eax
leaq 0x11358(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
cmpl $0xc4, %eax
jne 0x1c713
callq 0x11a00
movzbl %al, %eax
jmp 0x1c718
cmpb $0x9, %cl
ja 0x1c6ea
movzbl %al, %eax
addl $0xffffff36, %eax       # imm = 0xFFFFFF36
leaq 0x5319(%rip), %rcx      # 0x219b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x11319(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x11210
callq 0x1ca80
andq $0x0, 0x10(%rsp)
movss %xmm0, 0x10(%rsp)
jmp 0x1c85b
leaq 0x112f4(%rip), %rdi     # 0x2d9c0
callq 0x11e90
xorps %xmm0, %xmm0
andl $0x0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movw $0xb, 0x24(%rbx)
jmp 0x1c4b3
cmpb $-0x40, %al
jne 0x1c747
andq $0x0, 0x10(%rsp)
xorl %ecx, %ecx
movb $0xb, %dl
xorl %eax, %eax
jmp 0x1c8d4
leaq 0x112ba(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x11160
movzwl %ax, %eax
jmp 0x1c718
callq 0x11400
movl %eax, %esi
leaq 0x1129f(%rip), %rdx     # 0x2d9c0
movq %r12, %rdi
callq 0x12a90
movq %r15, (%rbx)
movq %r14, 0x8(%rbx)
andq $0x0, 0x10(%rbx)
movq %rax, 0x18(%rbx)
movl %edx, 0x20(%rbx)
movw $0xd, 0x24(%rbx)
jmp 0x1c4b3
movzbl %al, %ecx
movl %ecx, %edx
orl $-0x20, %edx
testb %al, %al
cmovnsl %ecx, %edx
movslq %edx, %rax
movq %rax, 0x10(%rsp)
pushq $0x4
popq %rax
movb $0x1, %cl
movb $0x5, %dl
jmp 0x1c8d4
leaq 0x11251(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x11400
movl %eax, %edi
callq 0x1c24a
movl %eax, %eax
movq %rax, 0x10(%rsp)
pushq $0x4
popq %rax
movb $0x1, %cl
movb $0x6, %dl
jmp 0x1c8d4
leaq 0x11228(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x11a60
movq %rax, %rdi
callq 0x1ca36
movq %rax, 0x10(%rsp)
pushq $0x8
popq %rax
movb $0x1, %cl
movb $0x7, %dl
jmp 0x1c8d4
leaq 0x11200(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x11a00
movzbl %al, %eax
movq %rax, 0x10(%rsp)
pushq $0x1
popq %rax
movb $0x1, %cl
movb $0x2, %dl
jmp 0x1c8d4
leaq 0x111dd(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x11160
rolw $0x8, %ax
movzwl %ax, %eax
movq %rax, 0x10(%rsp)
pushq $0x2
popq %rax
movb $0x1, %cl
movb $0x4, %dl
jmp 0x1c8d4
leaq 0x111b6(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x11d30
rolw $0x8, %ax
movswq %ax, %rax
movq %rax, 0x10(%rsp)
pushq $0x2
popq %rax
movb $0x1, %cl
movb $0x3, %dl
jmp 0x1c8d4
leaq 0x1118e(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x11c20
callq 0x1caa7
andq $0x0, 0x10(%rsp)
cvtsd2ss %xmm0, %xmm1
cvtss2sd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jne 0x1c8c7
jp 0x1c8c7
movss %xmm1, 0x10(%rsp)
pushq $0x4
popq %rax
movb $0x1, %cl
movb $0x9, %dl
jmp 0x1c8d4
leaq 0x11155(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x11760
movq %rax, %rdi
callq 0x1ca5b
movq %rax, 0x10(%rsp)
pushq $0x8
popq %rax
movb $0x1, %cl
movb $0x8, %dl
jmp 0x1c8d4
leaq 0x11130(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x12230
movsbq %al, %rax
movq %rax, 0x10(%rsp)
pushq $0x1
popq %rax
movb $0x1, %dl
movb $0x1, %cl
jmp 0x1c8d4
leaq 0x1110f(%rip), %rsi     # 0x2d9c0
movq %r12, %rdi
callq 0x11fd0
movl %eax, %edi
callq 0x1ca13
cltq
jmp 0x1c757
movsd %xmm0, 0x10(%rsp)
pushq $0x8
popq %rax
movb $0x1, %cl
movb $0xa, %dl
movq %r15, (%rbx)
movq %r14, 0x8(%rbx)
andq $0x0, 0x10(%rbx)
movq 0x10(%rsp), %rsi
movq %rsi, 0x18(%rbx)
movl %eax, 0x20(%rbx)
movb %dl, 0x24(%rbx)
movb $0x0, 0x25(%rbx)
movb %cl, 0x26(%rbx)
jmp 0x1c63c