// File: /workspace/github_c_makefile_star2_O1/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, %rbx
testl %esi, %esi
jle 0x582dd
movq %rdx, %r15
movl %esi, %r12d
movq (%rdx), %rdi
leaq -0x2c(%rbp), %r13
movq %r13, %rsi
callq 0x30b04
cmpl $0x0, (%r13)
jle 0x582dd
movq %rax, %r14
movq %rbx, -0x38(%rbp)
movl $0x1, %ebx
cmpl $0x1, %r12d
je 0x582a6
movq 0x8(%r15), %r15
movq %r15, %rdi
callq 0x3fd5f
movl (%r15), %ebx
testl %ebx, %ebx
jle 0x583a5
movl -0x2c(%rbp), %eax
cmpl %ebx, %eax
cmovll %eax, %ebx
movq -0x38(%rbp), %r15
movq %r15, %rdi
callq 0x317eb
movq %rax, %r13
movq %r15, %rdi
callq 0x317a5
movq %rax, %r12
testq %rax, %rax
sete %al
movq %r13, -0x40(%rbp)
testq %r13, %r13
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x5830f
movq 0x8(%r15), %rbx
jmp 0x582e1
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x309f2
movq $0x0, (%rbx)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%rbx), %eax
orl $0x8, %eax
movl %eax, 0x8(%rbx)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq -0x2c(%rbp), %r15
addq %r14, %r15
cmpq %r15, %r14
jae 0x58388
movl %r15d, %r13d
subl %r14d, %r13d
cmpl %r13d, %ebx
cmovll %ebx, %r13d
movq %r12, %rdi
movq %r14, %rsi
movl %r13d, %edx
callq 0x3087c
movq -0x40(%rbp), %rax
testb $0x40, 0x8(%rax)
je 0x58351
movq -0x40(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x3f924
movl $0x0, 0x28(%r12)
movl 0x30(%r12), %eax
testb $0x4, %al
je 0x5837d
movq $0x0, 0x20(%r12)
movl $0x0, 0x2c(%r12)
andl $-0x5, %eax
movl %eax, 0x30(%r12)
movslq %r13d, %rax
addq %r14, %rax
movl %r13d, %ebx
jmp 0x5838b
movq %r14, %rax
cmpq %r15, %r14
movq %rax, %r14
jb 0x58316
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x30d83
jmp 0x582fe
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rbx
jmp 0x582e1