// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9VmCallUserFunction
JX9_PRIVATE sxi32 jx9VmCallUserFunction(
	jx9_vm *pVm,       /* Target VM */
	jx9_value *pFunc,  /* Callback name */
	int nArg,          /* Total number of given arguments */
	jx9_value **apArg, /* Callback arguments */
	jx9_value *pResult /* Store callback return value here. NULL otherwise */
	)
{
	jx9_value *aStack;
	VmInstr aInstr[2];
	int i;
	if((pFunc->iFlags & (MEMOBJ_STRING)) == 0 ){
		/* Don't bother processing, it's invalid anyway */
		if( pResult ){
			/* Assume a null return value */
			jx9MemObjRelease(pResult);
		}
		return SXERR_INVALID;
	}
	/* Create a new operand stack */
	aStack = VmNewOperandStack(&(*pVm), 1+nArg);
	if( aStack == 0 ){
		jx9VmThrowError(&(*pVm), 0, JX9_CTX_ERR, 
			"JX9 is running out of memory while invoking user callback");
		if( pResult ){
			/* Assume a null return value */
			jx9MemObjRelease(pResult);
		}
		return SXERR_MEM;
	}
	/* Fill the operand stack with the given arguments */
	for( i = 0 ; i < nArg ; i++ ){
		jx9MemObjLoad(apArg[i], &aStack[i]);
		aStack[i].nIdx = apArg[i]->nIdx;
	}
	/* Push the function name */
	jx9MemObjLoad(pFunc, &aStack[i]);
	aStack[i].nIdx = SXU32_HIGH; /* Mark as constant */
	/* Emit the CALL istruction */
	aInstr[0].iOp = JX9_OP_CALL;
	aInstr[0].iP1 = nArg; /* Total number of given arguments */
	aInstr[0].iP2 = 0;
	aInstr[0].p3  = 0;
	/* Emit the DONE instruction */
	aInstr[1].iOp = JX9_OP_DONE;
	aInstr[1].iP1 = 1;   /* Extract function return value if available */
	aInstr[1].iP2 = 0;
	aInstr[1].p3  = 0;
	/* Execute the function body (if available) */
	VmByteCodeExec(&(*pVm), aInstr, aStack, nArg, pResult);
	/* Clean up the mess left behind */
	SyMemBackendFree(&pVm->sAllocator, aStack);
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x72879
cmpq $0x0, -0x30(%rbp)
je 0x7286d
movq -0x30(%rbp), %rdi
callq 0x56ab0
movl $0xfffffff7, -0x4(%rbp) # imm = 0xFFFFFFF7
jmp 0x729b0
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
addl $0x1, %esi
callq 0x72b20
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x728c8
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
leaq 0x4fd45(%rip), %rcx     # 0xc25ec
callq 0x72ba0
cmpq $0x0, -0x30(%rbp)
je 0x728bc
movq -0x30(%rbp), %rdi
callq 0x56ab0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x729b0
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x72923
movq -0x28(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x38(%rbp), %rsi
movslq -0x74(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rsi
callq 0x72d20
movq -0x28(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x38(%rax), %ecx
movq -0x38(%rbp), %rax
movslq -0x74(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movl %ecx, 0x38(%rax)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x728cf
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
movslq -0x74(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rsi
callq 0x72d20
movq -0x38(%rbp), %rax
movslq -0x74(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x38(%rax) # imm = 0xFFFFFFFF
movb $0x10, -0x70(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl $0x0, -0x68(%rbp)
movq $0x0, -0x60(%rbp)
movb $0x1, -0x58(%rbp)
movl $0x1, -0x54(%rbp)
movl $0x0, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq -0x30(%rbp), %r8
callq 0x72db0
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5d6b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)