// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_ltrim
static int jx9Builtin_ltrim(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zString;
	int nLen;
	if( nArg < 1 ){
		/* Missing arguments, return null */
		jx9_result_null(pCtx);
		return JX9_OK;
	}
	/* Extract the target string */
	zString = jx9_value_to_string(apArg[0], &nLen);
	if( nLen < 1 ){
		/* Empty string, return */
		jx9_result_string(pCtx, "", 0);
		return JX9_OK;
	}
	/* Start the trim process */
	if( nArg < 2 ){
		SyString sStr;
		/* Remove white spaces and NUL byte */
		SyStringInitFromBuf(&sStr, zString, nLen);
		SyStringLeftTrimSafe(&sStr);
		jx9_result_string(pCtx, sStr.zString, (int)sStr.nByte);
	}else{
		/* Char list */
		const char *zList;
		int nListlen;
		zList = jx9_value_to_string(apArg[1], &nListlen);
		if( nListlen < 1 ){
			/* Return the string unchanged */
			jx9_result_string(pCtx, zString, nLen);
		}else{
			const char *zEnd = &zString[nLen];
			const char *zCur = zString;
			const char *zPtr;
			int i;
			/* Left trim */
			for(;;){
				if( zCur >= zEnd ){
					break;
				}
				zPtr = zCur;
				for( i = 0 ; i < nListlen ; i++ ){
					if( zCur < zEnd && zCur[0] == zList[i] ){
						zCur++;
					}
				}
				if( zCur == zPtr ){
					/* No match, break immediately */
					break;
				}
			}
			if( zCur >= zEnd ){
				/* Return the empty string */
				jx9_result_string(pCtx, "", 0);
			}else{
				jx9_result_string(pCtx, zCur, (int)(zEnd-zCur));
			}
		}
	}
	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 $0x1, -0x14(%rbp)
jge 0x93a0e
movq -0x10(%rbp), %rdi
callq 0x57120
movl $0x0, -0x4(%rbp)
jmp 0x93be2
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x28(%rbp)
cmpl $0x1, -0x2c(%rbp)
jge 0x93a46
movq -0x10(%rbp), %rdi
leaq 0x32118(%rip), %rsi     # 0xc5b4b
xorl %edx, %edx
callq 0x57180
movl $0x0, -0x4(%rbp)
jmp 0x93be2
cmpl $0x2, -0x14(%rbp)
jge 0x93aed
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x38(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x38(%rbp)
movb %al, -0x6d(%rbp)
jbe 0x93ab8
movq -0x40(%rbp), %rax
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xc0, %ecx
movb %al, -0x6d(%rbp)
jge 0x93ab8
movq -0x40(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x6e(%rbp)
je 0x93ab2
callq 0xd1f0
movq (%rax), %rax
movq -0x40(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x6e(%rbp)
movb -0x6e(%rbp), %al
movb %al, -0x6d(%rbp)
movb -0x6d(%rbp), %al
testb $0x1, %al
jne 0x93ac1
jmp 0x93ad8
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x93a5e
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x38(%rbp), %edx
callq 0x57180
jmp 0x93bdb
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x48(%rbp)
cmpl $0x1, -0x4c(%rbp)
jge 0x93b1d
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x57180
jmp 0x93bd9
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
jb 0x93b40
jmp 0x93b9f
movq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x93b91
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x93b84
movq -0x60(%rbp), %rax
movsbl (%rax), %eax
movq -0x48(%rbp), %rcx
movslq -0x6c(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x93b84
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x93b86
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x93b4f
movq -0x60(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x93b9d
jmp 0x93b9f
jmp 0x93b34
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
jb 0x93bbd
movq -0x10(%rbp), %rdi
leaq 0x31f97(%rip), %rsi     # 0xc5b4b
xorl %edx, %edx
callq 0x57180
jmp 0x93bd7
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rax
movq -0x60(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
callq 0x57180
jmp 0x93bd9
jmp 0x93bdb
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)