// File: /workspace/github_c_makefile_star2_O1/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, -0x38(%rbp)
movq %rdi, %rbx
testq %rsi, %rsi
je 0x44ac7
movq %rsi, %r15
cmpl $0x0, 0x8(%rsi)
je 0x44ac7
movl %edx, %r12d
xorl %r13d, %r13d
jmp 0x44ad4
leaq 0x4e832(%rip), %r15     # 0x93300
movb $0x1, %r13b
xorl %r12d, %r12d
movq 0xf8(%rbx), %r14
movl 0x8(%r15), %edx
xorl %eax, %eax
testl %edx, %edx
je 0x44afd
cmpl $0x0, 0x370(%rbx)
je 0x44afd
leaq 0x348(%rbx), %rdi
movq (%r15), %rsi
callq 0x4573a
testq %rax, %rax
je 0x44b2b
movl 0x10(%rax), %r14d
movl %r14d, -0x2c(%rbp)
cmpl %r14d, 0x218(%rbx)
jbe 0x44beb
imull 0x220(%rbx), %r14d
addq 0x210(%rbx), %r14
jmp 0x44c2c
movl %r12d, -0x3c(%rbp)
leaq 0x40(%r14), %r12
movl 0x8(%r15), %edx
xorl %eax, %eax
testl %edx, %edx
je 0x44b4f
cmpl $0x0, 0x68(%r14)
je 0x44b4f
movq (%r15), %rsi
movq %r12, %rdi
callq 0x4573a
testq %rax, %rax
je 0x44b7a
movl 0x10(%rax), %r14d
movl %r14d, -0x2c(%rbp)
cmpl %r14d, 0x218(%rbx)
jbe 0x44bf0
imull 0x220(%rbx), %r14d
addq 0x210(%rbx), %r14
jmp 0x44bf3
cmpl $0x0, -0x38(%rbp)
je 0x44beb
movq %r12, %r13
movq %r14, -0x38(%rbp)
movq (%r15), %r12
leaq -0x2c(%rbp), %rsi
movq %rbx, %rdi
callq 0x40355
testq %rax, %rax
je 0x44beb
movq %rax, %r14
cmpl $0x0, -0x3c(%rbp)
je 0x44bbb
movq (%r15), %rsi
movl 0x8(%r15), %edx
movq %rbx, %rdi
callq 0x3e425
movq %rax, %r12
testq %rax, %rax
je 0x44beb
movl 0x8(%r15), %edx
movl -0x2c(%rbp), %ecx
movq %r13, %rdi
movq %r12, %rsi
callq 0x4542b
testl %eax, %eax
je 0x44c0c
movl -0x2c(%rbp), %eax
movl %eax, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
addq $0x260, %rbx            # imm = 0x260
xorl %r14d, %r14d
jmp 0x44c20
xorl %r14d, %r14d
jmp 0x44c2c
xorl %r14d, %r14d
testq %r14, %r14
setne %al
andb %al, %r13b
cmpb $0x1, %r13b
jne 0x44c2c
movq %r14, %rdi
callq 0x309f2
jmp 0x44c2c
movq -0x38(%rbp), %rbx
cmpq $0x0, (%rbx)
je 0x44c2c
movl -0x2c(%rbp), %eax
movl %eax, -0x50(%rbp)
addq $0x10, %rbx
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x336fc
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq