// File: /workspace/github_cpp_makefile_star2_O2/hoehermann[P]TypedJNI/test.cpp
// Function: main
int main(int argc, char **argv)
{
    JavaVMInitArgs  vm_args;
    JavaVMOption jvmo;
    std::vector<JavaVMOption> options;
    //jvmo.optionString = const_cast<char*>("-verbose:gc"); options.push_back(jvmo);
    //jvmo.optionString = const_cast<char*>("-XX:+PrintGCTimeStamps"); options.push_back(jvmo);
    //jvmo.optionString = const_cast<char*>("-XX:+PrintGCDetails"); options.push_back(jvmo);
    vm_args.options = options.data();
    vm_args.nOptions = options.size();
    vm_args.version  = JNI_VERSION_1_8;
    TypedJNIEnv tenv(vm_args);
    TypedJNIClass javacls = tenv.find_class("TypedJNITest");
    javacls.GetStaticMethod<void()>("printHelloWorld");
    javacls.GetStaticMethod<void(jlong)>("printLong")(1);
    javacls.GetStaticMethod<void(jlong,jlong)>("print2Long")(1,2);
    {
        const long l = 1;
        std::cout << l << " incremented by Java is " << javacls.GetStaticMethod<jint(jint)>("increment")(l) << std::endl;
    }
    
    TypedJNIObject javaobj = javacls.GetConstructor<jstring>()(tenv.make_jstring("5"));
    {
        jint i = javaobj.GetMethod<jint(jint)>("incrementCounterBy")(2);
        std::cout << "After incrementing, counter is " << i << "." << std::endl;
    }
    javaobj.GetMethod<void(void)>("printCounter")();
    
    TypedJNIString s = tenv.make_jstring(std::string("Some words"));
    javaobj.GetMethod<void(jstring, jint)>("printInBackground")(s, 10);
    std::this_thread::sleep_for(std::chrono::seconds(5));

    return 0;
}

