// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_htmlspecialchars
static int jx9Builtin_htmlspecialchars(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zCur, *zIn, *zEnd;
	int iFlags = 0x01|0x40; /* ENT_COMPAT | ENT_HTML401 */
	int nLen, c;
	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|0x40;
		}
	}
	/* Perform the requested operation */
	for(;;){
		if( zIn >= zEnd ){
			break;
		}
		zCur = zIn;
		while( zIn < zEnd && zIn[0] != '&' && zIn[0] != '\'' && zIn[0] != '"' && zIn[0] != '<' && zIn[0] != '>' ){
			zIn++;
		}
		if( zCur < zIn ){
			/* Append the raw string verbatim */
			jx9_result_string(pCtx, zCur, (int)(zIn-zCur));
		}
		if( zIn >= zEnd ){
			break;
		}
		c = zIn[0];
		if( c == '&' ){
			/* Expand '&amp;' */
			jx9_result_string(pCtx, "&amp;", (int)sizeof("&amp;")-1);
		}else if( c == '<' ){
			/* Expand '&lt;' */
			jx9_result_string(pCtx, "&lt;", (int)sizeof("&lt;")-1);
		}else if( c == '>' ){
			/* Expand '&gt;' */
			jx9_result_string(pCtx, "&gt;", (int)sizeof("&gt;")-1);
		}else if( c == '\'' ){
			if( iFlags & 0x02 /*ENT_QUOTES*/ ){
				/* Expand '&#039;' */
				jx9_result_string(pCtx, "&#039;", (int)sizeof("&#039;")-1);
			}else{
				/* Leave the single quote untouched */
				jx9_result_string(pCtx, "'", (int)sizeof(char));
			}
		}else if( c == '"' ){
			if( (iFlags & 0x04) == 0 /*ENT_NOQUOTES*/ ){
				/* Expand '&quot;' */
				jx9_result_string(pCtx, "&quot;", (int)sizeof("&quot;")-1);
			}else{
				/* Leave the double quote untouched */
				jx9_result_string(pCtx, "\"", (int)sizeof(char));
			}
		}
		/* Ignore the unsafe HTML character */
		zIn++;
	}
	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 0x545e8
movq %rdx, %r15
movq (%rdx), %rdi
testb $0x1, 0x8(%rdi)
jne 0x54606
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, %rbx
movslq (%r13), %r13
movl $0x41, -0x34(%rbp)
cmpl $0x1, %r12d
je 0x54645
movq 0x8(%r15), %r15
movq %r15, %rdi
callq 0x3f362
movl (%r15), %eax
testl %eax, %eax
movl $0x41, %ecx
cmovnsl %eax, %ecx
movl %ecx, -0x34(%rbp)
testl %r13d, %r13d
jle 0x545f5
addq %rbx, %r13
movabsq $0x500000c400000000, %r15 # imm = 0x500000C400000000
movq %rbx, %r14
movzbl (%r14), %eax
cmpq $0x3e, %rax
ja 0x5466a
btq %rax, %r15
jb 0x54677
incq %r14
cmpq %r13, %r14
jb 0x5465a
xorl %r12d, %r12d
jmp 0x5467a
movb $0x1, %r12b
cmpq %r14, %rbx
jae 0x54694
movl %r14d, %edx
subl %ebx, %edx
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq %rbx, %rsi
callq 0x302f6
testb %r12b, %r12b
je 0x545f5
movzbl (%r14), %eax
cmpl $0x26, %eax
jle 0x546ca
cmpl $0x27, %eax
je 0x546ea
cmpl $0x3c, %eax
je 0x54701
cmpl $0x3e, %eax
jne 0x5474d
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1cdb4(%rip), %rsi     # 0x7147c
jmp 0x54710
cmpl $0x22, %eax
je 0x54717
cmpl $0x26, %eax
jne 0x5474d
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x2280d(%rip), %rsi     # 0x76ef0
movl $0x5, %edx
jmp 0x54748
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
testb $0x2, -0x34(%rbp)
jne 0x5472e
leaq 0x21c47(%rip), %rsi     # 0x76346
jmp 0x54743
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1cd67(%rip), %rsi     # 0x71477
movl $0x4, %edx
jmp 0x54748
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
testb $0x4, -0x34(%rbp)
jne 0x5473c
leaq 0x227d1(%rip), %rsi     # 0x76efd
jmp 0x54735
leaq 0x227c1(%rip), %rsi     # 0x76ef6
movl $0x6, %edx
jmp 0x54748
leaq 0x1d52c(%rip), %rsi     # 0x71c6f
movl $0x1, %edx
callq 0x302f6
incq %r14
movq %r14, %rbx
cmpq %r13, %r14
jb 0x5465a
jmp 0x545f5