// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_str_split
static int jx9Builtin_str_split(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zString, *zEnd;
	jx9_value *pArray, *pValue;
	int split_len;
	int nLen;
	if( nArg < 1 ){
		/* Missing arguments, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Point to the target string */
	zString = jx9_value_to_string(apArg[0], &nLen);
	if( nLen < 1 ){
		/* Nothing to process, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	split_len = (int)sizeof(char);
	if( nArg > 1 ){
		/* Split length */
		split_len = jx9_value_to_int(apArg[1]);
		if( split_len < 1 ){
			/* Invalid length, return FALSE */
			jx9_result_bool(pCtx, 0);
			return JX9_OK;
		}
		if( split_len > nLen ){
			split_len = nLen;
		}
	}
	/* Create the array and the scalar value */
	pArray = jx9_context_new_array(pCtx);
	/*Chunk value */
	pValue = jx9_context_new_scalar(pCtx);
	if( pValue == 0 || pArray == 0 ){
		/* Return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Point to the end of the string */
	zEnd = &zString[nLen];
	/* Perform the requested operation */
	for(;;){
		int nMax;
		if( zString >= zEnd ){
			/* No more input to process */
			break;
		}
		nMax = (int)(zEnd-zString);
		if( nMax < split_len ){
			split_len = nMax;
		}
		/* Copy the current chunk */
		jx9_value_string(pValue, zString, split_len);
		/* Insert it */
		jx9_array_add_elem(pArray, 0, pValue); /* Will make it's own copy */
		/* reset the string cursor */
		jx9_value_reset_string_cursor(pValue);
		/* Update position */
		zString += split_len;
	}
	/* 
	 * Return the array.
	 * Don't worry about freeing memory, everything will be automatically released
	 * upon we return from this function.
	 */
	jx9_result_value(pCtx, pArray);
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r13
testl %esi, %esi
jle 0x4af2b
movq %rdx, %rbx
movl %esi, %r15d
movq (%rdx), %rdi
leaq -0x2c(%rbp), %r12
movq %r12, %rsi
callq 0x297ed
cmpl $0x0, (%r12)
jle 0x4af2b
movq %rax, %r14
cmpl $0x1, %r15d
jne 0x4ae8f
pushq $0x1
popq %r15
jmp 0x4aeab
movq 0x8(%rbx), %rdi
callq 0x29772
testl %eax, %eax
jle 0x4af2b
movl -0x2c(%rbp), %r15d
cmpl %r15d, %eax
cmovll %eax, %r15d
movq %r13, %rdi
callq 0x2a2b0
movq %rax, %rbx
movq %r13, %rdi
callq 0x2a26a
movq %r13, %rdi
movq %rax, %r13
testq %rax, %rax
sete %al
movq %rbx, -0x38(%rbp)
testq %rbx, %rbx
sete %cl
orb %al, %cl
cmpb $0x1, %cl
je 0x4af2e
movq %rdi, -0x40(%rbp)
movslq -0x2c(%rbp), %r12
addq %r14, %r12
movq %r13, %rbx
addq $0x18, %rbx
cmpq %r12, %r14
jae 0x4af46
movl %r12d, %eax
subl %r14d, %eax
cmpl %eax, %r15d
cmovgel %eax, %r15d
movq %r13, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x29588
movq -0x38(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x29c4b
movq %rbx, %rdi
callq 0x31b1e
movslq %r15d, %rax
addq %rax, %r14
jmp 0x4aeed
movq %r13, %rdi
xorl %esi, %esi
callq 0x298b2
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x299d3
jmp 0x4af35