// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_strtr
static int jx9Builtin_strtr(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zIn;
	int nLen;
	if( nArg < 1 ){
		/* Nothing to replace, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	zIn = jx9_value_to_string(apArg[0], &nLen);
	if( nLen < 1 || nArg < 2 ){
		/* Invalid arguments */
		jx9_result_string(pCtx, zIn, nLen);
		return JX9_OK;
	}
	if( nArg == 2 && jx9_value_is_json_array(apArg[1]) ){
		str_replace_data sRepData;
		SyBlob sWorker;
		/* Initilaize the working buffer */
		SyBlobInit(&sWorker, &pCtx->pVm->sAllocator);
		/* Copy raw string */
		SyBlobAppend(&sWorker, (const void *)zIn, (sxu32)nLen);
		/* Init our replace data instance */
		sRepData.pWorker = &sWorker;
		sRepData.xMatch = SyBlobSearch;
		/* Iterate throw array entries and perform the replace operation.*/
		jx9_array_walk(apArg[1], StringReplaceWalker, &sRepData);
		/* All done, return the result string */
		jx9_result_string(pCtx, (const char *)SyBlobData(&sWorker), 
			(int)SyBlobLength(&sWorker)); /* Will make it's own copy */
		/* Clean-up */
		SyBlobRelease(&sWorker);
	}else{
		int i, flen, tlen, c, iOfft;
		const char *zFrom, *zTo;
		if( nArg < 3 ){
			/* Nothing to replace */
			jx9_result_string(pCtx, zIn, nLen);
			return JX9_OK;
		}
		/* Extract given arguments */
		zFrom = jx9_value_to_string(apArg[1], &flen);
		zTo = jx9_value_to_string(apArg[2], &tlen);
		if( flen < 1 || tlen < 1 ){
			/* Nothing to replace */
			jx9_result_string(pCtx, zIn, nLen);
			return JX9_OK;
		}
		/* Start the replace process */
		for( i = 0 ; i < nLen ; ++i ){
			c = zIn[i];
			if( CheckMask(c, zFrom, flen, &iOfft) ){
				if ( iOfft < tlen ){
					c = zTo[iOfft];
				}
			}
			jx9_result_string(pCtx, (const char *)&c, (int)sizeof(char));
			
		}
	}
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpl $0x1, -0x14(%rbp)
jge 0x968a3
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x96a5f
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x28(%rbp)
cmpl $0x1, -0x2c(%rbp)
jl 0x968c3
cmpl $0x2, -0x14(%rbp)
jge 0x968df
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x57180
movl $0x0, -0x4(%rbp)
jmp 0x96a5f
cmpl $0x2, -0x14(%rbp)
jne 0x96961
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x57610
cmpl $0x0, %eax
je 0x96961
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rsi
leaq -0x70(%rbp), %rdi
callq 0x58bb0
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
leaq -0x70(%rbp), %rdi
callq 0x5d9d0
leaq -0x70(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq 0x26b9(%rip), %rax      # 0x98fe0
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x5df6(%rip), %rsi      # 0x9c730
leaq -0x50(%rbp), %rdx
callq 0x57880
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x60(%rbp), %edx
callq 0x57180
leaq -0x70(%rbp), %rdi
callq 0x58c00
jmp 0x96a58
cmpl $0x3, -0x14(%rbp)
jge 0x96983
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x57180
movl $0x0, -0x4(%rbp)
jmp 0x96a5f
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x78(%rbp), %rsi
callq 0x56e20
movq %rax, -0x90(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x7c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x98(%rbp)
cmpl $0x1, -0x78(%rbp)
jl 0x969bf
cmpl $0x1, -0x7c(%rbp)
jge 0x969db
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x57180
movl $0x0, -0x4(%rbp)
jmp 0x96a5f
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x96a56
movq -0x28(%rbp), %rax
movslq -0x74(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %edi
movq -0x90(%rbp), %rsi
movl -0x78(%rbp), %edx
leaq -0x84(%rbp), %rcx
callq 0x9c490
cmpl $0x0, %eax
je 0x96a39
movl -0x84(%rbp), %eax
cmpl -0x7c(%rbp), %eax
jge 0x96a37
movq -0x98(%rbp), %rax
movslq -0x84(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x80(%rbp)
jmp 0x96a39
movq -0x10(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl $0x1, %edx
callq 0x57180
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x969e2
jmp 0x96a58
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)