// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: VmExtractMemObj
static jx9_value * VmExtractMemObj(
	jx9_vm *pVm,           /* Target VM */
	const SyString *pName, /* Variable name */
	int bDup,              /* True to duplicate variable name */
	int bCreate            /* True to create the variable if non-existent */
	)
{
	int bNullify = FALSE;
	SyHashEntry *pEntry;
	VmFrame *pFrame;
	jx9_value *pObj;
	sxu32 nIdx;
	sxi32 rc;
	/* Point to the top active frame */
	pFrame = pVm->pFrame;
	/* Perform the lookup */
	if( pName == 0 || pName->nByte < 1 ){
		static const SyString sAnnon = { " " , sizeof(char) };
		pName = &sAnnon;
		/* Always nullify the object */
		bNullify = TRUE;
		bDup = FALSE;
	}
	/* Check the superglobals table first */
	pEntry = SyHashGet(&pVm->hSuper, (const void *)pName->zString, pName->nByte);
	if( pEntry == 0 ){
		/* Query the top active frame */
		pEntry = SyHashGet(&pFrame->hVar, (const void *)pName->zString, pName->nByte);
		if( pEntry == 0 ){
			char *zName = (char *)pName->zString;
			VmSlot sLocal;
			if( !bCreate ){
				/* Do not create the variable, return NULL */
				return 0;
			}
			/* No such variable, automatically create a new one and install
			 * it in the current frame.
			 */
			pObj = jx9VmReserveMemObj(&(*pVm),&nIdx);
			if( pObj == 0 ){
				return 0;
			}
			if( bDup ){
				/* Duplicate name */
				zName = SyMemBackendStrDup(&pVm->sAllocator, pName->zString, pName->nByte);
				if( zName == 0 ){
					return 0;
				}
			}
			/* Link to the top active VM frame */
			rc = SyHashInsert(&pFrame->hVar, zName, pName->nByte, SX_INT_TO_PTR(nIdx));
			if( rc != SXRET_OK ){
				/* Return the slot to the free pool */
				sLocal.nIdx = nIdx;
				sLocal.pUserData = 0;
				SySetPut(&pVm->aFreeObj, (const void *)&sLocal);
				return 0;
			}
			if( pFrame->pParent != 0 ){
				/* Local variable */
				sLocal.nIdx = nIdx;
				SySetPut(&pFrame->sLocal, (const void *)&sLocal);
			}
		}else{
			/* Extract variable contents */
			nIdx = (sxu32)SX_PTR_TO_INT(pEntry->pUserData);
			pObj = (jx9_value *)SySetAt(&pVm->aMemObj, nIdx);
			if( bNullify && pObj ){
				jx9MemObjRelease(pObj);
			}
		}
	}else{
		/* Superglobal */
		nIdx = (sxu32)SX_PTR_TO_INT(pEntry->pUserData);
		pObj = (jx9_value *)SySetAt(&pVm->aMemObj, nIdx);
	}
	return pObj;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %r15d
movq %rdi, %rbx
testq %rsi, %rsi
je 0x43c97
movl %edx, %r13d
movq %rsi, %r14
movl 0x8(%rsi), %edx
testl %edx, %edx
je 0x43c97
movl $0x0, -0x38(%rbp)
jmp 0x43cab
leaq 0x4d662(%rip), %r14     # 0x91300
movb $0x1, %al
movl %eax, -0x38(%rbp)
xorl %r13d, %r13d
movl $0x1, %edx
movq 0xf8(%rbx), %r12
cmpl $0x0, 0x370(%rbx)
je 0x43cf8
leaq 0x348(%rbx), %rdi
movq (%r14), %rsi
callq 0x448fa
testq %rax, %rax
je 0x43cf4
movl 0x10(%rax), %r15d
cmpl %r15d, 0x218(%rbx)
jbe 0x43dd4
imull 0x220(%rbx), %r15d
addq 0x210(%rbx), %r15
jmp 0x43dd7
movl 0x8(%r14), %edx
leaq 0x40(%r12), %rax
movq %rax, -0x40(%rbp)
testl %edx, %edx
je 0x43d5f
cmpl $0x0, 0x68(%r12)
je 0x43d5f
movq (%r14), %rsi
movq -0x40(%rbp), %rdi
callq 0x448fa
testq %rax, %rax
je 0x43d5f
movl 0x10(%rax), %r15d
cmpl %r15d, 0x218(%rbx)
jbe 0x43dd4
movq 0x210(%rbx), %rax
imull 0x220(%rbx), %r15d
addq %rax, %r15
testq %rax, %rax
setne %al
movl -0x38(%rbp), %ecx
andb %al, %cl
cmpb $0x1, %cl
jne 0x43dd7
movq %r15, %rdi
callq 0x30465
jmp 0x43dd7
testl %r15d, %r15d
je 0x43dd4
movq (%r14), %rax
movq %rax, -0x38(%rbp)
leaq -0x2c(%rbp), %rsi
movq %rbx, %rdi
callq 0x3f956
testq %rax, %rax
je 0x43dd4
movq %rax, %r15
testl %r13d, %r13d
je 0x43d9c
movq (%r14), %rsi
movl 0x8(%r14), %edx
movq %rbx, %rdi
callq 0x3da5b
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x43dd4
movl 0x8(%r14), %edx
movl -0x2c(%rbp), %ecx
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x445f4
testl %eax, %eax
je 0x43de9
movl -0x2c(%rbp), %eax
leaq -0x50(%rbp), %rsi
movl %eax, (%rsi)
movq $0x0, 0x8(%rsi)
addq $0x260, %rbx            # imm = 0x260
movq %rbx, %rdi
callq 0x33094
xorl %r15d, %r15d
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, (%r12)
je 0x43dd7
movl -0x2c(%rbp), %eax
leaq -0x50(%rbp), %rsi
movl %eax, (%rsi)
addq $0x10, %r12
movq %r12, %rdi
callq 0x33094
jmp 0x43dd7