// File: /workspace/github_cpp_makefile_star2_O3/night-shift[P]Srl/src/lib/PMsgPack.cpp
// Function: Srl::PMsgPack::write(Srl::Value const&, Srl::Lib::MemBlock const&, Srl::Lib::Out&)
void PMsgPack::write(const Value& value, const MemBlock& name, Out& out)
{
    auto type = value.type();

    if(type == Type::Scope_End) {
        assert(this->scope_stack.size() > 0);

        uint32_t scope_elems = this->scope->elements;
        auto scope_elems_be = swap_bytes(scope_elems);

        out.write(this->scope->ticket, (const uint8_t*)&scope_elems_be, 0, 4);
        this->scope_stack.pop();
        this->scope = this->scope_stack.size() > 0 ? &this->scope_stack.top() : nullptr;

        return;
    }

    if(this->scope) {
        if(this->scope->type == Type::Object) {
            write_str(name, out);
        }
        this->scope_stack.top().elements++;
    }


    if(TpTools::is_scope(type)) {
        this->write_scope(type, out);
        return;
    }

    srl_to_msgp(value, out);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r13
movq %rdi, %r14
movb 0x14(%rsi), %bl
cmpb $0x10, %bl
jne 0x17668
movq 0x68(%r14), %rax
movq %rax, %rcx
subq 0x48(%r14), %rcx
sarq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
leaq (%rcx,%rcx,2), %rax
movq 0x40(%r14), %rcx
movq 0x50(%r14), %rdx
subq 0x58(%r14), %rdx
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %rbp # imm = 0xCCCCCCCCCCCCCCCD
imulq %rbp, %rdx
leaq (%rdx,%rax,4), %rax
subq 0x30(%r14), %rcx
sarq $0x3, %rcx
movabsq $0x3333333333333333, %rbx # imm = 0x3333333333333333
imulq %rbx, %rcx
cmpq %rcx, %rax
je 0x17e70
movq 0x70(%r14), %r12
movl 0x4(%r12), %eax
bswapl %eax
movl %eax, 0x8(%rsp)
cmpq $0x3, 0x10(%r12)
jbe 0x17e8f
leaq 0x20(%r14), %r15
cmpb $0x1, 0x80(%r13)
jne 0x1765c
movq 0x20(%r12), %rcx
cmpq 0x68(%r13), %rcx
jne 0x1772f
movq 0x8(%r12), %rcx
movl %eax, (%rcx)
jmp 0x17784
movq %rsi, %r15
movq 0x70(%r14), %rax
testq %rax, %rax
je 0x1769e
cmpb $0xe, (%rax)
jne 0x17684
movq %rdx, %rdi
movq %r13, %rsi
callq 0x17ecd
movq 0x50(%r14), %rax
cmpq 0x58(%r14), %rax
jne 0x1769b
movq 0x68(%r14), %rcx
movl $0x1e0, %eax            # imm = 0x1E0
addq -0x8(%rcx), %rax
incl -0x24(%rax)
movl %ebx, %eax
andb $-0x2, %al
cmpb $0xe, %al
jne 0x176c2
movzbl %bl, %esi
movq %r14, %rdi
movq %r13, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbe30
movzbl 0x14(%r15), %eax
cmpq $0xd, %rax
ja 0x17eae
leaq 0x7280(%rip), %rcx      # 0x1e958
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%r15), %rbx
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17c00
cmpq $0x0, 0x58(%r13)
jne 0x17706
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x1771a
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17c0d
movq 0x88(%r13), %rdi
callq 0xb7e0
movq %rax, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq 0x88(%r13), %rdi
movq 0x18(%r12), %rsi
xorl %edx, %edx
callq 0xba70
movq 0x88(%r13), %rdi
leaq 0x8(%rsp), %rsi
movl $0x4, %edx
callq 0xbb40
movq 0x88(%r13), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0xba70
movq %r15, %rdi
callq 0xb300
movq 0x68(%r14), %rcx
movq %rcx, %rax
subq 0x48(%r14), %rax
sarq $0x3, %rax
cmpq $0x1, %rcx
adcq $-0x1, %rax
leaq (%rax,%rax,2), %rsi
movq 0x40(%r14), %rdi
movq 0x50(%r14), %rax
movq 0x58(%r14), %rdx
movq %rax, %r8
subq %rdx, %r8
sarq $0x3, %r8
imulq %rbp, %r8
subq 0x30(%r14), %rdi
leaq (%r8,%rsi,4), %rsi
sarq $0x3, %rdi
imulq %rbx, %rdi
cmpq %rdi, %rsi
jne 0x177da
xorl %eax, %eax
jmp 0x177ec
cmpq %rdx, %rax
jne 0x177e8
movl $0x1e0, %eax            # imm = 0x1E0
addq -0x8(%rcx), %rax
addq $-0x28, %rax
movq %rax, 0x70(%r14)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17b8d
cmpq $0x0, 0x58(%r13)
jne 0x17820
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17834
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17b9a
movzwl 0x8(%r15), %r14d
movb $-0x33, 0x7(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x18971
testb %al, %al
jne 0x177f0
rolw $0x8, %r14w
leaq 0x8(%rsp), %r15
movw %r14w, (%r15)
leaq 0x7(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r15, %rsi
callq 0xb4d0
jmp 0x177f0
cmpb $0x0, 0x16(%r15)
jne 0x17ba2
movq 0x8(%r15), %rax
jmp 0x17ba6
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17bc3
cmpq $0x0, 0x58(%r13)
jne 0x178c2
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x178d6
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17bd0
movzbl 0x8(%r15), %r14d
movb $-0x34, 0x8(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x18971
testb %al, %al
jne 0x177f0
leaq 0x7(%rsp), %r15
movb %r14b, (%r15)
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r15, %rsi
callq 0xb8f0
jmp 0x177f0
movq 0x8(%r15), %rbx
movb $-0x2f, 0x7(%rsp)
testw %bx, %bx
js 0x17953
movl %ebx, %edi
andl $0x7fff, %edi           # imm = 0x7FFF
movq %r13, %rsi
callq 0x18971
testb %al, %al
jne 0x177f0
movswq %bx, %rdi
movq %r13, %rsi
callq 0x189e4
testb %al, %al
jne 0x177f0
rolw $0x8, %bx
leaq 0x8(%rsp), %r14
movw %bx, (%r14)
leaq 0x7(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r14, %rsi
callq 0xb5a0
jmp 0x177f0
movq 0x8(%r15), %r14
movb $-0x2d, 0x7(%rsp)
testq %r14, %r14
js 0x179b2
movq %r14, %rdi
movq %r13, %rsi
callq 0x18971
testb %al, %al
jne 0x177f0
movq %r14, %rdi
movq %r13, %rsi
callq 0x189e4
testb %al, %al
jne 0x177f0
bswapq %r14
leaq 0x8(%rsp), %r15
movq %r14, (%r15)
leaq 0x7(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r15, %rsi
callq 0xbf20
jmp 0x177f0
movq 0x8(%r15), %rbx
movb $-0x30, 0x8(%rsp)
testb %bl, %bl
js 0x17a0f
movl %ebx, %edi
andl $0x7f, %edi
movq %r13, %rsi
callq 0x18971
testb %al, %al
jne 0x177f0
movsbq %bl, %rdi
movq %r13, %rsi
callq 0x189e4
testb %al, %al
jne 0x177f0
leaq 0x7(%rsp), %r14
movb %bl, (%r14)
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r14, %rsi
callq 0xb0d0
jmp 0x177f0
movq 0x8(%r15), %rbx
movb $-0x2e, 0x7(%rsp)
testl %ebx, %ebx
js 0x17a6d
movl %ebx, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq %r13, %rsi
callq 0x18971
testb %al, %al
jne 0x177f0
movslq %ebx, %rdi
movq %r13, %rsi
callq 0x189e4
testb %al, %al
jne 0x177f0
bswapl %ebx
leaq 0x8(%rsp), %r14
movl %ebx, (%r14)
leaq 0x7(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r14, %rsi
callq 0xc010
jmp 0x177f0
cmpb $0x0, 0x16(%r15)
jne 0x17c1b
movq 0x8(%r15), %r14
jmp 0x17c1f
movl 0x8(%r15), %r14d
movb $-0x32, 0x7(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x18971
testb %al, %al
jne 0x177f0
bswapl %r14d
leaq 0x8(%rsp), %r15
movl %r14d, (%r15)
leaq 0x7(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r15, %rsi
callq 0xb0a0
jmp 0x177f0
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17cd3
cmpq $0x0, 0x58(%r13)
jne 0x17b20
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17b34
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17ce0
movq 0x8(%r15), %r14
movb $-0x31, 0x7(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x18971
testb %al, %al
jne 0x177f0
bswapq %r14
leaq 0x8(%rsp), %r15
movq %r14, (%r15)
leaq 0x7(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r15, %rsi
callq 0xb060
jmp 0x177f0
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb $-0x40, (%rax)
jmp 0x177f0
leaq 0x8(%r15), %rax
movl 0x10(%r15), %ecx
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
movq %rcx, 0x8(%rdi)
movq %r13, %rsi
callq 0x17ecd
jmp 0x177f0
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb $-0x36, (%rax)
movq 0x8(%r15), %xmm0
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]
pshuflw $0x1b, %xmm0, %xmm0     # xmm0 = xmm0[3,2,1,0,4,5,6,7]
packuswb %xmm0, %xmm0
leaq 0x8(%rsp), %rsi
movd %xmm0, (%rsi)
movq %r13, %rdi
callq 0xb7d0
jmp 0x177f0
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
testq %rbx, %rbx
sete %cl
xorb $-0x3d, %cl
jmp 0x17e56
leaq 0x8(%r15), %r14
movl 0x10(%r15), %r15d
cmpq $0xff, %r15
ja 0x17c76
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17d1a
cmpq $0x0, 0x58(%r13)
jne 0x17c4d
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17c61
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17d27
cmpl $0xfffe, %r15d          # imm = 0xFFFE
ja 0x17d6d
movw %r15w, 0x8(%rsp)
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17dc7
cmpq $0x0, 0x58(%r13)
jne 0x17caa
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17cbe
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17dd4
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb $-0x35, (%rax)
movq 0x8(%r15), %xmm0
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
leaq 0x8(%rsp), %rsi
movq %xmm0, (%rsi)
movq %r13, %rdi
callq 0xbf40
jmp 0x177f0
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb $-0x3c, (%rax)
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17db5
cmpq $0x0, 0x58(%r13)
jne 0x17d47
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17d5b
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17dc2
movl %r15d, 0x8(%rsp)
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17de6
cmpq $0x0, 0x58(%r13)
jne 0x17d8f
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17da3
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17df3
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb %r15b, (%rax)
jmp 0x17e03
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb $-0x3b, (%rax)
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0xb4d0
jmp 0x17e03
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb $-0x3a, (%rax)
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0xb0a0
addq %r15, 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17e42
cmpq %r15, 0x58(%r13)
jae 0x17e1f
movq %r13, %rdi
callq 0xb460
cmpq %r15, 0x60(%r13)
jae 0x17e30
movq %r13, %rdi
movq %r15, %rsi
callq 0xbc90
subq %r15, 0x58(%r13)
movq 0x70(%r13), %rax
leaq (%rax,%r15), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17e4d
movq %r13, %rdi
movq %r15, %rsi
callq 0xb4f0
cmpl $0x1, %r15d
jne 0x17e5d
movb (%r14), %cl
movb %cl, (%rax)
jmp 0x177f0
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xb790
jmp 0x177f0
leaq 0x6b66(%rip), %rdi      # 0x1e9dd
leaq 0x6b7c(%rip), %rsi      # 0x1e9fa
leaq 0x6b8a(%rip), %rcx      # 0x1ea0f
movl $0x178, %edx            # imm = 0x178
callq 0xb540
leaq 0x6bc3(%rip), %rdi      # 0x1ea59
leaq 0x6bdb(%rip), %rsi      # 0x1ea78
leaq 0x6be8(%rip), %rcx      # 0x1ea8c
movl $0x2c, %edx
callq 0xb540
leaq 0x6b43(%rip), %rdi      # 0x1e9f8
leaq 0x6b3e(%rip), %rsi      # 0x1e9fa
leaq 0x6c13(%rip), %rcx      # 0x1ead6
movl $0xc2, %edx
callq 0xb540