// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movl %ecx, %r14d
movq %rdi, %rbx
testq %rsi, %rsi
je 0x3ae53
movl %edx, %r13d
movq %rsi, %r15
movl 0x8(%rsi), %edx
testl %edx, %edx
je 0x3ae53
movl $0x0, -0x38(%rbp)
jmp 0x3ae65
leaq 0x494b6(%rip), %r15     # 0x84310
movb $0x1, %al
movl %eax, -0x38(%rbp)
xorl %r13d, %r13d
pushq $0x1
popq %rdx
movq 0xf8(%rbx), %r12
leaq 0x348(%rbx), %rdi
movq (%r15), %rsi
callq 0x3ae09
testq %rax, %rax
je 0x3aea5
movl 0x10(%rax), %r14d
cmpl %r14d, 0x218(%rbx)
jbe 0x3af78
imull 0x220(%rbx), %r14d
addq 0x210(%rbx), %r14
jmp 0x3af7b
movl %r14d, -0x3c(%rbp)
leaq 0x40(%r12), %r14
movq (%r15), %rsi
movl 0x8(%r15), %edx
movq %r14, %rdi
callq 0x3ae09
testq %rax, %rax
je 0x3af03
movl 0x10(%rax), %r14d
cmpl %r14d, 0x218(%rbx)
jbe 0x3af78
movq 0x210(%rbx), %rax
imull 0x220(%rbx), %r14d
addq %rax, %r14
testq %rax, %rax
setne %al
movl -0x38(%rbp), %ecx
andb %al, %cl
cmpb $0x1, %cl
jne 0x3af7b
movq %r14, %rdi
callq 0x296af
jmp 0x3af7b
movq %r14, -0x38(%rbp)
movq %r12, -0x48(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x3af78
movq (%r15), %r12
leaq -0x2c(%rbp), %rsi
movq %rbx, %rdi
callq 0x37337
testq %rax, %rax
je 0x3af78
movq %rax, %r14
testl %r13d, %r13d
je 0x3af44
movq (%r15), %rsi
movl 0x8(%r15), %edx
movq %rbx, %rdi
callq 0x35732
movq %rax, %r12
testq %rax, %rax
je 0x3af78
movl 0x8(%r15), %edx
movl -0x2c(%rbp), %ecx
movq -0x38(%rbp), %rdi
movq %r12, %rsi
callq 0x3b67d
testl %eax, %eax
je 0x3af8d
movl -0x2c(%rbp), %eax
leaq -0x58(%rbp), %rsi
movl %eax, (%rsi)
andq $0x0, 0x8(%rsi)
addq $0x260, %rbx            # imm = 0x260
movq %rbx, %rdi
callq 0x2be00
xorl %r14d, %r14d
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x48(%rbp), %rdi
cmpq $0x0, (%rdi)
je 0x3af7b
movl -0x2c(%rbp), %eax
leaq -0x58(%rbp), %rsi
movl %eax, (%rsi)
addq $0x10, %rdi
callq 0x2be00
jmp 0x3af7b