// File: /workspace/github_cpp_makefile_star2_O3/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 0x18264
movl 0x4(%rax), %ecx
testl %ecx, %ecx
je 0x182e3
decl %ecx
movl %ecx, 0x4(%rax)
leaq 0x10115(%rip), %rsi     # 0x28380
movq %r12, %rdi
callq 0xb660
movq 0x70(%r13), %rcx
xorl %r14d, %r14d
testq %rcx, %rcx
je 0x182db
cmpb $0xe, (%rcx)
movl $0x0, %r15d
jne 0x18439
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 0x1842a
movzbl %al, %esi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r12, %rdx
callq 0x1886f
cmpb $0x0, 0x16(%r14)
jne 0x183e6
movq 0x18(%rsp), %r15
jmp 0x183eb
xorl %r15d, %r15d
jmp 0x18439
movq 0x68(%r13), %rax
movq %rax, %rcx
subq 0x48(%r13), %rcx
sarq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
leaq (%rcx,%rcx,2), %rax
movq 0x40(%r13), %rcx
movq 0x50(%r13), %rdx
subq 0x58(%r13), %rdx
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %r14 # imm = 0xCCCCCCCCCCCCCCCD
imulq %r14, %rdx
leaq (%rdx,%rax,4), %rax
subq 0x30(%r13), %rcx
sarq $0x3, %rcx
movabsq $0x3333333333333333, %r15 # imm = 0x3333333333333333
imulq %r15, %rcx
cmpq %rcx, %rax
jne 0x18356
cmpq $0x0, 0x1004d(%rip)     # 0x28390
je 0x1886a
leaq 0x10030(%rip), %rdi     # 0x28380
callq *0x10042(%rip)          # 0x28398
leaq 0x20(%r13), %rdi
callq 0xb300
movq 0x68(%r13), %rcx
movq %rcx, %rax
subq 0x48(%r13), %rax
sarq $0x3, %rax
cmpq $0x1, %rcx
adcq $-0x1, %rax
leaq (%rax,%rax,2), %rsi
movq 0x40(%r13), %rdi
movq 0x50(%r13), %rax
movq 0x58(%r13), %rdx
movq %rax, %r8
subq %rdx, %r8
sarq $0x3, %r8
imulq %r14, %r8
subq 0x30(%r13), %rdi
leaq (%r8,%rsi,4), %rsi
sarq $0x3, %rdi
imulq %r15, %rdi
cmpq %rdi, %rsi
jne 0x183ad
xorl %eax, %eax
jmp 0x183bf
cmpq %rdx, %rax
jne 0x183bb
movl $0x1e0, %eax            # imm = 0x1E0
addq -0x8(%rcx), %rax
addq $-0x28, %rax
movq %rax, 0x70(%r13)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%rbx)
movdqu %xmm0, (%rbx)
movl $0x0, 0x20(%rbx)
movw $0x10, 0x24(%rbx)
movb $0x0, 0x26(%rbx)
jmp 0x18568
leaq 0x18(%rsp), %r15
movl 0x20(%rsp), %r14d
cmpb $0x1, 0x18(%r12)
jne 0x1842a
leaq 0x8(%r13), %rbp
movq 0x8(%r13), %rdi
movq 0x10(%r13), %rax
subq %rdi, %rax
cmpq %r14, %rax
jae 0x1841b
movq %rbp, %rdi
movq %r14, %rsi
callq 0xb980
movq (%rbp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xb790
movq (%rbp), %r15
leaq 0xff4f(%rip), %rsi      # 0x28380
movq %r12, %rdi
callq 0xb660
cmpb $-0x60, %al
setge %cl
movl %eax, %edx
andb $-0x4, %dl
cmpb $-0x24, %dl
setne %dl
testb %dl, %cl
jne 0x18466
testb $0x40, %al
jne 0x18499
movzbl %al, %ecx
testb $0x10, %al
sete %bpl
xorb $0xf, %bpl
andl $0xf, %ecx
jmp 0x1850c
movl %eax, %ecx
andb $-0x20, %cl
cmpb $-0x60, %cl
setne %cl
leal 0x27(%rax), %edx
cmpb $0x3, %dl
setae %dl
testb %dl, %cl
jne 0x184bf
leaq 0x10(%rbx), %rdi
movzbl %al, %esi
movq %r12, %rdx
callq 0x1886f
movq %r15, (%rbx)
movq %r14, 0x8(%rbx)
jmp 0x18568
testb $0x2, %al
sete %bpl
orb $0xe, %bpl
leaq 0xfed6(%rip), %rsi      # 0x28380
movq %r12, %rdi
testb $0x1, %al
jne 0x18503
callq 0xb0f0
rolw $0x8, %ax
movzwl %ax, %ecx
jmp 0x1850c
leal 0x36(%rax), %ecx
cmpb $0xa, %cl
setae %dl
leal 0x20(%rax), %esi
cmpb $-0x1c, %sil
setae %sil
testb %sil, %dl
jne 0x1857a
movl %eax, %edx
andb $-0x2, %dl
cmpb $-0x3e, %dl
jne 0x185af
xorl %ecx, %ecx
cmpb $-0x3d, %al
sete %cl
movd %ecx, %xmm0
movl $0x1, %eax
movb $0x1, %cl
xorl %edx, %edx
jmp 0x18844
callq 0xb290
movl %eax, %ecx
bswapl %ecx
leaq 0xf(%rsp), %rsi
movb %bpl, (%rsi)
leaq 0x10(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x20(%r13), %rdi
callq 0xb570
movq 0x50(%r13), %rax
cmpq 0x58(%r13), %rax
jne 0x1853c
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
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%rbx)
movl $0x0, 0x20(%rbx)
movb %al, 0x24(%rbx)
movw $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 0x185e6
cmpb $-0x3b, %al
je 0x18637
movzbl %al, %eax
leaq 0xfdec(%rip), %rsi      # 0x28380
movq %r12, %rdi
cmpl $0xc4, %eax
jne 0x1864b
callq 0xb660
movzbl %al, %ebp
jmp 0x18652
cmpb $0x9, %cl
ja 0x18620
movzbl %al, %eax
addl $0xffffff36, %eax       # imm = 0xFFFFFF36
leaq 0x63cd(%rip), %rcx      # 0x1e990
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xfdad(%rip), %rsi      # 0x28380
movq %r12, %rdi
callq 0xb160
movd %xmm0, %eax
bswapl %eax
jmp 0x187cf
cmpq $0x0, 0xfda2(%rip)      # 0x28390
je 0x1886a
leaq 0xfd85(%rip), %rdi      # 0x28380
callq *0xfd97(%rip)           # 0x28398
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%rbx)
movdqu %xmm0, (%rbx)
movl $0x0, 0x20(%rbx)
movw $0xb, 0x24(%rbx)
jmp 0x183dd
cmpb $-0x40, %al
jne 0x186ad
xorl %ecx, %ecx
movb $0xb, %dl
pxor %xmm0, %xmm0
xorl %eax, %eax
jmp 0x18844
leaq 0xfd42(%rip), %rsi      # 0x28380
movq %r12, %rdi
callq 0xb0f0
movzwl %ax, %ebp
jmp 0x18652
callq 0xb290
movl %eax, %ebp
movl %ebp, %r13d
movq 0x10(%r12), %rax
movq %rax, 0x48(%r12)
leaq (%rax,%r13), %rcx
cmpq 0x8(%r12), %rcx
jb 0x18681
leaq 0xfd0f(%rip), %rdx      # 0x28380
movq %r12, %rdi
movq %r13, %rsi
callq 0xb210
movq 0x10(%r12), %rax
addq %rax, %r13
movq %r13, 0x10(%r12)
xorl %ecx, %ecx
movq %rcx, 0x48(%r12)
movq %r15, (%rbx)
movq %r14, 0x8(%rbx)
movq %rcx, 0x10(%rbx)
movq %rax, 0x18(%rbx)
movl %ebp, 0x20(%rbx)
movw $0xd, 0x24(%rbx)
jmp 0x183dd
movzbl %al, %ecx
movl %ecx, %edx
orl $-0x20, %edx
testb %al, %al
cmovnsl %ecx, %edx
movslq %edx, %rax
movq %rax, %xmm0
movl $0x4, %eax
movb $0x1, %cl
movb $0x5, %dl
jmp 0x18844
leaq 0xfca9(%rip), %rsi      # 0x28380
movq %r12, %rdi
callq 0xb290
bswapl %eax
movd %eax, %xmm0
movl $0x4, %eax
movb $0x1, %cl
movb $0x6, %dl
jmp 0x18844
leaq 0xfc86(%rip), %rsi      # 0x28380
movq %r12, %rdi
callq 0xb6a0
bswapq %rax
movq %rax, %xmm0
movl $0x8, %eax
movb $0x1, %cl
movb $0x7, %dl
jmp 0x18844
leaq 0xfc61(%rip), %rsi      # 0x28380
movq %r12, %rdi
callq 0xb660
movzbl %al, %eax
movd %eax, %xmm0
movl $0x1, %eax
movb $0x1, %cl
movb $0x2, %dl
jmp 0x18844
leaq 0xfc3d(%rip), %rsi      # 0x28380
movq %r12, %rdi
callq 0xb0f0
rolw $0x8, %ax
movzwl %ax, %eax
movd %eax, %xmm0
movl $0x2, %eax
movb $0x1, %cl
movb $0x4, %dl
jmp 0x18844
leaq 0xfc15(%rip), %rsi      # 0x28380
movq %r12, %rdi
callq 0xb830
rolw $0x8, %ax
movswq %ax, %rax
movq %rax, %xmm0
movl $0x2, %eax
movb $0x1, %cl
movb $0x3, %dl
jmp 0x18844
leaq 0xfbeb(%rip), %rsi      # 0x28380
movq %r12, %rdi
callq 0xb7b0
pxor %xmm1, %xmm1
punpcklbw %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
pshufd $0x4e, %xmm0, %xmm0     # xmm0 = xmm0[2,3,0,1]
pshuflw $0x1b, %xmm0, %xmm0     # xmm0 = xmm0[3,2,1,0,4,5,6,7]
pshufhw $0x1b, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,3,7,6,5,4]
packuswb %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtsd2ss %xmm0, %xmm1
cvtss2sd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jne 0x1883b
jp 0x1883b
movd %xmm1, %eax
movd %eax, %xmm0
movl $0x4, %eax
movb $0x1, %cl
movb $0x9, %dl
jmp 0x18844
leaq 0xfb9b(%rip), %rsi      # 0x28380
movq %r12, %rdi
callq 0xb4c0
bswapq %rax
movq %rax, %xmm0
movl $0x8, %eax
movb $0x1, %cl
movb $0x8, %dl
jmp 0x18844
leaq 0xfb79(%rip), %rsi      # 0x28380
movq %r12, %rdi
callq 0xbb20
movsbq %al, %rax
movq %rax, %xmm0
movl $0x1, %eax
movb $0x1, %dl
movb $0x1, %cl
jmp 0x18844
leaq 0xfb56(%rip), %rsi      # 0x28380
movq %r12, %rdi
callq 0xb9b0
bswapl %eax
cltq
jmp 0x186bd
movl $0x8, %eax
movb $0x1, %cl
movb $0xa, %dl
movq %r15, (%rbx)
movq %r14, 0x8(%rbx)
movq $0x0, 0x10(%rbx)
movq %xmm0, 0x18(%rbx)
movl %eax, 0x20(%rbx)
movb %dl, 0x24(%rbx)
movb $0x0, 0x25(%rbx)
movb %cl, 0x26(%rbx)
jmp 0x18568
callq 0xb2d0