// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9CompileWhile
static sxi32 jx9CompileWhile(jx9_gen_state *pGen)
{ 
	GenBlock *pWhileBlock = 0;
	SyToken *pTmp, *pEnd = 0;
	sxu32 nFalseJump;
	sxu32 nLine;
	sxi32 rc;
	nLine = pGen->pIn->nLine;
	/* Jump the 'while' 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 'while' keyword");
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
		goto Synchronize;
	}
	/* Jump the left parenthesis '(' */
	pGen->pIn++; 
	/* Create the loop block */
	rc = GenStateEnterBlock(&(*pGen), GEN_BLOCK_LOOP, jx9VmInstrLength(pGen->pVm), 0, &pWhileBlock);
	if( rc != SXRET_OK ){
		return SXERR_ABORT;
	}
	/* Delimit the condition */
	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, "Expected expression after 'while' keyword");
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
	}
	/* Swap token streams */
	pTmp = pGen->pEnd;
	pGen->pEnd = pEnd;
	/* Compile the expression */
	rc = jx9CompileExpr(&(*pGen), 0, 0);
	if( rc == SXERR_ABORT ){
		/* Expression handler request an operation abort [i.e: Out-of-memory] */
		return SXERR_ABORT;
	}
	/* Update token stream */
	while(pGen->pIn < pEnd ){
		rc = jx9GenCompileError(&(*pGen), E_ERROR, pGen->pIn->nLine, "Unexpected token '%z'", &pGen->pIn->sData);
		if( rc == SXERR_ABORT ){
			return SXERR_ABORT;
		}
		pGen->pIn++;
	}
	/* Synchronize pointers */
	pGen->pIn  = &pEnd[1];
	pGen->pEnd = pTmp;
	/* 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(pWhileBlock, JX9_OP_JZ, nFalseJump);
	/* Compile the loop body */
	rc = jx9CompileBlock(&(*pGen));
	if( rc == SXERR_ABORT ){
		return SXERR_ABORT;
	}
	/* Emit the unconditional jump to the start of the loop */
	jx9VmEmitInstr(pGen->pVm, JX9_OP_JMP, 0, pWhileBlock->nFirstInstr, 0, 0);
	/* Fix all jumps now the destination is resolved */
	GenStateFixJumps(pWhileBlock, -1, jx9VmInstrLength(pGen->pVm));
	/* Release the loop block */
	GenStateLeaveBlock(pGen, 0);
	/* Statement successfully compiled */
	return SXRET_OK;
Synchronize:
	/* Synchronize with the first semi-colon ';' so we can avoid 
	 * compiling this erroneous block.
	 */
	while( pGen->pIn < pGen->pEnd && (pGen->pIn->nType & (JX9_TK_SEMI|JX9_TK_OCB)) == 0 ){
		pGen->pIn++;
	}
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x14(%rax), %eax
movl %eax, -0x30(%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 0x822d3
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
jne 0x82307
movq -0x10(%rbp), %rdi
movl -0x30(%rbp), %edx
movl $0x1, %esi
leaq 0x41ba4(%rip), %rcx     # 0xc3e8a
movb $0x0, %al
callq 0x7e990
movl %eax, -0x34(%rbp)
cmpl $-0xa, -0x34(%rbp)
jne 0x82302
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x825ba
jmp 0x82557
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7e8d0
movq -0x40(%rbp), %rdi
movl %eax, %edx
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x18(%rbp), %r8
callq 0x84100
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x8235e
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x825ba
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 0x823a9
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x160(%rcx), %rax
jb 0x823da
movq -0x10(%rbp), %rdi
movl -0x30(%rbp), %edx
movl $0x1, %esi
leaq 0x41af1(%rip), %rcx     # 0xc3ead
movb $0x0, %al
callq 0x7e990
movl %eax, -0x34(%rbp)
cmpl $-0xa, -0x34(%rbp)
jne 0x823d8
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x825ba
jmp 0x823da
movq -0x10(%rbp), %rax
movq 0x160(%rax), %rax
movq %rax, -0x20(%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, -0x34(%rbp)
cmpl $-0xa, -0x34(%rbp)
jne 0x8241c
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x825ba
jmp 0x8241e
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
cmpq -0x28(%rbp), %rax
jae 0x8248c
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 0x41d01(%rip), %rcx     # 0xc4159
movb $0x0, %al
callq 0x7e990
movl %eax, -0x34(%rbp)
cmpl $-0xa, -0x34(%rbp)
jne 0x82474
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x825ba
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
jmp 0x8241e
movq -0x28(%rbp), %rcx
addq $0x20, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x158(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x160(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x9, %esi
xorl %ecx, %ecx
xorl %eax, %eax
movl %eax, %r8d
leaq -0x2c(%rbp), %r9
movl %ecx, %edx
callq 0x7e8f0
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %edx
movl $0x9, %esi
callq 0x84240
movq -0x10(%rbp), %rdi
callq 0x84280
movl %eax, -0x34(%rbp)
cmpl $-0xa, -0x34(%rbp)
jne 0x824fb
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x825ba
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movl 0x10(%rax), %ecx
movl $0x8, %esi
xorl %edx, %edx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
callq 0x7e8f0
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7e8d0
movq -0x48(%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)
jmp 0x825ba
jmp 0x82559
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpq 0x160(%rdx), %rcx
movb %al, -0x49(%rbp)
jae 0x82592
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movl 0x10(%rax), %eax
andl $0x40040, %eax          # imm = 0x40040
cmpl $0x0, %eax
sete %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x8259b
jmp 0x825b3
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x158(%rax)
jmp 0x82559
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)