// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_htmlentities
static int jx9Builtin_htmlentities(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	int iFlags = 0x01; /* ENT_COMPAT */
	const char *zIn, *zEnd;
	int nLen, c;
	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;
		}
		c = zIn[0];
		/* Perform a linear lookup on the decoding table */
		for( n = 0 ; n < SX_ARRAYSIZE(azHtmlEscape) ; n += 2 ){
			if( azHtmlEscape[n+1][0] == c ){
				/* Got one */
				break;
			}
		}
		if( n < SX_ARRAYSIZE(azHtmlEscape) ){
			/* Output the safe sequence [i.e: '<' ==> '&lt;"] */
			if( c == '"' && (iFlags & 0x04) /*ENT_NOQUOTES*/ ){
				/* Expand the double quote verbatim */
				jx9_result_string(pCtx, (const char *)&c, (int)sizeof(char));
			}else if(c == '\'' && ((iFlags & 0x02 /*ENT_QUOTES*/) == 0 || (iFlags & 0x04) /*ENT_NOQUOTES*/) ){
				/* expand single quote verbatim */
				jx9_result_string(pCtx, (const char *)&c, (int)sizeof(char));
			}else{
				jx9_result_string(pCtx, azHtmlEscape[n], -1/*Compute length automatically */);
			}
		}else{
			/* Output character verbatim */
			jx9_result_string(pCtx, (const char *)&c, (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, -0x24(%rbp)
cmpl $0x1, -0x14(%rbp)
jl 0x92851
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
jne 0x92866
movq -0x10(%rbp), %rdi
callq 0x57120
movl $0x0, -0x4(%rbp)
jmp 0x929af
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
cmpl $0x1, -0x14(%rbp)
jle 0x928ae
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x56c90
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0x928ac
movl $0x1, -0x24(%rbp)
jmp 0x928ae
jmp 0x928b0
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0x928bf
jmp 0x929a8
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpq $0x28, %rax
jae 0x92905
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x5c1d6(%rip), %rax     # 0xeeac0
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl -0x40(%rbp), %eax
jne 0x928f8
jmp 0x92905
jmp 0x928fa
movl -0x44(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x44(%rbp)
jmp 0x928d0
movl -0x44(%rbp), %eax
cmpq $0x28, %rax
jae 0x92985
cmpl $0x22, -0x40(%rbp)
jne 0x92933
movl -0x24(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x92933
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movl $0x1, %edx
callq 0x57180
jmp 0x92983
cmpl $0x27, -0x40(%rbp)
jne 0x92963
movl -0x24(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x9294f
movl -0x24(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x92963
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movl $0x1, %edx
callq 0x57180
jmp 0x92981
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %eax
movl %eax, %ecx
leaq 0x5c14d(%rip), %rax     # 0xeeac0
movq (%rax,%rcx,8), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x57180
jmp 0x92983
jmp 0x92997
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movl $0x1, %edx
callq 0x57180
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x928b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)