// File: /workspace/github_cpp_makefile_star2_O1/night-shift[P]Srl/src/lib/Environment.cpp
// Function: GLOBAL__sub_I_Environment.cpp
void Environment::write_conv(const Value& value, const String& val_name)
{
    MemBlock name_conv;

    if(val_name.encoding() == Encoding::UTF8) {
        name_conv = MemBlock(val_name.data(), val_name.size());

    } else {
        auto& buffer = this->str_buffer;
        auto size = Tools::conv_charset(Encoding::UTF8, val_name, buffer, true);
        name_conv = MemBlock(buffer.data(), size);
    }

    auto type = value.type();

    bool no_conversion_needed =
        /* scope types don't need conversion */
        TpTools::is_scope(type) || type == Type::Scope_End ||
        /* strings must be UTF8 in text formats */
        (type == Type::String && parser->get_format() != Format::Text &&
         value.encoding() == Encoding::UTF8) ||
        /* binary types must be converted to string in text formats */
        (type != Type::String && parser->get_format() == Format::Binary);

    if(no_conversion_needed) {
        parser->write(value, name_conv, this->out);

    } else {
        parser->write(this->conv_type(value), name_conv, this->out);
    }
}

// Assembly:
pushq %rbx
leaq 0x1c679(%rip), %rax     # 0x28860
movq %rax, 0x1c662(%rip)     # 0x28850
movl $0x6c6f6f42, 0x1c668(%rip) # imm = 0x6C6F6F42
movl $0x4, %eax
movq %rax, 0x1c654(%rip)     # 0x28858
xorl %ebx, %ebx
movb %bl, 0x1c658(%rip)      # 0x28864
leaq 0x1c66d(%rip), %rcx     # 0x28880
movq %rcx, 0x1c656(%rip)     # 0x28870
movw $0x3849, 0x1c65d(%rip)  # imm = 0x3849
movq $0x2, 0x1c64a(%rip) # 0x28878
movb %bl, 0x1c64e(%rip)      # 0x28882
leaq 0x1c665(%rip), %rcx     # 0x288a0
movq %rcx, 0x1c64e(%rip)     # 0x28890
movl $0x384955, 0x1c654(%rip) # imm = 0x384955
movl $0x3, %ecx
movq %rcx, 0x1c640(%rip)     # 0x28898
leaq 0x1c661(%rip), %rdx     # 0x288c0
movq %rdx, 0x1c64a(%rip)     # 0x288b0
movl $0x363149, 0x1c650(%rip) # imm = 0x363149
movq %rcx, 0x1c641(%rip)     # 0x288b8
leaq 0x1c662(%rip), %rdx     # 0x288e0
movq %rdx, 0x1c64b(%rip)     # 0x288d0
movl $0x36314955, 0x1c651(%rip) # imm = 0x36314955
movq %rax, 0x1c642(%rip)     # 0x288d8
movb %bl, 0x1c648(%rip)      # 0x288e4
leaq 0x1c65d(%rip), %rdx     # 0x28900
movq %rdx, 0x1c646(%rip)     # 0x288f0
movl $0x323349, 0x1c64c(%rip) # imm = 0x323349
movq %rcx, 0x1c63d(%rip)     # 0x288f8
leaq 0x1c65e(%rip), %rdx     # 0x28920
movq %rdx, 0x1c647(%rip)     # 0x28910
movl $0x32334955, 0x1c64d(%rip) # imm = 0x32334955
movq %rax, 0x1c63e(%rip)     # 0x28918
movb %bl, 0x1c644(%rip)      # 0x28924
leaq 0x1c659(%rip), %rdx     # 0x28940
movq %rdx, 0x1c642(%rip)     # 0x28930
movl $0x343649, 0x1c648(%rip) # imm = 0x343649
movq %rcx, 0x1c639(%rip)     # 0x28938
leaq 0x1c65a(%rip), %rcx     # 0x28960
movq %rcx, 0x1c643(%rip)     # 0x28950
movl $0x34364955, 0x1c649(%rip) # imm = 0x34364955
movq %rax, 0x1c63a(%rip)     # 0x28958
movb %bl, 0x1c640(%rip)      # 0x28964
leaq 0x1c655(%rip), %rcx     # 0x28980
movq %rcx, 0x1c63e(%rip)     # 0x28970
movl $0x32335046, 0x1c644(%rip) # imm = 0x32335046
movq %rax, 0x1c635(%rip)     # 0x28978
movb %bl, 0x1c63b(%rip)      # 0x28984
leaq 0x1c650(%rip), %rcx     # 0x289a0
movq %rcx, 0x1c639(%rip)     # 0x28990
movl $0x34365046, 0x1c63f(%rip) # imm = 0x34365046
movq %rax, 0x1c630(%rip)     # 0x28998
movb %bl, 0x1c636(%rip)      # 0x289a4
leaq 0x1c64b(%rip), %rcx     # 0x289c0
movq %rcx, 0x1c634(%rip)     # 0x289b0
movl $0x6c6c754e, 0x1c63a(%rip) # imm = 0x6C6C754E
movq %rax, 0x1c62b(%rip)     # 0x289b8
movb %bl, 0x1c631(%rip)      # 0x289c4
leaq 0x1c646(%rip), %rax     # 0x289e0
movq %rax, 0x1c62f(%rip)     # 0x289d0
movw $0x676e, 0x1c63a(%rip)  # imm = 0x676E
movl $0x69727453, 0x1c62c(%rip) # imm = 0x69727453
movl $0x6, %eax
movq %rax, 0x1c618(%rip)     # 0x289d8
movb %bl, 0x1c620(%rip)      # 0x289e6
leaq 0x1c633(%rip), %rcx     # 0x28a00
movq %rcx, 0x1c61c(%rip)     # 0x289f0
movw $0x7972, 0x1c627(%rip)  # imm = 0x7972
movl $0x616e6942, 0x1c619(%rip) # imm = 0x616E6942
movq %rax, 0x1c60a(%rip)     # 0x289f8
movb %bl, 0x1c612(%rip)      # 0x28a06
leaq 0x1c625(%rip), %rcx     # 0x28a20
movq %rcx, 0x1c60e(%rip)     # 0x28a10
movw $0x7463, 0x1c619(%rip)  # imm = 0x7463
movl $0x656a624f, 0x1c60b(%rip) # imm = 0x656A624F
movq %rax, 0x1c5fc(%rip)     # 0x28a18
movb %bl, 0x1c604(%rip)      # 0x28a26
leaq 0x1c617(%rip), %rax     # 0x28a40
movq %rax, 0x1c600(%rip)     # 0x28a30
movb $0x79, 0x1c60d(%rip)    # 0x28a44
movl $0x61727241, 0x1c5ff(%rip) # imm = 0x61727241
movq $0x5, 0x1c5ec(%rip) # 0x28a38
movb %bl, 0x1c5f3(%rip)      # 0x28a45
leaq 0x1c607(%rip), %rax     # 0x28a60
movq %rax, 0x1c5f0(%rip)     # 0x28a50
movabsq $0x6e455f65706f6353, %rax # imm = 0x6E455F65706F6353
movq %rax, 0x1c5ef(%rip)     # 0x28a60
movb $0x64, 0x1c5f0(%rip)    # 0x28a68
movq $0x9, 0x1c5d5(%rip) # 0x28a58
movb %bl, 0x1c5e0(%rip)      # 0x28a69
leaq -0x2f1(%rip), %rdi      # 0xc19f
leaq 0x1c391(%rip), %rdx     # 0x28828
xorl %esi, %esi
callq 0xb840
leaq 0x12bda(%rip), %rax     # 0x1f07f
movq %rax, 0x1c5c4(%rip)     # 0x28a70
movl $0x3, 0x1c5c2(%rip)     # 0x28a78
movw $0x10c, %ax             # imm = 0x10C
movw %ax, 0x1c5bb(%rip)      # 0x28a7c
movb %bl, 0x1c5b7(%rip)      # 0x28a7e
leaq 0x12b88(%rip), %rcx     # 0x1f056
movq %rcx, 0x1c5ab(%rip)     # 0x28a80
movl $0x5, %ecx
movl %ecx, 0x1c5a8(%rip)     # 0x28a88
movw %ax, 0x1c5a5(%rip)      # 0x28a8c
movb %bl, 0x1c5a1(%rip)      # 0x28a8e
leaq 0x12b7a(%rip), %rdx     # 0x1f06e
movq %rdx, 0x1c595(%rip)     # 0x28a90
movl %ecx, 0x1c597(%rip)     # 0x28a98
movw %ax, 0x1c594(%rip)      # 0x28a9c
movb %bl, 0x1c590(%rip)      # 0x28a9e
leaq 0x12b47(%rip), %rcx     # 0x1f05c
movq %rcx, 0x1c584(%rip)     # 0x28aa0
movl $0x6, 0x1c582(%rip)     # 0x28aa8
movw %ax, 0x1c57f(%rip)      # 0x28aac
movb %bl, 0x1c57b(%rip)      # 0x28aae
leaq 0x12b29(%rip), %rcx     # 0x1f063
movq %rcx, 0x1c56f(%rip)     # 0x28ab0
movl $0x10, 0x1c56d(%rip)    # 0x28ab8
movw %ax, 0x1c56a(%rip)      # 0x28abc
movb %bl, 0x1c566(%rip)      # 0x28abe
leaq 0x12b15(%rip), %rcx     # 0x1f074
movq %rcx, 0x1c55a(%rip)     # 0x28ac0
movl $0xe, 0x1c558(%rip)     # 0x28ac8
movw %ax, 0x1c555(%rip)      # 0x28acc
movb %bl, 0x1c551(%rip)      # 0x28ace
leaq 0x12aff(%rip), %rcx     # 0x1f083
movq %rcx, 0x1c545(%rip)     # 0x28ad0
movl $0xb, 0x1c543(%rip)     # 0x28ad8
movw %ax, 0x1c540(%rip)      # 0x28adc
movb %bl, 0x1c53c(%rip)      # 0x28ade
movq %rbx, 0x1c537(%rip)     # 0x28ae0
movl %ebx, 0x1c539(%rip)     # 0x28ae8
movw %ax, 0x1c536(%rip)      # 0x28aec
movb %bl, 0x1c532(%rip)      # 0x28aee
movq 0x1b97d(%rip), %rcx     # 0x27f40
movq %rbx, (%rcx)
movl %ebx, 0x8(%rcx)
movw %ax, 0xc(%rcx)
movb %bl, 0xe(%rcx)
xorl %edi, %edi
xorl %esi, %esi
callq 0xb580
movq %rax, 0x1c520(%rip)     # 0x28b00
popq %rbx
retq