// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: ProcessScript
static sxi32 ProcessScript(
	jx9 *pEngine,          /* Running JX9 engine */
	jx9_vm **ppVm,         /* OUT: A pointer to the virtual machine */
	SyString *pScript,     /* Raw JX9 script to compile */
	sxi32 iFlags,          /* Compile-time flags */
	const char *zFilePath  /* File path if script come from a file. NULL otherwise */
	)
{
	jx9_vm *pVm;
	int rc;
	/* Allocate a new virtual machine */
	pVm = (jx9_vm *)SyMemBackendPoolAlloc(&pEngine->sAllocator, sizeof(jx9_vm));
	if( pVm == 0 ){
		/* If the supplied memory subsystem is so sick that we are unable to allocate
		 * a tiny chunk of memory, there is no much we can do here. */
		if( ppVm ){
			*ppVm = 0;
		}
		return JX9_NOMEM;
	}
	if( iFlags < 0 ){
		/* Default compile-time flags */
		iFlags = 0;
	}
	/* Initialize the Virtual Machine */
	rc = jx9VmInit(pVm, &(*pEngine));
	if( rc != JX9_OK ){
		SyMemBackendPoolFree(&pEngine->sAllocator, pVm);
		if( ppVm ){
			*ppVm = 0;
		}
		return JX9_VM_ERR;
	}
	if( zFilePath ){
		/* Push processed file path */
		jx9VmPushFilePath(pVm, zFilePath, -1, TRUE, 0);
	}
	/* Reset the error message consumer */
	SyBlobReset(&pEngine->xConf.sErrConsumer);
	/* Compile the script */
	jx9CompileScript(pVm, &(*pScript), iFlags);
	if( pVm->sCodeGen.nErr > 0 || pVm == 0){
		sxu32 nErr = pVm->sCodeGen.nErr;
		/* Compilation error or null ppVm pointer, release this VM */
		SyMemBackendRelease(&pVm->sAllocator);
		SyMemBackendPoolFree(&pEngine->sAllocator, pVm);
		if( ppVm ){
			*ppVm = 0;
		}
		return nErr > 0 ? JX9_COMPILE_ERR : JX9_OK;
	}
	/* Prepare the virtual machine for bytecode execution */
	rc = jx9VmMakeReady(pVm);
	if( rc != JX9_OK ){
		goto Release;
	}
	/* Install local import path which is the current directory */
	jx9_vm_config(pVm, JX9_VM_CONFIG_IMPORT_PATH, "./");
#if defined(JX9_ENABLE_THREADS)
	if( sJx9MPGlobal.nThreadingLevel > JX9_THREAD_LEVEL_SINGLE ){
		 /* Associate a recursive mutex with this instance */
		 pVm->pMutex = SyMutexNew(sJx9MPGlobal.pMutexMethods, SXMUTEX_TYPE_RECURSIVE);
		 if( pVm->pMutex == 0 ){
			 goto Release;
		 }
	 }
#endif
	/* Script successfully compiled, link to the list of active virtual machines */
	MACRO_LD_PUSH(pEngine->pVms, pVm);
	pEngine->iVm++;
	/* Point to the freshly created VM */
	*ppVm = pVm;
	/* Ready to execute JX9 bytecode */
	return JX9_OK;
Release:
	SyMemBackendRelease(&pVm->sAllocator);
	SyMemBackendPoolFree(&pEngine->sAllocator, pVm);
	*ppVm = 0;
	return JX9_VM_ERR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl $0x6f0, %esi            # imm = 0x6F0
callq 0x541f0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x7da72
cmpq $0x0, -0x18(%rbp)
je 0x7da66
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7dc7a
cmpl $0x0, -0x24(%rbp)
jge 0x7da7f
movl $0x0, -0x24(%rbp)
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x7dc90
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x7dac0
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x54490
cmpq $0x0, -0x18(%rbp)
je 0x7dab4
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movl $0xffffffb9, -0x4(%rbp) # imm = 0xFFFFFFB9
jmp 0x7dc7a
cmpq $0x0, -0x30(%rbp)
je 0x7dae3
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
xorl %eax, %eax
movl %eax, %r8d
callq 0x7e030
movq -0x10(%rbp), %rdi
addq $0xc0, %rdi
addq $0x10, %rdi
callq 0x65e00
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0x7e120
movq -0x38(%rbp), %rax
cmpl $0x0, 0x6d0(%rax)
ja 0x7db1b
cmpq $0x0, -0x38(%rbp)
jne 0x7db68
movq -0x38(%rbp), %rax
movl 0x6d0(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x543e0
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x54490
cmpq $0x0, -0x18(%rbp)
je 0x7db50
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movl -0x40(%rbp), %edx
xorl %eax, %eax
movl $0xffffffba, %ecx       # imm = 0xFFFFFFBA
cmpl $0x0, %edx
cmoval %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x7dc7a
movq -0x38(%rbp), %rdi
callq 0x7e200
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x7db7f
jmp 0x7dc52
movq -0x38(%rbp), %rdi
movl $0x2, %esi
leaq 0x452f2(%rip), %rdx     # 0xc2e81
movb $0x0, %al
callq 0x7ba50
cmpl $0x1, 0x7190b(%rip)     # 0xef4a8
jbe 0x7dbd1
movq 0x718f2(%rip), %rax     # 0xef498
movl $0x2, %edi
callq *0x10(%rax)
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0xb8(%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, 0xb8(%rax)
jne 0x7dbcf
jmp 0x7dc52
jmp 0x7dbd1
movq -0x10(%rbp), %rax
cmpq $0x0, 0xf8(%rax)
jne 0x7dbf0
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xf8(%rax)
jmp 0x7dc2b
movq -0x10(%rbp), %rax
movq 0xf8(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x6d8(%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0xf8(%rax), %rax
movq %rcx, 0x6e0(%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xf8(%rax)
movq -0x10(%rbp), %rax
movl 0x100(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x100(%rax)
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x7dc7a
movq -0x38(%rbp), %rdi
callq 0x543e0
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x54490
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movl $0xffffffb9, -0x4(%rbp) # imm = 0xFFFFFFB9
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)