// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
xorl %r12d, %r12d
movb %r12b, 0x10(%rdi)
movl $0x20, %edi
callq 0x31a0
movl %r12d, 0x8(%rax)
movq $0x10ffff, 0x10(%rax)   # imm = 0x10FFFF
movl %r12d, 0x18(%rax)
leaq 0x5f58(%rip), %rcx      # 0xcd38
movq %rcx, (%rax)
leaq 0x100(%rsp), %rcx
movq %rax, -0x18(%rcx)
movq %rcx, -0x10(%rcx)
movq %r12, -0x8(%rcx)
movb %r12b, (%rcx)
leaq 0x120(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r12, -0x8(%rax)
movw %r12w, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movw %r12w, 0x20(%rax)
movq (%r15), %rdx
movq 0x8(%r15), %rcx
addq %rdx, %rcx
leaq 0x48(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x7c84
movq 0x50(%rsp), %rdx
testq $-0x80000000, %rdx      # imm = 0x80000000
jne 0x6ee7
movq 0x48(%rsp), %rsi
movq (%r14), %rax
movq %r14, %rdi
callq *0x518(%rax)
movq %rax, %r12
testq %rax, %rax
je 0x6f60
movl $0x28, %edi
callq 0x31a0
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x5e3c(%rip), %rcx      # 0xccc0
movq %rcx, (%rax)
movq %rbx, 0x10(%rax)
movq %r14, 0x18(%rax)
movq %r12, 0x20(%rax)
movq %r12, (%rbx)
movq 0x8(%rbx), %rdi
movq %rax, 0x8(%rbx)
testq %rdi, %rdi
je 0x6ea8
callq 0x3f78
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6ec8
movq 0x58(%rsp), %rax
leaq 0x2(,%rax,2), %rsi
callq 0x31b0
leaq 0xe8(%rsp), %rdi
callq 0x7b1c
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x30e0
movq %rax, %r14
movq 0x50(%rsp), %rsi
leaq 0x88(%rsp), %rdi
callq 0x79ea
leaq 0x26ab(%rip), %rsi      # 0x95b8
leaq 0xc8(%rsp), %rdi
leaq 0x88(%rsp), %rdx
callq 0x797a
leaq 0x26a8(%rip), %rsi      # 0x95d1
leaq 0xc8(%rsp), %rdi
callq 0x32a0
leaq 0x78(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x7010
movups (%rcx), %xmm0
movups %xmm0, (%r12)
jmp 0x701d
movl $0x10, %edi
callq 0x30e0
movq %rax, %r14
leaq 0x266f(%rip), %rsi      # 0x95e3
leaq 0x28(%rsp), %rdi
movq %r15, %rdx
callq 0x784a
leaq 0x267f(%rip), %rsi      # 0x9607
leaq 0x28(%rsp), %rdi
callq 0x32a0
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x6fb5
movups (%rcx), %xmm0
movups %xmm0, (%r12)
jmp 0x6fc2
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rax), %rdx
leaq 0x8(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
movq %r14, %rdi
callq 0x31f0
leaq 0x5c10(%rip), %rax      # 0xcc00
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x5c1c(%rip), %rsi      # 0xcc18
movq 0x5fc5(%rip), %rdx      # 0xcfc8
movq %r14, %rdi
callq 0x3260
jmp 0x70e7
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x70(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xa8(%rsp), %rdi
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
callq 0x7a7a
leaq 0x28(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x78d2
leaq 0x25a3(%rip), %rsi      # 0x9608
leaq 0x28(%rsp), %rdi
callq 0x32a0
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x7091
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x709e
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rax), %rdx
leaq 0x8(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
movq %r14, %rdi
callq 0x31f0
leaq 0x5b34(%rip), %rax      # 0xcc00
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x5b40(%rip), %rsi      # 0xcc18
movq 0x5ee9(%rip), %rdx      # 0xcfc8
movq %r14, %rdi
callq 0x3260
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7109
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x31b0
jmp 0x7109
movq %rax, %r15
movb $0x1, %bpl
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x712c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x31b0
jmp 0x712c
movq %rax, %r15
movb $0x1, %bpl
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7155
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x31b0
jmp 0x7155
movq %rax, %r15
movb $0x1, %bpl
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x7174
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x31b0
jmp 0x7174
movq %rax, %r15
movb $0x1, %bpl
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7195
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x31b0
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x71e5
movq 0x98(%rsp), %rsi
jmp 0x71dd
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x71ca
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x31b0
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x71e5
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x31b0
testb %bpl, %bpl
jne 0x7232
jmp 0x7273
movq %rax, %r15
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7232
movq 0x38(%rsp), %rsi
jmp 0x7223
movq %rax, %r15
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7232
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x31b0
jmp 0x7232
jmp 0x722f
movq %rax, %r15
movq %r14, %rdi
callq 0x3120
jmp 0x7273
movq %rax, %rdi
callq 0x30c0
cmpb $0x0, 0x10(%rbx)
jne 0x7259
movq (%r14), %rax
movq %r14, %rdi
movq %r12, %rsi
callq *0xb8(%rax)
callq 0x3210
movq %rax, %r15
callq 0x3250
jmp 0x7273
movq %rax, %rdi
callq 0x3f6d
movq %rax, %r15
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7298
movq 0x58(%rsp), %rax
leaq 0x2(,%rax,2), %rsi
callq 0x31b0
jmp 0x7298
movq %rax, %r15
leaq 0xe8(%rsp), %rdi
callq 0x7b1c
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x72b3
callq 0x3f78
movq %r15, %rdi
callq 0x3280
nop