// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9CompileConstant
static sxi32 jx9CompileConstant(jx9_gen_state *pGen)
{
	SySet *pConsCode, *pInstrContainer;
	sxu32 nLine = pGen->pIn->nLine;
	SyString *pName;
	sxi32 rc;
	pGen->pIn++; /* Jump the 'const' keyword */
	if( pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & (JX9_TK_SSTR|JX9_TK_DSTR|JX9_TK_ID|JX9_TK_KEYWORD)) == 0 ){
		/* Invalid constant name */
		rc = jx9GenCompileError(pGen, E_ERROR, nLine, "const: Invalid constant name");
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
		goto Synchronize;
	}
	/* Peek constant name */
	pName = &pGen->pIn->sData;
	/* Make sure the constant name isn't reserved */
	if( GenStateIsReservedID(pName) ){
		/* Reserved constant */
		rc = jx9GenCompileError(pGen, E_ERROR, nLine, "const: Cannot redeclare a reserved constant '%z'", pName);
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
		goto Synchronize;
	}
	pGen->pIn++;
	if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & JX9_TK_EQUAL /* '=' */) == 0 ){
		/* Invalid statement*/
		rc = jx9GenCompileError(pGen, E_ERROR, nLine, "const: Expected '=' after constant name");
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
		goto Synchronize;
	}
	pGen->pIn++; /*Jump the equal sign */
	/* Allocate a new constant value container */
	pConsCode = (SySet *)SyMemBackendPoolAlloc(&pGen->pVm->sAllocator, sizeof(SySet));
	if( pConsCode == 0 ){
		return GenStateOutOfMem(pGen);
	}
	SySetInit(pConsCode, &pGen->pVm->sAllocator, sizeof(VmInstr));
	/* Swap bytecode container */
	pInstrContainer = jx9VmGetByteCodeContainer(pGen->pVm);
	jx9VmSetByteCodeContainer(pGen->pVm, pConsCode);
	/* Compile constant value */
	rc = jx9CompileExpr(&(*pGen), 0, 0);
	/* Emit the done instruction */
	jx9VmEmitInstr(pGen->pVm, JX9_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
	jx9VmSetByteCodeContainer(pGen->pVm, pInstrContainer); 
	if( rc == SXERR_ABORT ){
		/* Don't worry about freeing memory, everything will be released shortly */
		return SXERR_ABORT;
	}
	SySetSetUserData(pConsCode, pGen->pVm);
	/* Register the constant */
	rc = jx9VmRegisterConstant(pGen->pVm, pName, jx9VmExpandConstantValue, pConsCode);
	if( rc != SXRET_OK ){
		SySetRelease(pConsCode);
		SyMemBackendPoolFree(&pGen->pVm->sAllocator, pConsCode);
	}
	return SXRET_OK;
Synchronize:
	/* Synchronize with the next-semi-colon and avoid compiling this erroneous statement */
	while(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & JX9_TK_SEMI) == 0 ){
		pGen->pIn++;
	}
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x158(%rdi), %r13
movq 0x160(%rdi), %r12
movl 0x14(%r13), %r15d
leaq 0x20(%r13), %r14
movq %r14, 0x158(%rdi)
cmpq %r12, %r14
jae 0x4bc33
movzwl 0x30(%r13), %eax
testl $0x600c, %eax           # imm = 0x600C
je 0x4bc33
movl 0x28(%r13), %eax
cmpl $0x5, %eax
je 0x4bc99
cmpl $0x4, %eax
jne 0x4bcb1
movq (%r14), %rdi
leaq 0x2aed4(%rip), %rsi     # 0x76adf
movq %rdi, -0x30(%rbp)
movl $0x4, %edx
callq 0x39f3f
testl %eax, %eax
je 0x4bcd4
leaq 0x2604c(%rip), %rsi     # 0x71c74
movq -0x30(%rbp), %rdi
movl $0x4, %edx
jmp 0x4bca8
leaq 0x2a0ba(%rip), %rcx     # 0x75cf4
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x483d1
movl %eax, %ecx
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
cmpl $-0xa, %ecx
je 0x4bc8a
movq 0x158(%rbx), %rdx
movq 0x160(%rbx), %rcx
xorl %eax, %eax
cmpq %rcx, %rdx
jae 0x4bc8a
addq $0x20, %rdx
testb $0x4, -0xe(%rdx)
jne 0x4bc8a
movq %rdx, 0x158(%rbx)
leaq 0x20(%rdx), %rsi
cmpq %rcx, %rdx
movq %rsi, %rdx
jb 0x4bc71
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
leaq 0x25fd6(%rip), %rsi     # 0x71c79
movl $0x5, %edx
callq 0x39f3f
testl %eax, %eax
je 0x4bcd4
leaq 0x40(%r13), %rax
movq %rax, 0x158(%rbx)
cmpq %r12, %rax
jae 0x4bcc8
testb $0x40, 0x52(%r13)
jne 0x4bcf5
leaq 0x2a073(%rip), %rcx     # 0x75d42
jmp 0x4bc3a
leaq 0x2a036(%rip), %rcx     # 0x75d11
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
movq %r14, %r8
xorl %eax, %eax
callq 0x483d1
jmp 0x4bc4c
addq $0x60, %r13
movq %r13, 0x158(%rbx)
movq (%rbx), %rdi
movl $0x28, %esi
callq 0x2e481
testq %rax, %rax
je 0x4bdd4
movq %rax, %r15
movq (%rbx), %rax
movabsq $0x1800000000, %rcx     # imm = 0x1800000000
movq %rcx, 0x14(%r15)
xorl %ecx, %ecx
movl %ecx, 0x10(%r15)
movl %ecx, 0x1c(%r15)
movq %rax, (%r15)
movq %rcx, 0x8(%r15)
movq %rcx, 0x20(%r15)
movq 0xf0(%rax), %r13
movq %r15, 0xf0(%rax)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x49789
movl %eax, %r12d
movq (%rbx), %rdi
xorl %edx, %edx
cmpl $-0x3, %eax
setne %dl
movl $0x1, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x48365
movq (%rbx), %rdi
leaq 0xc8(%rdi), %rax
testq %r13, %r13
cmovneq %r13, %rax
movq %rax, 0xf0(%rdi)
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
cmpl $-0xa, %r12d
je 0x4bc8a
movq %rdi, 0x20(%r15)
leaq 0xcf9(%rip), %rdx       # 0x4caa4
movq %r14, %rsi
movq %r15, %rcx
callq 0x2ffd7
testl %eax, %eax
je 0x4bdcd
movq %r15, %rdi
callq 0x399c8
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x2e659
xorl %eax, %eax
jmp 0x4bc8a
leaq 0x2997e(%rip), %rcx     # 0x75759
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x483d1
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
jmp 0x4bc8a