// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9CompileFor
static sxi32 jx9CompileFor(jx9_gen_state *pGen)
{
	SyToken *pTmp, *pPostStart, *pEnd = 0;
	GenBlock *pForBlock = 0;
	sxu32 nFalseJump;
	sxu32 nLine;
	sxi32 rc;
	nLine = pGen->pIn->nLine;
	/* Jump the 'for' keyword */
	pGen->pIn++;    
	if( pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & JX9_TK_LPAREN) == 0 ){
		/* Syntax error */
		rc = jx9GenCompileError(pGen, E_ERROR, nLine, "Expected '(' after 'for' keyword");
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
		return SXRET_OK;
	}
	/* Jump the left parenthesis '(' */
	pGen->pIn++; 
	/* Delimit the init-expr;condition;post-expr */
	jx9DelimitNestedTokens(pGen->pIn, pGen->pEnd, JX9_TK_LPAREN /* '(' */, JX9_TK_RPAREN /* ')' */, &pEnd);
	if( pGen->pIn == pEnd || pEnd >= pGen->pEnd ){
		/* Empty expression */
		rc = jx9GenCompileError(pGen, E_ERROR, nLine, "for: Invalid expression");
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
		/* Synchronize */
		pGen->pIn = pEnd;
		if( pGen->pIn < pGen->pEnd ){
			pGen->pIn++;
		}
		return SXRET_OK;
	}
	/* Swap token streams */
	pTmp = pGen->pEnd;
	pGen->pEnd = pEnd;
	/* Compile initialization expressions if available */
	rc = jx9CompileExpr(&(*pGen), 0, 0);
	/* Pop operand lvalues */
	if( rc == SXERR_ABORT ){
		/* Expression handler request an operation abort [i.e: Out-of-memory] */
		return SXERR_ABORT;
	}else if( rc != SXERR_EMPTY ){
		jx9VmEmitInstr(pGen->pVm, JX9_OP_POP, 1, 0, 0, 0);
	}
	if( (pGen->pIn->nType & JX9_TK_SEMI) == 0 ){
		/* Syntax error */
		rc = jx9GenCompileError(pGen, E_ERROR, pGen->pIn->nLine, 
			"for: Expected ';' after initialization expressions");
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
		return SXRET_OK;
	}
	/* Jump the trailing ';' */
	pGen->pIn++;
	/* Create the loop block */
	rc = GenStateEnterBlock(&(*pGen), GEN_BLOCK_LOOP, jx9VmInstrLength(pGen->pVm), 0, &pForBlock);
	if( rc != SXRET_OK ){
		return SXERR_ABORT;
	}
	/* Deffer continue jumps */
	pForBlock->bPostContinue = TRUE;
	/* Compile the condition */
	rc = jx9CompileExpr(&(*pGen), 0, 0);
	if( rc == SXERR_ABORT ){
		/* Expression handler request an operation abort [i.e: Out-of-memory] */
		return SXERR_ABORT;
	}else if( rc != SXERR_EMPTY ){
		/* Emit the false jump */
		jx9VmEmitInstr(pGen->pVm, JX9_OP_JZ, 0, 0, 0, &nFalseJump);
		/* Save the instruction index so we can fix it later when the jump destination is resolved */
		GenStateNewJumpFixup(pForBlock, JX9_OP_JZ, nFalseJump);
	}
	if( (pGen->pIn->nType & JX9_TK_SEMI) == 0 ){
		/* Syntax error */
		rc = jx9GenCompileError(pGen, E_ERROR, pGen->pIn->nLine, 
			"for: Expected ';' after conditionals expressions");
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
		return SXRET_OK;
	}
	/* Jump the trailing ';' */
	pGen->pIn++;
	/* Save the post condition stream */
	pPostStart = pGen->pIn;
	/* Compile the loop body */
	pGen->pIn  = &pEnd[1]; /* Jump the trailing parenthesis ')' */
	pGen->pEnd = pTmp;
	rc = jx9CompileBlock(&(*pGen));
	if( rc == SXERR_ABORT ){
		return SXERR_ABORT;
	}
	/* Fix post-continue jumps */
	if( SySetUsed(&pForBlock->aPostContFix) > 0 ){
		JumpFixup *aPost;
		VmInstr *pInstr;
		sxu32 nJumpDest;
		sxu32 n;
		aPost = (JumpFixup *)SySetBasePtr(&pForBlock->aPostContFix);
		nJumpDest = jx9VmInstrLength(pGen->pVm);
		for( n = 0 ; n < SySetUsed(&pForBlock->aPostContFix) ; ++n ){
			pInstr = jx9VmGetInstr(pGen->pVm, aPost[n].nInstrIdx);
			if( pInstr ){
				/* Fix jump */
				pInstr->iP2 = nJumpDest;
			}
		}
	}
	/* compile the post-expressions if available */
	while( pPostStart < pEnd && (pPostStart->nType & JX9_TK_SEMI) ){
		pPostStart++;
	}
	if( pPostStart < pEnd ){
		SyToken *pTmpIn, *pTmpEnd;
		SWAP_DELIMITER(pGen, pPostStart, pEnd);
		rc = jx9CompileExpr(&(*pGen), 0, 0);
		if( pGen->pIn < pGen->pEnd ){
			/* Syntax error */
			rc = jx9GenCompileError(pGen, E_ERROR, pGen->pIn->nLine, "for: Expected ')' after post-expressions");
			if( rc == SXERR_ABORT ){
				/* Error count limit reached, abort immediately */
				return SXERR_ABORT;
			}
			return SXRET_OK;
		}
		RE_SWAP_DELIMITER(pGen);
		if( rc == SXERR_ABORT ){
			/* Expression handler request an operation abort [i.e: Out-of-memory] */
			return SXERR_ABORT;
		}else if( rc != SXERR_EMPTY){
			/* Pop operand lvalue */
			jx9VmEmitInstr(pGen->pVm, JX9_OP_POP, 1, 0, 0, 0);
		}
	}
	/* Emit the unconditional jump to the start of the loop */
	jx9VmEmitInstr(pGen->pVm, JX9_OP_JMP, 0, pForBlock->nFirstInstr, 0, 0);
	/* Fix all jumps now the destination is resolved */
	GenStateFixJumps(pForBlock, -1, jx9VmInstrLength(pGen->pVm));
	/* Release the loop block */
	GenStateLeaveBlock(pGen, 0);
	/* Statement successfully compiled */
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x14(%rax), %eax
movl %eax, -0x38(%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 0x82646
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
jne 0x82681
movq -0x10(%rbp), %rdi
movl -0x38(%rbp), %edx
movl $0x1, %esi
leaq 0x4187e(%rip), %rcx     # 0xc3ed7
movb $0x0, %al
callq 0x7e990
movl %eax, -0x3c(%rbp)
cmpl $-0xa, -0x3c(%rbp)
jne 0x82675
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x82bbd
movl $0x0, -0x4(%rbp)
jmp 0x82bbd
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x160(%rax), %rsi
movl $0x200, %edx            # imm = 0x200
movl $0x400, %ecx            # imm = 0x400
leaq -0x28(%rbp), %r8
callq 0x841b0
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
cmpq -0x28(%rbp), %rax
je 0x826e2
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x160(%rcx), %rax
jb 0x8275a
movq -0x10(%rbp), %rdi
movl -0x38(%rbp), %edx
movl $0x1, %esi
leaq 0x41803(%rip), %rcx     # 0xc3ef8
movb $0x0, %al
callq 0x7e990
movl %eax, -0x3c(%rbp)
cmpl $-0xa, -0x3c(%rbp)
jne 0x82711
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x82bbd
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x158(%rax)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x160(%rcx), %rax
jae 0x8274e
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x82bbd
movq -0x10(%rbp), %rax
movq 0x160(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x160(%rax)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x81110
movl %eax, -0x3c(%rbp)
cmpl $-0xa, -0x3c(%rbp)
jne 0x8279c
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x82bbd
cmpl $-0x3, -0x3c(%rbp)
je 0x827c2
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 0x827c4
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x40000, %eax          # imm = 0x40000
cmpl $0x0, %eax
jne 0x82822
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x14(%rax), %edx
movl $0x1, %esi
leaq 0x41716(%rip), %rcx     # 0xc3f10
movb $0x0, %al
callq 0x7e990
movl %eax, -0x3c(%rbp)
cmpl $-0xa, -0x3c(%rbp)
jne 0x82816
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x82bbd
movl $0x0, -0x4(%rbp)
jmp 0x82bbd
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7e8d0
movq -0x70(%rbp), %rdi
movl %eax, %edx
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x30(%rbp), %r8
callq 0x84100
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x82879
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x82bbd
movq -0x30(%rbp), %rax
movb $0x1, 0x48(%rax)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x81110
movl %eax, -0x3c(%rbp)
cmpl $-0xa, -0x3c(%rbp)
jne 0x828a5
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x82bbd
cmpl $-0x3, -0x3c(%rbp)
je 0x828da
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x9, %esi
xorl %ecx, %ecx
xorl %eax, %eax
movl %eax, %r8d
leaq -0x34(%rbp), %r9
movl %ecx, %edx
callq 0x7e8f0
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %edx
movl $0x9, %esi
callq 0x84240
jmp 0x828dc
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x40000, %eax          # imm = 0x40000
cmpl $0x0, %eax
jne 0x8293a
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x14(%rax), %edx
movl $0x1, %esi
leaq 0x41631(%rip), %rcx     # 0xc3f43
movb $0x0, %al
callq 0x7e990
movl %eax, -0x3c(%rbp)
cmpl $-0xa, -0x3c(%rbp)
jne 0x8292e
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x82bbd
movl $0x0, -0x4(%rbp)
jmp 0x82bbd
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, -0x20(%rbp)
movq -0x28(%rbp), %rcx
addq $0x20, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x158(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x160(%rax)
movq -0x10(%rbp), %rdi
callq 0x84280
movl %eax, -0x3c(%rbp)
cmpl $-0xa, -0x3c(%rbp)
jne 0x8299f
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x82bbd
movq -0x30(%rbp), %rax
cmpl $0x0, 0x60(%rax)
jbe 0x82a12
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7e8d0
movl %eax, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x60(%rcx), %eax
jae 0x82a10
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rax
movl -0x58(%rbp), %ecx
movl 0x4(%rax,%rcx,8), %esi
callq 0x845a0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x82a03
movl -0x54(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x8(%rax)
jmp 0x82a05
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x829cb
jmp 0x82a12
jmp 0x82a14
movq -0x20(%rbp), %rcx
xorl %eax, %eax
cmpq -0x28(%rbp), %rcx
movb %al, -0x71(%rbp)
jae 0x82a38
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x40000, %eax          # imm = 0x40000
cmpl $0x0, %eax
setne %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %al
testb $0x1, %al
jne 0x82a41
jmp 0x82a4f
movq -0x20(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x20(%rbp)
jmp 0x82a14
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x82b63
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x160(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x158(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x160(%rax)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x81110
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x160(%rcx), %rax
jae 0x82b09
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x14(%rax), %edx
movl $0x1, %esi
leaq 0x41493(%rip), %rcx     # 0xc3f74
movb $0x0, %al
callq 0x7e990
movl %eax, -0x3c(%rbp)
cmpl $-0xa, -0x3c(%rbp)
jne 0x82afd
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x82bbd
movl $0x0, -0x4(%rbp)
jmp 0x82bbd
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x158(%rax)
movq -0x68(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x160(%rax)
cmpl $-0xa, -0x3c(%rbp)
jne 0x82b39
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x82bbd
cmpl $-0x3, -0x3c(%rbp)
je 0x82b5f
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 0x82b61
jmp 0x82b63
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movl 0x10(%rax), %ecx
movl $0x8, %esi
xorl %edx, %edx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
callq 0x7e8f0
movq -0x30(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7e8d0
movq -0x80(%rbp), %rdi
movl %eax, %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x84440
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x84500
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)