// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0xf8(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x76cdd
movq -0x18(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jae 0x76cf6
leaq 0x7481c(%rip), %rax     # 0xeb500
movq %rax, -0x18(%rbp)
movl $0x1, -0x24(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x348, %rdi            # imm = 0x348
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x76c30
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x76e7b
movq -0x38(%rbp), %rdi
addq $0x40, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x76c30
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x76e3f
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x76d6b
movq $0x0, -0x8(%rbp)
jmp 0x76ea5
movq -0x10(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x70a20
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x76d90
movq $0x0, -0x8(%rbp)
jmp 0x76ea5
cmpl $0x0, -0x1c(%rbp)
je 0x76dc7
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x6da40
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x76dc5
movq $0x0, -0x8(%rbp)
jmp 0x76ea5
jmp 0x76dc7
movq -0x38(%rbp), %rdi
addq $0x40, %rdi
movq -0x50(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
movl -0x44(%rbp), %eax
movl %eax, %ecx
callq 0x77a80
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x76e1c
movl -0x44(%rbp), %eax
movl %eax, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x10(%rbp), %rdi
addq $0x260, %rdi            # imm = 0x260
leaq -0x60(%rbp), %rsi
callq 0x5a7b0
movq $0x0, -0x8(%rbp)
jmp 0x76ea5
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
je 0x76e3d
movl -0x44(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x38(%rbp), %rdi
addq $0x10, %rdi
leaq -0x60(%rbp), %rsi
callq 0x5a7b0
jmp 0x76e79
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movl -0x44(%rbp), %esi
callq 0x6ea60
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x76e77
cmpq $0x0, -0x40(%rbp)
je 0x76e77
movq -0x40(%rbp), %rdi
callq 0x56ab0
jmp 0x76e79
jmp 0x76e9d
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movl -0x44(%rbp), %esi
callq 0x6ea60
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nop