// File: /workspace/github_c_makefile_star2_O1/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 0x55ecc
movq %rdx, %r14
movq (%rdx), %rdi
testb $0x1, 0x8(%rdi)
jne 0x55eea
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x309f2
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %r15d
leaq -0x38(%rbp), %r13
movq %r13, %rsi
callq 0x30b04
movq %rax, %r12
movslq (%r13), %rbx
movl $0x1, -0x34(%rbp)
cmpl $0x1, %r15d
je 0x55f29
movq 0x8(%r14), %r14
movq %r14, %rdi
callq 0x3fd5f
movl (%r14), %eax
testl %eax, %eax
movl $0x1, %ecx
cmovnsl %eax, %ecx
movl %ecx, -0x34(%rbp)
testl %ebx, %ebx
jle 0x55ed9
addq %r12, %rbx
leaq 0x22fae(%rip), %r14     # 0x78ee5
leaq 0x21788(%rip), %r15     # 0x776c6
movq %r12, %r13
cmpb $0x26, (%r13)
je 0x55f50
incq %r13
cmpq %rbx, %r13
jb 0x55f41
cmpq %r13, %r12
jae 0x55f6b
movl %r13d, %edx
subl %r12d, %edx
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq %r12, %rsi
callq 0x3087c
movl %ebx, %r12d
subl %r13d, %r12d
movl %r12d, -0x38(%rbp)
cmpl $0x5, %r12d
jl 0x55f93
movq %r13, %rdi
movq %r14, %rsi
movl $0x5, %edx
callq 0x3a837
testl %eax, %eax
je 0x5603f
cmpl $0x4, %r12d
jl 0x55fd7
movq %r13, %rdi
leaq 0x1d4d4(%rip), %rsi     # 0x73477
movl $0x4, %edx
callq 0x3a837
testl %eax, %eax
je 0x5605e
cmpl $0x4, %r12d
jl 0x55fd7
movq %r13, %rdi
leaq 0x1d4b7(%rip), %rsi     # 0x7347c
movl $0x4, %edx
callq 0x3a837
testl %eax, %eax
je 0x56097
cmpl $0x6, %r12d
jl 0x56017
movq %r13, %rdi
leaq 0x22f0b(%rip), %rsi     # 0x78ef2
movl $0x6, %edx
callq 0x3a837
testl %eax, %eax
je 0x5606f
cmpl $0x6, %r12d
jl 0x56017
movq %r13, %rdi
leaq 0x22ee6(%rip), %rsi     # 0x78eeb
movl $0x6, %edx
callq 0x3a837
testl %eax, %eax
je 0x560b7
testl %r12d, %r12d
jle 0x55ed9
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x3087c
movl $0x1, %eax
jmp 0x560f1
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x3087c
movl $0x5, %eax
jmp 0x560f1
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x21643(%rip), %rsi     # 0x776b0
jmp 0x560a6
testb $0x4, -0x34(%rbp)
jne 0x56086
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1dbee(%rip), %rsi     # 0x73c72
jmp 0x560e2
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x22e5d(%rip), %rsi     # 0x78ef2
jmp 0x560cc
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1d352(%rip), %rsi     # 0x733f8
movl $0x1, %edx
callq 0x3087c
movl $0x4, %eax
jmp 0x560f1
testb $0x2, -0x34(%rbp)
jne 0x560d3
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x22e1f(%rip), %rsi     # 0x78eeb
movl $0x6, %edx
jmp 0x560e7
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x22259(%rip), %rsi     # 0x7833b
movl $0x1, %edx
callq 0x3087c
movl $0x6, %eax
addq %rax, %r13
movq %r13, %r12
cmpq %rbx, %r13
jb 0x55f41
jmp 0x55ed9