// File: /workspace/github_c_makefile_star2_O0/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
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x14(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x160(%rcx), %rax
jae 0x83e63
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x600c, %eax           # imm = 0x600C
cmpl $0x0, %eax
jne 0x83e97
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %edx
movl $0x1, %esi
leaq 0x4035f(%rip), %rcx     # 0xc41d5
movb $0x0, %al
callq 0x7e990
movl %eax, -0x34(%rbp)
cmpl $-0xa, -0x34(%rbp)
jne 0x83e92
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x840f5
jmp 0x84092
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x857d0
cmpl $0x0, %eax
je 0x83eec
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %edx
movq -0x30(%rbp), %r8
movl $0x1, %esi
leaq 0x40327(%rip), %rcx     # 0xc41f2
movb $0x0, %al
callq 0x7e990
movl %eax, -0x34(%rbp)
cmpl $-0xa, -0x34(%rbp)
jne 0x83ee7
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x840f5
jmp 0x84092
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x160(%rcx), %rax
jae 0x83f32
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x400000, %eax         # imm = 0x400000
cmpl $0x0, %eax
jne 0x83f66
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %edx
movl $0x1, %esi
leaq 0x402de(%rip), %rcx     # 0xc4223
movb $0x0, %al
callq 0x7e990
movl %eax, -0x34(%rbp)
cmpl $-0xa, -0x34(%rbp)
jne 0x83f61
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x840f5
jmp 0x84092
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x28, %esi
callq 0x541f0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x83fa9
movq -0x10(%rbp), %rdi
callq 0x84570
movl %eax, -0x4(%rbp)
jmp 0x840f5
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movl $0x18, %edx
callq 0x5b470
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x85050
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x85070
movq -0x10(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x81110
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl -0x34(%rbp), %ecx
xorl %edx, %edx
movl $0x1, %eax
cmpl $-0x3, %ecx
cmovnel %eax, %edx
movl $0x1, %esi
xorl %ecx, %ecx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
callq 0x7e8f0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x85070
cmpl $-0xa, -0x34(%rbp)
jne 0x8403d
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x840f5
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x18(%rbp), %rcx
leaq 0x181e(%rip), %rdx      # 0x85880
callq 0x56420
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x84089
movq -0x18(%rbp), %rdi
callq 0x66980
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x54490
movl $0x0, -0x4(%rbp)
jmp 0x840f5
jmp 0x84094
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpq 0x160(%rdx), %rcx
movb %al, -0x35(%rbp)
jae 0x840cd
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x40000, %eax          # imm = 0x40000
cmpl $0x0, %eax
sete %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0x840d6
jmp 0x840ee
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
jmp 0x84094
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop