// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_strspn
static int jx9Builtin_strspn(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zString, *zMask, *zEnd;
	int iMasklen, iLen;
	SyString sToken;
	int iCount = 0;
	int rc;
	if( nArg < 2 ){
		/* Missing agruments, return zero */
		jx9_result_int(pCtx, 0);
		return JX9_OK;
	}
	/* Extract the target string */
	zString = jx9_value_to_string(apArg[0], &iLen);
	/* Extract the mask */
	zMask = jx9_value_to_string(apArg[1], &iMasklen);
	if( iLen < 1 || iMasklen < 1 ){
		/* Nothing to process, return zero */
		jx9_result_int(pCtx, 0);
		return JX9_OK;
	}
	if( nArg > 2 ){
		int nOfft;
		/* Extract the offset */
		nOfft = jx9_value_to_int(apArg[2]);
		if( nOfft < 0 ){
			const char *zBase = &zString[iLen + nOfft];
			if( zBase > zString ){
				iLen = (int)(&zString[iLen]-zBase);
				zString = zBase;	
			}else{
				/* Invalid offset */
				jx9_result_int(pCtx, 0);
				return JX9_OK;
			}
		}else{
			if( nOfft >= iLen ){
				/* Invalid offset */
				jx9_result_int(pCtx, 0);
				return JX9_OK;
			}else{
				/* Update offset */
				zString += nOfft;
				iLen -= nOfft;
			}
		}
		if( nArg > 3 ){
			int iUserlen;
			/* Extract the desired length */
			iUserlen = jx9_value_to_int(apArg[3]);
			if( iUserlen > 0 && iUserlen < iLen ){
				iLen = iUserlen;
			}
		}
	}
	/* Point to the end of the string */
	zEnd = &zString[iLen];
	/* Extract the first non-space token */
	rc = ExtractNonSpaceToken(&zString, zEnd, &sToken);
	if( rc == SXRET_OK && sToken.nByte > 0 ){
		/* Compare against the current mask */
		iCount = LongestStringMask(sToken.zString, (int)sToken.nByte, zMask, iMasklen);
	}
	/* Longest match */
	jx9_result_int(pCtx, iCount);
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x54(%rbp)
cmpl $0x2, -0x14(%rbp)
jge 0x956d7
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x56fb0
movl $0x0, -0x4(%rbp)
jmp 0x9585c
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x56e20
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x30(%rbp)
cmpl $0x1, -0x40(%rbp)
jl 0x9570c
cmpl $0x1, -0x3c(%rbp)
jge 0x95723
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x56fb0
movl $0x0, -0x4(%rbp)
jmp 0x9585c
cmpl $0x2, -0x14(%rbp)
jle 0x95804
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x56c90
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jge 0x95799
movq -0x28(%rbp), %rax
movl -0x40(%rbp), %ecx
addl -0x5c(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x28(%rbp), %rax
jbe 0x95780
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
addq %rcx, %rax
movq -0x68(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x40(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x95797
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x56fb0
movl $0x0, -0x4(%rbp)
jmp 0x9585c
jmp 0x957d6
movl -0x5c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jl 0x957b8
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x56fb0
movl $0x0, -0x4(%rbp)
jmp 0x9585c
movl -0x5c(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl -0x5c(%rbp), %ecx
movl -0x40(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x40(%rbp)
jmp 0x957d6
cmpl $0x3, -0x14(%rbp)
jle 0x95802
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x56c90
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jle 0x95800
movl -0x6c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x95800
movl -0x6c(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x95802
jmp 0x95804
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rsi
leaq -0x28(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x9c0a0
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
jne 0x95849
cmpl $0x0, -0x48(%rbp)
jbe 0x95849
movq -0x50(%rbp), %rdi
movl -0x48(%rbp), %esi
movq -0x30(%rbp), %rdx
movl -0x3c(%rbp), %ecx
callq 0x9c1e0
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x56fb0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)