// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_explode
static int jx9Builtin_explode(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zDelim, *zString, *zCur, *zEnd;
	int nDelim, nStrlen, iLimit;
	jx9_value *pArray;
	jx9_value *pValue;
	sxu32 nOfft;
	sxi32 rc;
	if( nArg < 2 ){
		/* Missing arguments, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Extract the delimiter */
	zDelim = jx9_value_to_string(apArg[0], &nDelim);
	if( nDelim < 1 ){
		/* Empty delimiter, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Extract the string */
	zString = jx9_value_to_string(apArg[1], &nStrlen);
	if( nStrlen < 1 ){
		/* Empty delimiter, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Point to the end of the string */
	zEnd = &zString[nStrlen];
	/* Create the array */
	pArray =  jx9_context_new_array(pCtx);
	pValue = jx9_context_new_scalar(pCtx);
	if( pArray == 0 || pValue == 0 ){
		/* Out of memory, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Set a defualt limit */
	iLimit = SXI32_HIGH;
	if( nArg > 2 ){
		iLimit = jx9_value_to_int(apArg[2]);
		 if( iLimit < 0 ){
			iLimit = -iLimit;
		}
		if( iLimit == 0 ){
			iLimit = 1;
		}
		iLimit--;
	}
	/* Start exploding */
	for(;;){
		if( zString >= zEnd ){
			/* No more entry to process */
			break;
		}
		rc = SyBlobSearch(zString, (sxu32)(zEnd-zString), zDelim, nDelim, &nOfft);
		if( rc != SXRET_OK || iLimit <= (int)jx9_array_count(pArray) ){
			/* Limit reached, insert the rest of the string and break */
			if( zEnd > zString ){
				jx9_value_string(pValue, zString, (int)(zEnd-zString));
				jx9_array_add_elem(pArray, 0/* Automatic index assign*/, pValue);
			}
			break;
		}
		/* Point to the desired offset */
		zCur = &zString[nOfft];
		if( zCur > zString ){
			/* Perform the store operation */
			jx9_value_string(pValue, zString, (int)(zCur-zString));
			jx9_array_add_elem(pArray, 0/* Automatic index assign*/, pValue);
		}
		/* Point beyond the delimiter */
		zString = &zCur[nDelim];
		/* Reset the cursor */
		jx9_value_reset_string_cursor(pValue);
	}
	/* Return the freshly created array */
	jx9_result_value(pCtx, pArray);
	/* NOTE that every allocated jx9_value will be automatically 
	 * released as soon we return from this foregin function.
	 */
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpl $0x2, -0x14(%rbp)
jge 0x93290
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x93480
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x44(%rbp), %rsi
callq 0x56e20
movq %rax, -0x28(%rbp)
cmpl $0x1, -0x44(%rbp)
jge 0x932c1
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x93480
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x56e20
movq %rax, -0x30(%rbp)
cmpl $0x1, -0x48(%rbp)
jge 0x932f3
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x93480
movq -0x30(%rbp), %rax
movslq -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x58570
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x58510
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x9332a
cmpq $0x0, -0x60(%rbp)
jne 0x93341
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x93480
movl $0x7fffffff, -0x4c(%rbp) # imm = 0x7FFFFFFF
cmpl $0x2, -0x14(%rbp)
jle 0x93382
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x56c90
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jge 0x9336c
xorl %eax, %eax
subl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0x93379
movl $0x1, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x93384
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jb 0x93393
jmp 0x9346c
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
movq -0x28(%rbp), %rdx
movl -0x44(%rbp), %ecx
leaq -0x64(%rbp), %r8
callq 0x98fe0
movl %eax, -0x68(%rbp)
cmpl $0x0, -0x68(%rbp)
jne 0x933d5
movl -0x4c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x58(%rbp), %rdi
callq 0x57a90
movl %eax, %ecx
movl -0x6c(%rbp), %eax
cmpl %ecx, %eax
jg 0x9340c
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
jbe 0x9340a
movq -0x60(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
callq 0x56950
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x57920
jmp 0x9346c
movq -0x30(%rbp), %rax
movl -0x64(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jbe 0x9344f
movq -0x60(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
callq 0x56950
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x57920
movq -0x38(%rbp), %rax
movslq -0x44(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x60(%rbp), %rdi
callq 0x56b80
jmp 0x93384
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x572c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)