// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_html_entity_decode
static int jx9Builtin_html_entity_decode(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zCur, *zIn, *zEnd;
	int iFlags = 0x01; /* ENT_COMPAT  */
	int nLen;
	sxu32 n;
	if( nArg < 1 || !jx9_value_is_string(apArg[0]) ){
		/* Missing/Invalid arguments, return NULL */
		jx9_result_null(pCtx);
		return JX9_OK;
	}
	/* Extract the target string */
	zIn = jx9_value_to_string(apArg[0], &nLen);
	zEnd = &zIn[nLen];
	/* Extract the flags if available */
	if( nArg > 1 ){
		iFlags = jx9_value_to_int(apArg[1]);
		if( iFlags < 0 ){
			iFlags = 0x01;
		}
	}
	/* Perform the requested operation */
	for(;;){
		if( zIn >= zEnd ){
			/* No more input to process */
			break;
		}
		zCur = zIn;
		while( zIn < zEnd && zIn[0] != '&' ){
			zIn++;
		}
		if( zCur < zIn ){
			/* Append raw string verbatim */
			jx9_result_string(pCtx, zCur, (int)(zIn-zCur));
		}
		if( zIn >= zEnd ){
			break;
		}
		nLen = (int)(zEnd-zIn);
		/* Find an encoded sequence */
		for(n = 0 ; n < SX_ARRAYSIZE(azHtmlEscape) ; n += 2 ){
			int iLen = (int)SyStrlen(azHtmlEscape[n]);
			if( nLen >= iLen && SyStrnicmp(zIn, azHtmlEscape[n], (sxu32)iLen) == 0 ){
				/* Got one */
				zIn += iLen;
				break;
			}
		}
		if( n < SX_ARRAYSIZE(azHtmlEscape) ){
			int c = azHtmlEscape[n+1][0];
			/* Output the decoded character */
			if( c == '\'' && ((iFlags & 0x02) == 0 /*ENT_QUOTES*/|| (iFlags & 0x04) /*ENT_NOQUOTES*/)  ){
				/* Do not process single quotes */
				jx9_result_string(pCtx, azHtmlEscape[n], -1);
			}else if( c == '"' && (iFlags & 0x04) /*ENT_NOQUOTES*/ ){
				/* Do not process double quotes */
				jx9_result_string(pCtx, azHtmlEscape[n], -1);
			}else{
				jx9_result_string(pCtx, azHtmlEscape[n+1], -1); /* Compute length automatically */
			}
		}else{
			/* Append '&' */
			jx9_result_string(pCtx, "&", (int)sizeof(char));
			zIn++;
		}
	}
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x1, -0x3c(%rbp)
cmpl $0x1, -0x14(%rbp)
jl 0x929f1
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
jne 0x92a06
movq -0x10(%rbp), %rdi
callq 0x57120
movl $0x0, -0x4(%rbp)
jmp 0x92c38
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x56e20
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
cmpl $0x1, -0x14(%rbp)
jle 0x92a4e
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x56c90
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jge 0x92a4c
movl $0x1, -0x3c(%rbp)
jmp 0x92a4e
jmp 0x92a50
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0x92a5f
jmp 0x92c31
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rcx
xorl %eax, %eax
cmpq -0x38(%rbp), %rcx
movb %al, -0x4d(%rbp)
jae 0x92a86
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x26, %eax
setne %al
movb %al, -0x4d(%rbp)
movb -0x4d(%rbp), %al
testb $0x1, %al
jne 0x92a8f
jmp 0x92a9d
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x92a67
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x92ac1
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
callq 0x57180
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0x92ad0
jmp 0x92c31
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpq $0x28, %rax
jae 0x92b4f
movl -0x44(%rbp), %eax
movl %eax, %ecx
leaq 0x5bfc6(%rip), %rax     # 0xeeac0
movq (%rax,%rcx,8), %rdi
callq 0x55d10
movl %eax, -0x48(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x48(%rbp), %eax
jl 0x92b42
movq -0x30(%rbp), %rdi
movl -0x44(%rbp), %eax
movl %eax, %ecx
leaq 0x5bfa2(%rip), %rax     # 0xeeac0
movq (%rax,%rcx,8), %rsi
movl -0x48(%rbp), %edx
callq 0x67830
cmpl $0x0, %eax
jne 0x92b42
movl -0x48(%rbp), %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
jmp 0x92b4f
jmp 0x92b44
movl -0x44(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x44(%rbp)
jmp 0x92ae5
movl -0x44(%rbp), %eax
cmpq $0x28, %rax
jae 0x92c0b
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x5bf53(%rip), %rax     # 0xeeac0
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x27, -0x4c(%rbp)
jne 0x92bb3
movl -0x3c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x92b93
movl -0x3c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x92bb3
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %eax
movl %eax, %ecx
leaq 0x5bf1d(%rip), %rax     # 0xeeac0
movq (%rax,%rcx,8), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x57180
jmp 0x92c09
cmpl $0x22, -0x4c(%rbp)
jne 0x92be4
movl -0x3c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x92be4
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %eax
movl %eax, %ecx
leaq 0x5beec(%rip), %rax     # 0xeeac0
movq (%rax,%rcx,8), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x57180
jmp 0x92c07
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x5bec7(%rip), %rax     # 0xeeac0
movq (%rax,%rcx,8), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x57180
jmp 0x92c09
jmp 0x92c2c
movq -0x10(%rbp), %rdi
leaq 0x30f9c(%rip), %rsi     # 0xc3bb2
movl $0x1, %edx
callq 0x57180
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x92a50
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)