// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9CompileExpr
static sxi32 jx9CompileExpr(
	jx9_gen_state *pGen, /* Code generator state */
	sxi32 iFlags,        /* Control flags */
	sxi32 (*xTreeValidator)(jx9_gen_state *, jx9_expr_node *) /* Node validator callback.NULL otherwise */
	)
{
	jx9_expr_node *pRoot;
	SySet sExprNode;
	SyToken *pEnd;
	sxi32 nExpr;
	sxi32 iNest;
	sxi32 rc;
	/* Initialize worker variables */
	nExpr = 0;
	pRoot = 0;
	SySetInit(&sExprNode, &pGen->pVm->sAllocator, sizeof(jx9_expr_node *));
	SySetAlloc(&sExprNode, 0x10);
	rc = SXRET_OK;
	/* Delimit the expression */
	pEnd = pGen->pIn;
	iNest = 0;
	while( pEnd < pGen->pEnd ){
		if( pEnd->nType & JX9_TK_OCB /* '{' */ ){
			/* Ticket 1433-30: Annonymous/Closure functions body */
			iNest++;
		}else if(pEnd->nType & JX9_TK_CCB /* '}' */ ){
			iNest--;
		}else if( pEnd->nType & JX9_TK_SEMI /* ';' */ ){
			if( iNest <= 0 ){
				break;
			}
		}
		pEnd++;
	}
	if( iFlags & EXPR_FLAG_COMMA_STATEMENT ){
		SyToken *pEnd2 = pGen->pIn;
		iNest = 0;
		/* Stop at the first comma */
		while( pEnd2 < pEnd ){
			if( pEnd2->nType & (JX9_TK_OCB/*'{'*/|JX9_TK_OSB/*'['*/|JX9_TK_LPAREN/*'('*/) ){
				iNest++;
			}else if(pEnd2->nType & (JX9_TK_CCB/*'}'*/|JX9_TK_CSB/*']'*/|JX9_TK_RPAREN/*')'*/)){
				iNest--;
			}else if( pEnd2->nType & JX9_TK_COMMA /*','*/ ){
				if( iNest <= 0 ){
					break;
				}
			}
			pEnd2++;
		}
		if( pEnd2 <pEnd ){
			pEnd = pEnd2;
		}
	}
	if( pEnd > pGen->pIn ){
		SyToken *pTmp = pGen->pEnd;
		/* Swap delimiter */
		pGen->pEnd = pEnd;
		/* Try to get an expression tree */
		rc = jx9ExprMakeTree(&(*pGen), &sExprNode, &pRoot);
		if( rc == SXRET_OK && pRoot ){
			rc = SXRET_OK;
			if( xTreeValidator ){
				/* Call the upper layer validator callback */
				rc = xTreeValidator(&(*pGen), pRoot);
			}
			if( rc != SXERR_ABORT ){
				/* Generate code for the given tree */
				rc = GenStateEmitExprCode(&(*pGen), pRoot, iFlags);
			}
			nExpr = 1;
		}
		/* Release the whole tree */
		jx9ExprFreeTree(&(*pGen), &sExprNode);
		/* Synchronize token stream */
		pGen->pEnd = pTmp;
		pGen->pIn  = pEnd;
		if( rc == SXERR_ABORT ){
			SySetRelease(&sExprNode);
			return SXERR_ABORT;
		}
	}
	SySetRelease(&sExprNode);
	return nExpr > 0 ? SXRET_OK : SXERR_EMPTY;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x5c(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq -0x50(%rbp), %rdi
movl $0x8, %edx
callq 0x5b470
leaq -0x50(%rbp), %rdi
movl $0x10, %esi
callq 0x7e350
movl $0x0, -0x64(%rbp)
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x60(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x160(%rcx), %rax
jae 0x811e9
movq -0x58(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x811a0
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x811db
movq -0x58(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x811bc
movl -0x60(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x811d9
movq -0x58(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x40000, %eax          # imm = 0x40000
cmpl $0x0, %eax
je 0x811d7
cmpl $0x0, -0x60(%rbp)
jg 0x811d5
jmp 0x811e9
jmp 0x811d7
jmp 0x811d9
jmp 0x811db
movq -0x58(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x58(%rbp)
jmp 0x81175
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x81291
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x60(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x8127d
movq -0x70(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xa40, %eax            # imm = 0xA40
cmpl $0x0, %eax
je 0x81234
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x8126f
movq -0x70(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x1480, %eax           # imm = 0x1480
cmpl $0x0, %eax
je 0x81250
movl -0x60(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x8126d
movq -0x70(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x20000, %eax          # imm = 0x20000
cmpl $0x0, %eax
je 0x8126b
cmpl $0x0, -0x60(%rbp)
jg 0x81269
jmp 0x8127d
jmp 0x8126b
jmp 0x8126d
jmp 0x8126f
movq -0x70(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x70(%rbp)
jmp 0x8120e
movq -0x70(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x8128f
movq -0x70(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x81291
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x158(%rcx), %rax
jbe 0x81369
movq -0x10(%rbp), %rax
movq 0x160(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x58(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x160(%rax)
movq -0x10(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x858c0
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jne 0x81324
cmpq $0x0, -0x28(%rbp)
je 0x81324
movl $0x0, -0x64(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x81304
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq *%rax
movl %eax, -0x64(%rbp)
cmpl $-0xa, -0x64(%rbp)
je 0x8131d
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x859e0
movl %eax, -0x64(%rbp)
movl $0x1, -0x5c(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x85fb0
movq -0x78(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x160(%rax)
movq -0x58(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x158(%rax)
cmpl $-0xa, -0x64(%rbp)
jne 0x81367
leaq -0x50(%rbp), %rdi
callq 0x66980
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x81385
jmp 0x81369
leaq -0x50(%rbp), %rdi
callq 0x66980
movl -0x5c(%rbp), %edx
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovgl %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)