// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_strrpos
static int jx9Builtin_strrpos(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zStart, *zBlob, *zPattern, *zPtr, *zEnd;
	ProcStringMatch xPatternMatch = SyBlobSearch; /* Case-sensitive pattern match */
	int nLen, nPatLen;
	sxu32 nOfft;
	sxi32 rc;
	if( nArg < 2 ){
		/* Missing arguments, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Extract the needle and the haystack */
	zBlob = jx9_value_to_string(apArg[0], &nLen);
	zPattern = jx9_value_to_string(apArg[1], &nPatLen);
	/* Point to the end of the pattern */
	zPtr = &zBlob[nLen - 1];
	zEnd = &zBlob[nLen];
	/* Save the starting posistion */
	zStart = zBlob;
	nOfft = 0; /* cc warning */
	/* Peek the starting offset if available */
	if( nArg > 2 ){
		int nStart;
		nStart = jx9_value_to_int(apArg[2]);
		if( nStart < 0 ){
			nStart = -nStart;
			if( nStart >= nLen ){
				/* Invalid offset */
				jx9_result_bool(pCtx, 0);
				return JX9_OK;
			}else{
				nLen -= nStart;
				zPtr = &zBlob[nLen - 1];
				zEnd = &zBlob[nLen];
			}
		}else{
			if( nStart >= nLen ){
				/* Invalid offset */
				jx9_result_bool(pCtx, 0);
				return JX9_OK;
			}else{
				zBlob += nStart;
				nLen -= nStart;
			}
		}
	}
	if( nLen > 0 && nPatLen > 0 ){
		/* Perform the lookup */
		for(;;){
			if( zBlob >= zPtr ){
				break;
			}
			rc = xPatternMatch((const void *)zPtr, (sxu32)(zEnd-zPtr), (const void *)zPattern, (sxu32)nPatLen, &nOfft);
			if( rc == SXRET_OK ){
				/* Pattern found, return it's position */
				jx9_result_int64(pCtx, (jx9_int64)(&zPtr[nOfft] - zStart));
				return JX9_OK;
			}
			zPtr--;
		}
		/* Pattern not found, return FALSE */
		jx9_result_bool(pCtx, 0);
	}else{
		jx9_result_bool(pCtx, 0);
	}
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
leaq 0x4a56(%rip), %rax      # 0x98fe0
movq %rax, -0x50(%rbp)
cmpl $0x2, -0x14(%rbp)
jge 0x945ab
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x94751
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x54(%rbp), %rsi
callq 0x56e20
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x58(%rbp), %rsi
callq 0x56e20
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movl -0x54(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x54(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x5c(%rbp)
cmpl $0x2, -0x14(%rbp)
jle 0x946bc
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x56c90
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jge 0x9467d
xorl %eax, %eax
subl -0x64(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x54(%rbp), %eax
jl 0x9464d
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x94751
movl -0x64(%rbp), %ecx
movl -0x54(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rax
movl -0x54(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x54(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x946ba
movl -0x64(%rbp), %eax
cmpl -0x54(%rbp), %eax
jl 0x9469c
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x94751
movl -0x64(%rbp), %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl -0x64(%rbp), %ecx
movl -0x54(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x54(%rbp)
jmp 0x946ba
jmp 0x946bc
cmpl $0x0, -0x54(%rbp)
jle 0x9473f
cmpl $0x0, -0x58(%rbp)
jle 0x9473f
jmp 0x946ca
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jb 0x946d6
jmp 0x94732
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rdx
subq %rdx, %rcx
movl %ecx, %esi
movq -0x38(%rbp), %rdx
movl -0x58(%rbp), %ecx
leaq -0x5c(%rbp), %r8
callq *%rax
movl %eax, -0x60(%rbp)
cmpl $0x0, -0x60(%rbp)
jne 0x94724
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x5c(%rbp), %eax
addq %rax, %rsi
movq -0x28(%rbp), %rax
subq %rax, %rsi
callq 0x57010
movl $0x0, -0x4(%rbp)
jmp 0x94751
movq -0x40(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x946ca
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
jmp 0x9474a
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)