// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_trim
static int jx9Builtin_trim(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 bytes */
		SyStringInitFromBuf(&sStr, zString, nLen);
		SyStringFullTrimSafe(&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;
				}
			}
			/* Right trim */
			zEnd--;
			for(;;){
				if( zEnd <= zCur ){
					break;
				}
				zPtr = zEnd;
				for( i = 0 ; i < nListlen ; i++ ){
					if( zEnd > zCur && zEnd[0] == zList[i] ){
						zEnd--;
					}
				}
				if( zEnd == zPtr ){
					break;
				}
			}
			if( zCur >= zEnd ){
				/* Return the empty string */
				jx9_result_string(pCtx, "", 0);
			}else{
				zEnd++;
				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 0x934be
movq -0x10(%rbp), %rdi
callq 0x57120
movl $0x0, -0x4(%rbp)
jmp 0x937a3
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x28(%rbp)
cmpl $0x1, -0x2c(%rbp)
jge 0x934f6
movq -0x10(%rbp), %rdi
leaq 0x32668(%rip), %rsi     # 0xc5b4b
xorl %edx, %edx
callq 0x57180
movl $0x0, -0x4(%rbp)
jmp 0x937a3
cmpl $0x2, -0x14(%rbp)
jge 0x9362b
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 0x93568
movq -0x40(%rbp), %rax
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xc0, %ecx
movb %al, -0x6d(%rbp)
jge 0x93568
movq -0x40(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x6e(%rbp)
je 0x93562
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 0x93571
jmp 0x93588
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x9350e
jmp 0x9358a
xorl %eax, %eax
cmpl $0x0, -0x38(%rbp)
movb %al, -0x6f(%rbp)
jbe 0x935ff
movq -0x40(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0xc0, %ecx
movb %al, -0x6f(%rbp)
jge 0x935ff
movq -0x40(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x70(%rbp)
je 0x935f9
callq 0xd1f0
movq (%rax), %rax
movq -0x40(%rbp), %rcx
movl -0x38(%rbp), %edx
subl $0x1, %edx
movl %edx, %edx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x70(%rbp)
movb -0x70(%rbp), %al
movb %al, -0x6f(%rbp)
movb -0x6f(%rbp), %al
testb $0x1, %al
jne 0x93608
jmp 0x93616
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x9358a
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x38(%rbp), %edx
callq 0x57180
jmp 0x9379c
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x56e20
movq %rax, -0x48(%rbp)
cmpl $0x1, -0x4c(%rbp)
jge 0x9365b
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x57180
jmp 0x9379a
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 0x9367e
jmp 0x936dd
movq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x936cf
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x936c2
movq -0x60(%rbp), %rax
movsbl (%rax), %eax
movq -0x48(%rbp), %rcx
movslq -0x6c(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x936c2
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x936c4
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x9368d
movq -0x60(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x936db
jmp 0x936dd
jmp 0x93672
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
ja 0x936f5
jmp 0x93754
movq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x93746
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jbe 0x93739
movq -0x58(%rbp), %rax
movsbl (%rax), %eax
movq -0x48(%rbp), %rcx
movslq -0x6c(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x93739
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x9373b
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x93704
movq -0x58(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x93752
jmp 0x93754
jmp 0x936e9
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
jb 0x93772
movq -0x10(%rbp), %rdi
leaq 0x323e2(%rip), %rsi     # 0xc5b4b
xorl %edx, %edx
callq 0x57180
jmp 0x93798
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
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 0x9379a
jmp 0x9379c
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)