// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9VmRegisterConstant
JX9_PRIVATE sxi32 jx9VmRegisterConstant(
	jx9_vm *pVm,            /* Target VM */
	const SyString *pName,  /* Constant name */
	ProcConstant xExpand,   /* Constant expansion callback */
	void *pUserData         /* Last argument to xExpand() */
	)
{
	jx9_constant *pCons;
	SyHashEntry *pEntry;
	char *zDupName;
	sxi32 rc;
	pEntry = SyHashGet(&pVm->hConstant, (const void *)pName->zString, pName->nByte);
	if( pEntry ){
		/* Overwrite the old definition and return immediately */
		pCons = (jx9_constant *)pEntry->pUserData;
		pCons->xExpand = xExpand;
		pCons->pUserData = pUserData;
		return SXRET_OK;
	}
	/* Allocate a new constant instance */
	pCons = (jx9_constant *)SyMemBackendPoolAlloc(&pVm->sAllocator, sizeof(jx9_constant));
	if( pCons == 0 ){
		return 0;
	}
	/* Duplicate constant name */
	zDupName = SyMemBackendStrDup(&pVm->sAllocator, pName->zString, pName->nByte);
	if( zDupName == 0 ){
		SyMemBackendPoolFree(&pVm->sAllocator, pCons);
		return 0;
	}
	/* Install the constant */
	SyStringInitFromBuf(&pCons->sName, zDupName, pName->nByte);
	pCons->xExpand = xExpand;
	pCons->pUserData = pUserData;
	rc = SyHashInsert(&pVm->hConstant, (const void *)zDupName, SyStringLength(&pCons->sName), pCons);
	if( rc != SXRET_OK ){
		SyMemBackendFree(&pVm->sAllocator, zDupName);
		SyMemBackendPoolFree(&pVm->sAllocator, pCons);
		return rc;
	}
	/* All done, constant can be invoked from JX9 code */
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rdi
addq $0x288, %rdi            # imm = 0x288
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x76c30
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x56491
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x56573
movq -0x10(%rbp), %rdi
movl $0x20, %esi
callq 0x541f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x564b6
movl $0x0, -0x4(%rbp)
jmp 0x56573
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x6da40
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x564f1
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x54490
movl $0x0, -0x4(%rbp)
jmp 0x56573
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rdi
addq $0x288, %rdi            # imm = 0x288
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x30(%rbp), %rcx
callq 0x77a80
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x5656c
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x5d6b0
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x54490
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x56573
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)