// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: SyUriEncode
JX9_PRIVATE sxi32 SyUriEncode(const char *zSrc, sxu32 nLen, ProcConsumer xConsumer, void *pUserData)
{
	unsigned char *zIn = (unsigned char *)zSrc;
	unsigned char zHex[3] = { '%', 0, 0 };
	unsigned char zOut[2];
	unsigned char *zCur, *zEnd;
	sxi32 c;
	sxi32 rc;
#ifdef UNTRUST
	if( SX_EMPTY_STR(zSrc) || xConsumer == 0 ){
		return SXERR_EMPTY;
	}
#endif
	rc = SXRET_OK;
	zEnd = &zIn[nLen]; zCur = zIn;
	for(;;){
		if( zCur >= zEnd ){
			if( zCur != zIn ){
				rc = xConsumer(zIn, (sxu32)(zCur-zIn), pUserData);
			}
			break;
		}
		c = zCur[0];
		if( SAFE_HTTP(c) ){
			zCur++; continue;
		}
		if( zCur != zIn && SXRET_OK != (rc = xConsumer(zIn, (sxu32)(zCur-zIn), pUserData))){
			break;
		}		
		if( c == ' ' ){
			zOut[0] = '+';
			rc = xConsumer((const void *)zOut, sizeof(unsigned char), pUserData);
		}else{
			zHex[1]	= "0123456789ABCDEF"[(c >> 4) & 0x0F];
			zHex[2] = "0123456789ABCDEF"[c & 0x0F];
			rc = xConsumer(zHex, sizeof(zHex), pUserData);
		}
		if( SXRET_OK != rc ){
			break;
		}				
		zIn = &zCur[1]; zCur = zIn ;
	}
	return rc == SXRET_OK ? SXRET_OK : SXERR_ABORT;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movw 0x231fa(%rip), %ax      # 0xc18d0
movw %ax, -0x2b(%rbp)
movb 0x231f2(%rip), %al      # 0xc18d2
movb %al, -0x29(%rbp)
movl $0x0, -0x48(%rbp)
movq -0x28(%rbp), %rax
movl -0xc(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jb 0x9e737
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x9e732
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %rdx
subq %rdx, %rcx
movl %ecx, %esi
movq -0x20(%rbp), %rdx
callq *%rax
movl %eax, -0x48(%rbp)
jmp 0x9e83d
movq -0x38(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x44(%rbp)
callq 0xd1f0
movq (%rax), %rax
movslq -0x44(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x9e771
cmpl $0x5f, -0x44(%rbp)
je 0x9e771
cmpl $0x2d, -0x44(%rbp)
je 0x9e771
cmpl $0x24, -0x44(%rbp)
je 0x9e771
cmpl $0x2e, -0x44(%rbp)
jne 0x9e77f
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x9e700
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x9e7b4
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %rdx
subq %rdx, %rcx
movl %ecx, %esi
movq -0x20(%rbp), %rdx
callq *%rax
movl %eax, %ecx
movl %ecx, -0x48(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0x9e7b4
jmp 0x9e83d
cmpl $0x20, -0x44(%rbp)
jne 0x9e7d6
movb $0x2b, -0x2d(%rbp)
movq -0x18(%rbp), %rax
leaq -0x2d(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x1, %esi
callq *%rax
movl %eax, -0x48(%rbp)
jmp 0x9e81b
movl -0x44(%rbp), %eax
sarl $0x4, %eax
andl $0xf, %eax
movslq %eax, %rcx
leaq 0x23529(%rip), %rax     # 0xc1d12
movb (%rax,%rcx), %al
movb %al, -0x2a(%rbp)
movl -0x44(%rbp), %eax
andl $0xf, %eax
movslq %eax, %rcx
leaq 0x23513(%rip), %rax     # 0xc1d12
movb (%rax,%rcx), %al
movb %al, -0x29(%rbp)
movq -0x18(%rbp), %rax
leaq -0x2b(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x3, %esi
callq *%rax
movl %eax, -0x48(%rbp)
xorl %eax, %eax
cmpl -0x48(%rbp), %eax
je 0x9e824
jmp 0x9e83d
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x9e700
movl -0x48(%rbp), %edx
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)