// File: /workspace/github_c_makefile_star2_O2/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 0x4900b
movq %rdx, %r14
movq (%rdx), %rdi
testb $0x1, 0x8(%rdi)
jne 0x49025
movq -0x30(%rbp), %rdi
callq 0x298e8
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %r15d
leaq -0x3c(%rbp), %r12
movq %r12, %rsi
callq 0x297ed
movq %rax, %r13
movslq (%r12), %rbx
cmpl $0x1, %r15d
jne 0x49049
pushq $0x1
popq %rax
movl %eax, -0x34(%rbp)
jmp 0x4905d
movq 0x8(%r14), %rdi
callq 0x29772
testl %eax, %eax
pushq $0x1
popq %rcx
cmovnsl %eax, %ecx
movl %ecx, -0x34(%rbp)
movq %r13, %r12
addq %rbx, %r12
leal (%rbx,%r13), %eax
movl %eax, -0x38(%rbp)
pushq $0x4
popq %r15
cmpq %r12, %r13
jae 0x49014
movl %r15d, %ebx
xorl %r15d, %r15d
movq %r13, %r14
cmpq %r12, %r14
jae 0x4908f
cmpb $0x26, (%r14)
je 0x4908f
incq %r14
incl %r15d
jmp 0x4907c
cmpq %r14, %r13
jae 0x490a3
movq -0x30(%rbp), %rdi
movq %r13, %rsi
movl %r15d, %edx
callq 0x29903
movl -0x38(%rbp), %eax
subl %r13d, %eax
movl %eax, %r13d
subl %r15d, %r13d
movl %r13d, -0x3c(%rbp)
cmpl $0x5, %r13d
jl 0x490ed
movq %r14, %rdi
leaq 0x1de0d(%rip), %rsi     # 0x66ed0
pushq $0x5
popq %rdx
callq 0x32436
testl %eax, %eax
jne 0x490f9
movq -0x30(%rbp), %rdi
leaq 0x1c5d7(%rip), %rsi     # 0x656b1
pushq $0x1
popq %rdx
callq 0x29903
pushq $0x5
popq %rax
movl %ebx, %r15d
jmp 0x491c8
addl $-0x4, %eax
cmpl %r15d, %eax
jne 0x49182
movq %r14, %rdi
leaq 0x1834a(%rip), %rsi     # 0x6144d
movl %ebx, %r15d
movl %ebx, %edx
callq 0x32436
testl %eax, %eax
je 0x491a5
movq %r14, %rdi
leaq 0x18333(%rip), %rsi     # 0x61452
movl %r15d, %edx
callq 0x32436
testl %eax, %eax
je 0x491b2
cmpl $0x6, %r13d
jb 0x4918e
movq %r14, %rdi
leaq 0x1dd9e(%rip), %rsi     # 0x66edd
pushq $0x6
popq %rbx
movl %ebx, %edx
callq 0x32436
testl %eax, %eax
je 0x491d3
movq %r14, %rdi
leaq 0x1dd7b(%rip), %rsi     # 0x66ed6
movl %ebx, %edx
callq 0x32436
testl %eax, %eax
jne 0x4918e
testb $0x2, -0x34(%rbp)
jne 0x491f5
movq -0x30(%rbp), %rdi
leaq 0x1dd5b(%rip), %rsi     # 0x66ed6
pushq $0x6
jmp 0x49202
testl %r13d, %r13d
movl %ebx, %r15d
jle 0x49014
movq -0x30(%rbp), %rdi
leaq 0x1c518(%rip), %rsi     # 0x656b1
pushq $0x1
popq %rdx
callq 0x29903
pushq $0x1
jmp 0x491c7
movq -0x30(%rbp), %rdi
leaq 0x1c4eb(%rip), %rsi     # 0x6569b
jmp 0x491bd
movq -0x30(%rbp), %rdi
leaq 0x18211(%rip), %rsi     # 0x613ce
pushq $0x1
popq %rdx
callq 0x29903
pushq $0x4
popq %rax
addq %rax, %r14
movq %r14, %r13
jmp 0x4906e
testb $0x4, -0x34(%rbp)
jne 0x491e6
movq -0x30(%rbp), %rdi
leaq 0x18a85(%rip), %rsi     # 0x61c69
jmp 0x49200
movq -0x30(%rbp), %rdi
leaq 0x1dcec(%rip), %rsi     # 0x66edd
movl %ebx, %edx
jmp 0x49203
movq -0x30(%rbp), %rdi
leaq 0x1d126(%rip), %rsi     # 0x66326
pushq $0x1
popq %rdx
callq 0x29903
pushq $0x6
jmp 0x491c7