// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rcx, %r13
movq %rdi, %r14
movb 0x14(%rsi), %bl
cmpb $0x10, %bl
jne 0x177a6
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 0x18080
leaq 0x20(%r14), %r15
movq 0x70(%r14), %r12
movl 0x4(%r12), %eax
movl %eax, 0x18(%rsp)
movl $0x4, %eax
leaq 0x10(%rsp), %rcx
movb 0x17(%rsp,%rax), %dl
movb %dl, (%rcx)
incq %rcx
decq %rax
jne 0x1775b
movl 0x10(%rsp), %eax
movl %eax, 0x18(%rsp)
cmpq $0x3, 0x10(%r12)
jbe 0x1809f
cmpb $0x1, 0x80(%r13)
jne 0x17796
movq 0x20(%r12), %rax
cmpq 0x68(%r13), %rax
jne 0x1786d
movq 0x8(%r12), %rax
movl 0x18(%rsp), %ecx
movl %ecx, (%rax)
jmp 0x178c2
movq %rsi, %r15
movq 0x70(%r14), %rax
testq %rax, %rax
je 0x177dc
cmpb $0xe, (%rax)
jne 0x177c2
movq %rdx, %rdi
movq %r13, %rsi
callq 0x180dd
movq 0x50(%r14), %rax
cmpq 0x58(%r14), %rax
jne 0x177d9
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 0x17800
movzbl %bl, %esi
movq %r14, %rdi
movq %r13, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbe30
movzbl 0x14(%r15), %eax
cmpq $0xd, %rax
ja 0x180be
leaq 0x8142(%rip), %rcx      # 0x1f958
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%r15), %rbx
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17e07
cmpq $0x0, 0x58(%r13)
jne 0x17844
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17858
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17e14
movq 0x88(%r13), %rdi
callq 0xb7e0
movq %rax, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq 0x88(%r13), %rdi
movq 0x18(%r12), %rsi
xorl %edx, %edx
callq 0xba70
movq 0x88(%r13), %rdi
leaq 0x18(%rsp), %rsi
movl $0x4, %edx
callq 0xbb40
movq 0x88(%r13), %rdi
movq 0x30(%rsp), %rsi
movq 0x28(%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 0x17918
xorl %eax, %eax
jmp 0x1792a
cmpq %rdx, %rax
jne 0x17926
movl $0x1e0, %eax            # imm = 0x1E0
addq -0x8(%rcx), %rax
addq $-0x28, %rax
movq %rax, 0x70(%r14)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17d81
cmpq $0x0, 0x58(%r13)
jne 0x1795e
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17972
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17d8e
movb $-0x33, 0xf(%rsp)
movzwl 0x8(%r15), %r14d
movq %r14, %rdi
movq %r13, %rsi
callq 0x18cf5
testb %al, %al
jne 0x1792e
movw %r14w, 0x18(%rsp)
movl $0x1, %eax
leaq 0x10(%rsp), %rcx
movb 0x18(%rsp,%rax), %dl
movb %dl, (%rcx)
incq %rcx
decq %rax
je 0x179b0
movzwl 0x10(%rsp), %eax
leaq 0x18(%rsp), %r14
movw %ax, (%r14)
leaq 0xf(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r14, %rsi
callq 0xb4d0
jmp 0x1792e
cmpb $0x0, 0x16(%r15)
jne 0x17d96
movq 0x8(%r15), %rax
jmp 0x17d9a
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17db7
cmpq $0x0, 0x58(%r13)
jne 0x17a1e
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17a32
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17dc4
movb $-0x34, 0x18(%rsp)
movzbl 0x8(%r15), %r14d
movq %r14, %rdi
movq %r13, %rsi
callq 0x18cf5
testb %al, %al
jne 0x1792e
leaq 0x10(%rsp), %r15
movb %r14b, (%r15)
leaq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r15, %rsi
callq 0xb8f0
jmp 0x1792e
movb $-0x2f, 0xf(%rsp)
movq 0x8(%r15), %rbx
testw %bx, %bx
js 0x17aaf
movl %ebx, %edi
andl $0x7fff, %edi           # imm = 0x7FFF
movq %r13, %rsi
callq 0x18cf5
testb %al, %al
jne 0x1792e
movswq %bx, %rdi
movq %r13, %rsi
callq 0x18d68
testb %al, %al
jne 0x1792e
movw %bx, 0x18(%rsp)
movl $0x1, %eax
leaq 0x10(%rsp), %rcx
movb 0x18(%rsp,%rax), %dl
movb %dl, (%rcx)
incq %rcx
decq %rax
je 0x17ad2
movzwl 0x10(%rsp), %eax
leaq 0x18(%rsp), %r14
movw %ax, (%r14)
leaq 0xf(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r14, %rsi
callq 0xb5a0
jmp 0x1792e
movb $-0x2d, 0xf(%rsp)
movq 0x8(%r15), %r14
testq %r14, %r14
js 0x17b2c
movq %r14, %rdi
movq %r13, %rsi
callq 0x18cf5
testb %al, %al
jne 0x1792e
movq %r14, %rdi
movq %r13, %rsi
callq 0x18d68
testb %al, %al
jne 0x1792e
movq %r14, 0x18(%rsp)
movl $0x8, %eax
leaq 0x10(%rsp), %rcx
movb 0x17(%rsp,%rax), %dl
movb %dl, (%rcx)
incq %rcx
decq %rax
jne 0x17b4e
movq 0x10(%rsp), %rax
leaq 0x18(%rsp), %r14
movq %rax, (%r14)
leaq 0xf(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r14, %rsi
callq 0xbf20
jmp 0x1792e
movb $-0x30, 0x18(%rsp)
movq 0x8(%r15), %rbx
testb %bl, %bl
js 0x17ba8
movl %ebx, %edi
andl $0x7f, %edi
movq %r13, %rsi
callq 0x18cf5
testb %al, %al
jne 0x1792e
movsbq %bl, %rdi
movq %r13, %rsi
callq 0x18d68
testb %al, %al
jne 0x1792e
leaq 0x10(%rsp), %r14
movb %bl, (%r14)
leaq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r14, %rsi
callq 0xb0d0
jmp 0x1792e
movb $-0x2e, 0xf(%rsp)
movq 0x8(%r15), %rbx
testl %ebx, %ebx
js 0x17c06
movl %ebx, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq %r13, %rsi
callq 0x18cf5
testb %al, %al
jne 0x1792e
movslq %ebx, %rdi
movq %r13, %rsi
callq 0x18d68
testb %al, %al
jne 0x1792e
movl %ebx, 0x18(%rsp)
movl $0x4, %eax
leaq 0x10(%rsp), %rcx
movb 0x17(%rsp,%rax), %dl
movb %dl, (%rcx)
incq %rcx
decq %rax
jne 0x17c27
movl 0x10(%rsp), %eax
leaq 0x18(%rsp), %r14
movl %eax, (%r14)
leaq 0xf(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r14, %rsi
callq 0xc010
jmp 0x1792e
cmpb $0x0, 0x16(%r15)
jne 0x17e22
movq 0x8(%r15), %r14
jmp 0x17e26
movb $-0x32, 0xf(%rsp)
movl 0x8(%r15), %r14d
movq %r14, %rdi
movq %r13, %rsi
callq 0x18cf5
testb %al, %al
jne 0x1792e
movl %r14d, 0x18(%rsp)
movl $0x4, %eax
leaq 0x10(%rsp), %rcx
movb 0x17(%rsp,%rax), %dl
movb %dl, (%rcx)
incq %rcx
decq %rax
jne 0x17c9d
movl 0x10(%rsp), %eax
leaq 0x18(%rsp), %r14
movl %eax, (%r14)
leaq 0xf(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r14, %rsi
callq 0xb0a0
jmp 0x1792e
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17eda
cmpq $0x0, 0x58(%r13)
jne 0x17cf5
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17d09
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17ee7
movb $-0x31, 0xf(%rsp)
movq 0x8(%r15), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x18cf5
testb %al, %al
jne 0x1792e
movq %r14, 0x18(%rsp)
movl $0x8, %eax
leaq 0x10(%rsp), %rcx
movb 0x17(%rsp,%rax), %dl
movb %dl, (%rcx)
incq %rcx
decq %rax
jne 0x17d49
movq 0x10(%rsp), %rax
leaq 0x18(%rsp), %r14
movq %rax, (%r14)
leaq 0xf(%rsp), %rsi
movq %r13, %rdi
callq 0xb8f0
movq %r13, %rdi
movq %r14, %rsi
callq 0xb060
jmp 0x1792e
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb $-0x40, (%rax)
jmp 0x1792e
leaq 0x8(%r15), %rax
movl 0x10(%r15), %ecx
leaq 0x18(%rsp), %rdi
movq %rax, (%rdi)
movq %rcx, 0x8(%rdi)
movq %r13, %rsi
callq 0x180dd
jmp 0x1792e
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb $-0x36, (%rax)
movss 0x8(%r15), %xmm0
movss %xmm0, 0x18(%rsp)
movl $0x4, %eax
leaq 0x10(%rsp), %rcx
movb 0x17(%rsp,%rax), %dl
movb %dl, (%rcx)
incq %rcx
decq %rax
jne 0x17ddd
movss 0x10(%rsp), %xmm0
leaq 0x18(%rsp), %rsi
movss %xmm0, (%rsi)
movq %r13, %rdi
callq 0xb7d0
jmp 0x1792e
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
testq %rbx, %rbx
sete %cl
xorb $-0x3d, %cl
jmp 0x18066
leaq 0x8(%r15), %r14
movl 0x10(%r15), %r15d
cmpq $0xff, %r15
ja 0x17e7d
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17f2a
cmpq $0x0, 0x58(%r13)
jne 0x17e54
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17e68
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17f37
cmpl $0xfffe, %r15d          # imm = 0xFFFE
ja 0x17f7d
movw %r15w, 0x18(%rsp)
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17fd7
cmpq $0x0, 0x58(%r13)
jne 0x17eb1
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17ec5
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17fe4
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb $-0x35, (%rax)
movsd 0x8(%r15), %xmm0
movsd %xmm0, 0x18(%rsp)
movl $0x8, %eax
leaq 0x10(%rsp), %rcx
movb 0x17(%rsp,%rax), %dl
movb %dl, (%rcx)
incq %rcx
decq %rax
jne 0x17f00
movsd 0x10(%rsp), %xmm0
leaq 0x18(%rsp), %rsi
movsd %xmm0, (%rsi)
movq %r13, %rdi
callq 0xbf40
jmp 0x1792e
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb $-0x3c, (%rax)
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17fc5
cmpq $0x0, 0x58(%r13)
jne 0x17f57
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17f6b
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x17fd2
movl %r15d, 0x18(%rsp)
incq 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x17ff6
cmpq $0x0, 0x58(%r13)
jne 0x17f9f
movq %r13, %rdi
callq 0xb460
cmpq $0x0, 0x60(%r13)
jne 0x17fb3
movl $0x1, %esi
movq %r13, %rdi
callq 0xbc90
decq 0x58(%r13)
movq 0x70(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%r13)
jmp 0x18003
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb %r15b, (%rax)
jmp 0x18013
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb $-0x3b, (%rax)
leaq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0xb4d0
jmp 0x18013
movl $0x1, %esi
movq %r13, %rdi
callq 0xb4f0
movb $-0x3a, (%rax)
leaq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0xb0a0
addq %r15, 0x50(%r13)
cmpb $0x0, 0x80(%r13)
je 0x18052
cmpq %r15, 0x58(%r13)
jae 0x1802f
movq %r13, %rdi
callq 0xb460
cmpq %r15, 0x60(%r13)
jae 0x18040
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 0x1805d
movq %r13, %rdi
movq %r15, %rsi
callq 0xb4f0
cmpl $0x1, %r15d
jne 0x1806d
movb (%r14), %cl
movb %cl, (%rax)
jmp 0x1792e
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xb790
jmp 0x1792e
leaq 0x7956(%rip), %rdi      # 0x1f9dd
leaq 0x796c(%rip), %rsi      # 0x1f9fa
leaq 0x797a(%rip), %rcx      # 0x1fa0f
movl $0x178, %edx            # imm = 0x178
callq 0xb540
leaq 0x79b3(%rip), %rdi      # 0x1fa59
leaq 0x79cb(%rip), %rsi      # 0x1fa78
leaq 0x79d8(%rip), %rcx      # 0x1fa8c
movl $0x2c, %edx
callq 0xb540
leaq 0x7933(%rip), %rdi      # 0x1f9f8
leaq 0x792e(%rip), %rsi      # 0x1f9fa
leaq 0x7a03(%rip), %rcx      # 0x1fad6
movl $0xc2, %edx
callq 0xb540