// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9CompileStatic
static sxi32 jx9CompileStatic(jx9_gen_state *pGen)
{
	jx9_vm_func_static_var sStatic; /* Structure describing the static variable */
	jx9_vm_func *pFunc;             /* Enclosing function */
	GenBlock *pBlock;
	SyString *pName;
	char *zDup;
	sxu32 nLine;
	sxi32 rc;
	/* Jump the static keyword */
	nLine = pGen->pIn->nLine;
	pGen->pIn++;
	/* Extract the enclosing function if any */
	pBlock = pGen->pCurrent;
	while( pBlock ){
		if( pBlock->iFlags & GEN_BLOCK_FUNC){
			break;
		}
		/* Point to the upper block */
		pBlock = pBlock->pParent;
	}
	if( pBlock == 0 ){
		/* Static statement, called outside of a function body, treat it as a simple variable. */
		if( pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & JX9_TK_DOLLAR) == 0 ){
			rc = jx9GenCompileError(&(*pGen), E_ERROR, nLine, "Expected variable after 'static' keyword");
			if( rc == SXERR_ABORT ){
				return SXERR_ABORT;
			}
			goto Synchronize;
		}
		/* Compile the expression holding the variable */
		rc = jx9CompileExpr(&(*pGen), 0, 0);
		if( rc == SXERR_ABORT ){
			return SXERR_ABORT;
		}else if( rc != SXERR_EMPTY ){
			/* Emit the POP instruction */
			jx9VmEmitInstr(pGen->pVm, JX9_OP_POP, 1, 0, 0, 0);
		}
		return SXRET_OK;
	}
	pFunc = (jx9_vm_func *)pBlock->pUserData;
	/* Make sure we are dealing with a valid statement */
	if( pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & JX9_TK_DOLLAR) == 0 || &pGen->pIn[1] >= pGen->pEnd ||
		(pGen->pIn[1].nType & (JX9_TK_ID|JX9_TK_KEYWORD)) == 0 ){
			rc = jx9GenCompileError(&(*pGen), E_ERROR, nLine, "Expected variable after 'static' keyword");
			if( rc == SXERR_ABORT ){
				return SXERR_ABORT;
			}
			goto Synchronize;
	}
	pGen->pIn++;
	/* Extract variable name */
	pName = &pGen->pIn->sData;
	pGen->pIn++; /* Jump the var name */
	if( pGen->pIn < pGen->pEnd && (pGen->pIn->nType & (JX9_TK_SEMI/*';'*/|JX9_TK_EQUAL/*'='*/)) == 0 ){
		rc = jx9GenCompileError(&(*pGen), E_ERROR, pGen->pIn->nLine, "static: Unexpected token '%z'", &pGen->pIn->sData);
		goto Synchronize;
	}
	/* Initialize the structure describing the static variable */
	SySetInit(&sStatic.aByteCode, &pGen->pVm->sAllocator, sizeof(VmInstr));
	sStatic.nIdx = SXU32_HIGH; /* Not yet created */
	/* Duplicate variable name */
	zDup = SyMemBackendStrDup(&pGen->pVm->sAllocator, pName->zString, pName->nByte);
	if( zDup == 0 ){
		jx9GenCompileError(&(*pGen), E_ERROR, nLine, "Fatal, JX9 engine is running out of memory");
		return SXERR_ABORT;
	}
	SyStringInitFromBuf(&sStatic.sName, zDup, pName->nByte);
	/* Check if we have an expression to compile */
	if( pGen->pIn < pGen->pEnd && (pGen->pIn->nType & JX9_TK_EQUAL) ){
		SySet *pInstrContainer;
		pGen->pIn++; /* Jump the equal '=' sign */
		/* Swap bytecode container */
		pInstrContainer = jx9VmGetByteCodeContainer(pGen->pVm);
		jx9VmSetByteCodeContainer(pGen->pVm, &sStatic.aByteCode);
		/* Compile the expression */
		rc = jx9CompileExpr(&(*pGen), 0, 0);
		/* Emit the done instruction */
		jx9VmEmitInstr(pGen->pVm, JX9_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
		/* Restore default bytecode container */
		jx9VmSetByteCodeContainer(pGen->pVm, pInstrContainer);
	}
	/* Finally save the compiled static variable in the appropriate container */
	SySetPut(&pFunc->aStatic, (const void *)&sStatic);
	return SXRET_OK;
Synchronize:
	/* Synchronize with the first semi-colon ';', so we can 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 $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x14(%rax), %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x837bb
movq -0x60(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x837ad
jmp 0x837bb
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x83795
cmpq $0x0, -0x60(%rbp)
jne 0x83880
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x160(%rcx), %rax
jae 0x837f4
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x83828
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %edx
movl $0x1, %esi
leaq 0x40921(%rip), %rcx     # 0xc4128
movb $0x0, %al
callq 0x7e990
movl %eax, -0x78(%rbp)
cmpl $-0xa, -0x78(%rbp)
jne 0x83823
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x83b85
jmp 0x83b19
movq -0x10(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x81110
movl %eax, -0x78(%rbp)
cmpl $-0xa, -0x78(%rbp)
jne 0x8384c
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x83b85
cmpl $-0x3, -0x78(%rbp)
je 0x83872
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0xb, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
callq 0x7e8f0
jmp 0x83874
movl $0x0, -0x4(%rbp)
jmp 0x83b85
movq -0x60(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x160(%rcx), %rax
jae 0x838ec
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x838ec
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
addq $0x20, %rax
movq -0x10(%rbp), %rcx
cmpq 0x160(%rcx), %rax
jae 0x838ec
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x30(%rax), %eax
andl $0xc, %eax
cmpl $0x0, %eax
jne 0x83920
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %edx
movl $0x1, %esi
leaq 0x40829(%rip), %rcx     # 0xc4128
movb $0x0, %al
callq 0x7e990
movl %eax, -0x78(%rbp)
cmpl $-0xa, -0x78(%rbp)
jne 0x8391b
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x83b85
jmp 0x83b19
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq %rax, -0x68(%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 0x839c3
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x440000, %eax         # imm = 0x440000
cmpl $0x0, %eax
jne 0x839c3
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x14(%rax), %edx
movq -0x10(%rbp), %rax
movq 0x158(%rax), %r8
movl $0x1, %esi
leaq 0x4079d(%rip), %rcx     # 0xc4151
movb $0x0, %al
callq 0x7e990
movl %eax, -0x78(%rbp)
jmp 0x83b19
leaq -0x50(%rbp), %rdi
addq $0x10, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movl $0x18, %edx
callq 0x5b470
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x68(%rbp), %rax
movq (%rax), %rsi
movq -0x68(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x6da40
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x83a2e
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %edx
movl $0x1, %esi
leaq 0x40754(%rip), %rcx     # 0xc416f
movb $0x0, %al
callq 0x7e990
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x83b85
movq -0x70(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x68(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x160(%rcx), %rax
jae 0x83aff
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x400000, %eax         # imm = 0x400000
cmpl $0x0, %eax
je 0x83aff
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x85050
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x50(%rbp), %rsi
addq $0x10, %rsi
callq 0x85070
movq -0x10(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x81110
movl %eax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl -0x78(%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 -0x80(%rbp), %rsi
callq 0x85070
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
leaq -0x50(%rbp), %rsi
callq 0x5a7b0
movl $0x0, -0x4(%rbp)
jmp 0x83b85
jmp 0x83b1b
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpq 0x160(%rdx), %rcx
movb %al, -0x81(%rbp)
jae 0x83b5a
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x40000, %eax          # imm = 0x40000
cmpl $0x0, %eax
sete %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x83b66
jmp 0x83b7e
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
jmp 0x83b1b
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)