// File: /workspace/github_cpp_makefile_star2_O2/hoehermann[P]TypedJNI/typedjni.cpp
// Function: TypedJNIString::TypedJNIString(JNIEnv_*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
TypedJNIString::TypedJNIString(JNIEnv *env, const std::string & str) {
    std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert; 
    std::u16string u16string = convert.from_bytes(str);
    if (u16string.size() > static_cast<size_t>(std::numeric_limits<jint>::max())) {
        throw TypedJNIError("Converted string length "+std::to_string(u16string.size())+" exceeds maximum "+std::to_string(std::numeric_limits<jint>::max())+".");
    }
    static_assert(sizeof(jchar) == sizeof(char16_t), "jchar is not as long as char16_t");
    jstring jstr = env->NewString(reinterpret_cast<const jchar*>(u16string.c_str()), static_cast<jint>(u16string.size()));
    if (jstr == NULL) {
        throw TypedJNIError("NewString failed for UTF-8 string '"+str+"'.");
    }
    jstrptr = std::shared_ptr<_jstring>(jstr, [this, env](jstring s){ 
        if (!persistent) { 
            env->DeleteLocalRef(s);
        }
    });
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x140, %rsp            # imm = 0x140
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movb $0x0, 0x10(%rdi)
leaq 0xe0(%rsp), %rdi
callq 0x62fe
leaq 0x40(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
movq %r15, %rdx
callq 0x6358
movq 0x48(%rsp), %rdx
testq $-0x80000000, %rdx      # imm = 0x80000000
jne 0x5c66
movq 0x40(%rsp), %rsi
movq (%r14), %rax
movq %r14, %rdi
callq *0x518(%rax)
movq %rax, %r12
testq %rax, %rax
je 0x5d1d
movq %r12, (%rsp)
andq $0x0, 0x8(%rsp)
pushq $0x28
popq %rdi
callq 0x31a0
leaq 0x8(%rsp), %r15
leaq 0x60(%rsp), %rcx
leaq 0x20(%rsp), %rdi
movq %rcx, (%rdi)
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x60a0(%rip), %rcx      # 0xbcb0
movq %rcx, (%rax)
movq %rbx, 0x10(%rax)
movq %r14, 0x18(%rax)
movq %r12, 0x20(%rax)
movq %rax, (%r15)
andq $0x0, 0x8(%rdi)
callq 0x61d4
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x6bf0
movq %r15, %rdi
callq 0x3cce
leaq 0x40(%rsp), %rdi
callq 0x640e
leaq 0xe0(%rsp), %rdi
callq 0x641e
addq $0x140, %rsp            # imm = 0x140
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x30f0
movq %rax, %r14
movq 0x48(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x6373
leaq 0x18b5(%rip), %rsi      # 0x753f
leaq 0xc0(%rsp), %rdi
leaq 0xa0(%rsp), %rdx
callq 0x4006
leaq 0x18b2(%rip), %rdx      # 0x7558
leaq 0x60(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x3fe7
leaq 0x80(%rsp), %rdi
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
callq 0x63b5
movq %rsp, %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x3f80
leaq 0x18a9(%rip), %rdx      # 0x758f
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x3fe7
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x57b0
xorl %ebp, %ebp
leaq 0x5eec(%rip), %rsi      # 0xbbf8
movq 0x62b5(%rip), %rdx      # 0xbfc8
movq %r14, %rdi
callq 0x3270
jmp 0x5d76
pushq $0x10
popq %rdi
callq 0x30f0
movq %rax, %r14
leaq 0x183b(%rip), %rsi      # 0x756a
movq %rsp, %rdi
movq %r15, %rdx
callq 0x6288
leaq 0x184d(%rip), %rdx      # 0x758e
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x3fe7
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x57b0
xorl %ebp, %ebp
leaq 0x5e91(%rip), %rsi      # 0xbbf8
movq 0x625a(%rip), %rdx      # 0xbfc8
movq %r14, %rdi
callq 0x3270
movq %rax, %r15
leaq 0x20(%rsp), %rdi
callq 0x30d0
jmp 0x5d8b
movq %rax, %r15
movb $0x1, %bpl
movq %rsp, %rdi
callq 0x30d0
jmp 0x5d9b
movq %rax, %r15
movb $0x1, %bpl
leaq 0x80(%rsp), %rdi
callq 0x30d0
jmp 0x5db0
movq %rax, %r15
movb $0x1, %bpl
leaq 0x60(%rsp), %rdi
callq 0x30d0
jmp 0x5dc2
movq %rax, %r15
movb $0x1, %bpl
leaq 0xc0(%rsp), %rdi
callq 0x30d0
jmp 0x5df1
movq %rax, %r15
leaq 0x20(%rsp), %rdi
callq 0x30d0
jmp 0x5de6
movq %rax, %r15
movb $0x1, %bpl
movq %rsp, %rdi
jmp 0x5df9
movq %rax, %r15
movb $0x1, %bpl
leaq 0xa0(%rsp), %rdi
callq 0x30d0
testb %bpl, %bpl
jne 0x5e0a
jmp 0x5e4b
jmp 0x5e07
movq %rax, %r15
movq %r14, %rdi
callq 0x3120
jmp 0x5e4b
movq %rax, %rdi
callq 0x30b0
cmpb $0x0, 0x10(%rbx)
jne 0x5e31
movq (%r14), %rax
movq %r14, %rdi
movq %r12, %rsi
callq *0xb8(%rax)
callq 0x3210
movq %rax, %r15
callq 0x3260
jmp 0x5e4b
movq %rax, %rdi
callq 0x3cc2
movq %rax, %r15
leaq 0x40(%rsp), %rdi
callq 0x640e
jmp 0x5e5a
movq %rax, %r15
leaq 0xe0(%rsp), %rdi
callq 0x641e
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x3cce
movq %r15, %rdi
callq 0x3290
movq %rax, %r15
jmp 0x5e67