// Assembly:
pushq %rbx
subq $0x210, %rsp            # imm = 0x210
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
andq $0x0, 0xd0(%rsp)
movq $0x10008, 0xd8(%rsp) # imm = 0x10008
andq $0x0, 0xe0(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xd8(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x5f1a
leaq 0x3c2a(%rip), %rsi      # 0x7084
leaq 0x1d0(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x39f0
leaq 0xa8(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x607e
movq %rax, 0x60(%rsp)
movq %rdx, 0x68(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x30d0
leaq 0x3bf2(%rip), %rsi      # 0x7091
leaq 0x1b0(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x39f0
leaq 0x1f0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x1b0(%rsp), %rdx
callq 0x3a2c
leaq 0x1f0(%rsp), %rdi
callq 0x3c6e
leaq 0x1b0(%rsp), %rdi
callq 0x30d0
leaq 0x3bb5(%rip), %rsi      # 0x70a1
leaq 0x190(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x39f0
leaq 0x40(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x190(%rsp), %rdx
callq 0x3a48
leaq 0x40(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x3a64
leaq 0x40(%rsp), %rdi
callq 0x3c6e
leaq 0x190(%rsp), %rdi
callq 0x30d0
leaq 0x3b6b(%rip), %rsi      # 0x70ab
leaq 0x170(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x39f0
leaq 0x40(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x170(%rsp), %rdx
callq 0x3a7e
leaq 0x40(%rsp), %rdi
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
callq 0x3a9a
leaq 0x40(%rsp), %rdi
callq 0x3c6e
leaq 0x170(%rsp), %rdi
callq 0x30d0
movq 0x8a41(%rip), %rdi      # 0xbfd8
pushq $0x1
popq %rsi
callq 0x3180
leaq 0x3b10(%rip), %rsi      # 0x70b6
movq %rax, %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x3b17(%rip), %rsi      # 0x70cf
leaq 0x150(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x39f0
leaq 0x40(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x150(%rsp), %rdx
callq 0x3ac6
leaq 0x40(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x3b2a
movq %rbx, %rdi
movl %eax, %esi
callq 0x3280
movq %rax, %rdi
callq 0x30e0
leaq 0x40(%rsp), %rdi
callq 0x3c6e
leaq 0x150(%rsp), %rdi
callq 0x30d0
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x3b46
leaq 0x3aac(%rip), %rsi      # 0x70d9
leaq 0x70(%rsp), %rdi
leaq 0x1f(%rsp), %rdx
callq 0x39f0
leaq 0x90(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x613e
leaq 0x90(%rsp), %rdi
callq 0x5e80
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rax, %rdx
callq 0x3b5e
leaq 0x98(%rsp), %rdi
callq 0x3cce
leaq 0x70(%rsp), %rdi
callq 0x30d0
leaq 0x20(%rsp), %rdi
callq 0x3c6e
leaq 0x3a3e(%rip), %rsi      # 0x70db
leaq 0x130(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x39f0
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x130(%rsp), %rdx
callq 0x3b88
leaq 0x20(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x3b2a
movl %eax, %ebx
leaq 0x20(%rsp), %rdi
callq 0x3c6e
leaq 0x130(%rsp), %rdi
callq 0x30d0
movq 0x88e5(%rip), %rdi      # 0xbfd8
leaq 0x39f4(%rip), %rsi      # 0x70ee
callq 0x3190
movq %rax, %rdi
movl %ebx, %esi
callq 0x3280
leaq 0x3e7f(%rip), %rsi      # 0x758f
movq %rax, %rdi
callq 0x3190
movq %rax, %rdi
callq 0x30e0
leaq 0x39e7(%rip), %rsi      # 0x710e
leaq 0x110(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x39f0
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x110(%rsp), %rdx
callq 0x3bf2
leaq 0x20(%rsp), %rdi
callq 0x3c12
leaq 0x20(%rsp), %rdi
callq 0x3c6e
leaq 0x110(%rsp), %rdi
callq 0x30d0
leaq 0x39a3(%rip), %rsi      # 0x711b
leaq 0x20(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x39f0
leaq 0x70(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x613e
leaq 0x20(%rsp), %rdi
callq 0x30d0
leaq 0x3974(%rip), %rsi      # 0x7126
leaq 0xf0(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x39f0
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
callq 0x3c22
leaq 0x70(%rsp), %rdi
callq 0x5e80
leaq 0x20(%rsp), %rdi
pushq $0xa
popq %rdx
movq %rax, %rsi
callq 0x3c42
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x3c6e
leaq 0xf0(%rsp), %rdi
callq 0x30d0
movq $0x5, (%rbx)
leaq 0x20(%rsp), %rdi
callq 0x3c8a
leaq 0x78(%rsp), %rdi
callq 0x3cce
leaq 0x58(%rsp), %rdi
callq 0x3cce
leaq 0xa8(%rsp), %rdi
callq 0x603c
leaq 0xc0(%rsp), %rdi
callq 0x3d4a
xorl %eax, %eax
addq $0x210, %rsp            # imm = 0x210
popq %rbx
retq
jmp 0x3866
movq %rax, %rbx
jmp 0x3961
movq %rax, %rbx
jmp 0x396e
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x38b8
jmp 0x39c1
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3c6e
jmp 0x388f
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
jmp 0x38b8
jmp 0x39c1
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3c6e
jmp 0x38b0
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x30d0
jmp 0x39c4
jmp 0x39c1
movq %rax, %rbx
jmp 0x398a
movq %rax, %rbx
jmp 0x3994
jmp 0x39a0
movq %rax, %rbx
jmp 0x39b2
jmp 0x39a0
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3c6e
jmp 0x38fb
movq %rax, %rbx
leaq 0x170(%rsp), %rdi
jmp 0x39ba
jmp 0x39a0
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3c6e
jmp 0x391f
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
jmp 0x39ba
jmp 0x39a0
movq %rax, %rbx
leaq 0x1b0(%rsp), %rdi
jmp 0x39ba
jmp 0x39a0
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
jmp 0x39ba
jmp 0x39a0
movq %rax, %rbx
jmp 0x39db
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3c6e
leaq 0xf0(%rsp), %rdi
callq 0x30d0
leaq 0x78(%rsp), %rdi
callq 0x3cce
jmp 0x39c4
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x3cce
leaq 0x70(%rsp), %rdi
callq 0x30d0
leaq 0x20(%rsp), %rdi
callq 0x3c6e
jmp 0x39ce
movq %rax, %rbx
jmp 0x39ce
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3c6e
leaq 0x150(%rsp), %rdi
callq 0x30d0
jmp 0x39ce
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x3cce
leaq 0xa8(%rsp), %rdi
callq 0x603c
leaq 0xc0(%rsp), %rdi
callq 0x3d4a
movq %rbx, %rdi
callq 0x3290