// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_htmlspecialchars_decode
static int jx9Builtin_htmlspecialchars_decode(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zCur, *zIn, *zEnd;
	int iFlags = 0x01; /* ENT_COMPAT */
	int nLen, nJump;
	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 ){
			break;
		}
		zCur = zIn;
		while( zIn < zEnd && zIn[0] != '&' ){
			zIn++;
		}
		if( zCur < zIn ){
			/* Append the raw string verbatim */
			jx9_result_string(pCtx, zCur, (int)(zIn-zCur));
		}
		nLen = (int)(zEnd-zIn);
		nJump = (int)sizeof(char);
		if( nLen >= (int)sizeof("&amp;")-1 && SyStrnicmp(zIn, "&amp;", sizeof("&amp;")-1) == 0 ){
			/* &amp; ==> '&' */
			jx9_result_string(pCtx, "&", (int)sizeof(char));
			nJump = (int)sizeof("&amp;")-1;
		}else if( nLen >= (int)sizeof("&lt;")-1 && SyStrnicmp(zIn, "&lt;", sizeof("&lt;")-1) == 0 ){
			/* &lt; ==> < */
			jx9_result_string(pCtx, "<", (int)sizeof(char));
			nJump = (int)sizeof("&lt;")-1; 
		}else if( nLen >= (int)sizeof("&gt;")-1 && SyStrnicmp(zIn, "&gt;", sizeof("&gt;")-1) == 0 ){
			/* &gt; ==> '>' */
			jx9_result_string(pCtx, ">", (int)sizeof(char));
			nJump = (int)sizeof("&gt;")-1; 
		}else if( nLen >= (int)sizeof("&quot;")-1 && SyStrnicmp(zIn, "&quot;", sizeof("&quot;")-1) == 0 ){
			/* &quot; ==> '"' */
			if( (iFlags & 0x04) == 0 /*ENT_NOQUOTES*/ ){
				jx9_result_string(pCtx, "\"", (int)sizeof(char));
			}else{
				/* Leave untouched */
				jx9_result_string(pCtx, "&quot;", (int)sizeof("&quot;")-1);
			}
			nJump = (int)sizeof("&quot;")-1;
		}else if( nLen >= (int)sizeof("&#039;")-1 && SyStrnicmp(zIn, "&#039;", sizeof("&#039;")-1) == 0 ){
			/* &#039; ==> ''' */
			if( iFlags & 0x02 /*ENT_QUOTES*/ ){
				/* Expand ''' */
				jx9_result_string(pCtx, "'", (int)sizeof(char));
			}else{
				/* Leave untouched */
				jx9_result_string(pCtx, "&#039;", (int)sizeof("&#039;")-1);
			}
			nJump = (int)sizeof("&#039;")-1;
		}else if( nLen >= (int)sizeof(char) ){
			/* expand '&' */
			jx9_result_string(pCtx, "&", (int)sizeof(char));
		}else{
			/* No more input to process */
			break;
		}
		zIn += nJump;
	}
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, -0x30(%rbp)
testl %esi, %esi
jle 0x54786
movq %rdx, %r15
movq (%rdx), %rdi
testb $0x1, 0x8(%rdi)
jne 0x547a4
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x30465
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %r12d
leaq -0x38(%rbp), %r13
movq %r13, %rsi
callq 0x30577
movq %rax, %r14
movslq (%r13), %rbx
movl $0x1, -0x34(%rbp)
cmpl $0x1, %r12d
je 0x547e3
movq 0x8(%r15), %r15
movq %r15, %rdi
callq 0x3f362
movl (%r15), %eax
testl %eax, %eax
movl $0x1, %ecx
cmovnsl %eax, %ecx
movl %ecx, -0x34(%rbp)
testl %ebx, %ebx
jle 0x54793
addq %r14, %rbx
leaq 0x20ee0(%rip), %r15     # 0x756d1
leaq 0x1cc7f(%rip), %r12     # 0x71477
movq %r14, %r13
cmpb $0x26, (%r13)
je 0x5480a
incq %r13
cmpq %rbx, %r13
jb 0x547fb
cmpq %r13, %r14
jae 0x54825
movl %r13d, %edx
subl %r14d, %edx
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq %r14, %rsi
callq 0x302f6
movl %ebx, %r14d
subl %r13d, %r14d
movl %r14d, -0x38(%rbp)
cmpl $0x5, %r14d
jl 0x5486c
movq %r13, %rdi
leaq 0x226b1(%rip), %rsi     # 0x76ef0
movl $0x5, %edx
callq 0x39f3f
testl %eax, %eax
jne 0x54876
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x302f6
movl $0x5, %eax
jmp 0x54956
cmpl $0x4, %r14d
jne 0x54902
movq %r13, %rdi
movq %r12, %rsi
movl $0x4, %edx
callq 0x39f3f
testl %eax, %eax
je 0x54927
movq %r13, %rdi
leaq 0x1cbe4(%rip), %rsi     # 0x7147c
movl $0x4, %edx
callq 0x39f3f
testl %eax, %eax
je 0x54938
cmpl $0x6, %r14d
jb 0x5490b
movq %r13, %rdi
leaq 0x22643(%rip), %rsi     # 0x76efd
movl $0x6, %edx
callq 0x39f3f
testl %eax, %eax
je 0x5496a
movq %r13, %rdi
leaq 0x22620(%rip), %rsi     # 0x76ef6
movl $0x6, %edx
callq 0x39f3f
testl %eax, %eax
jne 0x5490b
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
testb $0x2, -0x34(%rbp)
jne 0x5498f
leaq 0x225f9(%rip), %rsi     # 0x76ef6
jmp 0x54988
testl %r14d, %r14d
jle 0x54793
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x302f6
movl $0x1, %eax
jmp 0x54956
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x20d85(%rip), %rsi     # 0x756bb
jmp 0x54947
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1cab1(%rip), %rsi     # 0x713f8
movl $0x1, %edx
callq 0x302f6
movl $0x4, %eax
addq %rax, %r13
movq %r13, %r14
cmpq %rbx, %r13
jb 0x547fb
jmp 0x54793
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
testb $0x4, -0x34(%rbp)
jne 0x54981
leaq 0x1d2f0(%rip), %rsi     # 0x71c6f
jmp 0x54996
leaq 0x22575(%rip), %rsi     # 0x76efd
movl $0x6, %edx
jmp 0x5499b
leaq 0x219b0(%rip), %rsi     # 0x76346
movl $0x1, %edx
callq 0x302f6
movl $0x6, %eax
jmp 0x54956