// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_basename
static int jx9Builtin_basename(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zPath, *zBase, *zEnd;
	int c, d, iLen;
	if( nArg < 1 || !jx9_value_is_string(apArg[0]) ){
		/* Missing/Invalid argument, return the empty string */
		jx9_result_string(pCtx, "", 0);
		return JX9_OK;
	}
	c = d = '/';
#ifdef __WINNT__
	d = '\\';
#endif
	/* Point to the target path */
	zPath = jx9_value_to_string(apArg[0], &iLen);
	if( iLen < 1 ){
		/* Empty string */
		jx9_result_string(pCtx, "", 0);
		return JX9_OK;
	}
	/* Perform the requested operation */
	zEnd = &zPath[iLen - 1];
	/* Ignore trailing '/' */
	while( zEnd > zPath && ( (int)zEnd[0] == c || (int)zEnd[0] == d ) ){
		zEnd--;
	}
	iLen = (int)(&zEnd[1]-zPath);
	while( zEnd > zPath && ( (int)zEnd[0] != c && (int)zEnd[0] != d ) ){
		zEnd--;
	}
	zBase = (zEnd > zPath) ? &zEnd[1] : zPath;
	zEnd = &zPath[iLen];
	if( nArg > 1 && jx9_value_is_string(apArg[1]) ){
		const char *zSuffix;
		int nSuffix;
		/* Strip suffix */
		zSuffix = jx9_value_to_string(apArg[1], &nSuffix);
		if( nSuffix > 0 && nSuffix < iLen && SyMemcmp(&zEnd[-nSuffix], zSuffix, nSuffix) == 0 ){
			zEnd -= nSuffix;
		}
	}
	/* Store the basename */
	jx9_result_string(pCtx, zBase, (int)(zEnd-zBase));
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpl $0x1, -0x14(%rbp)
jl 0xa40ea
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
jne 0xa4108
movq -0x10(%rbp), %rdi
leaq 0x21a56(%rip), %rsi     # 0xc5b4b
xorl %edx, %edx
callq 0x57180
movl $0x0, -0x4(%rbp)
jmp 0xa42d8
movl $0x2f, -0x40(%rbp)
movl $0x2f, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x44(%rbp), %rsi
callq 0x56e20
movq %rax, -0x28(%rbp)
cmpl $0x1, -0x44(%rbp)
jge 0xa414e
movq -0x10(%rbp), %rdi
leaq 0x21a10(%rip), %rsi     # 0xc5b4b
xorl %edx, %edx
callq 0x57180
movl $0x0, -0x4(%rbp)
jmp 0xa42d8
movq -0x28(%rbp), %rax
movl -0x44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
xorl %eax, %eax
cmpq -0x28(%rbp), %rcx
movb %al, -0x55(%rbp)
jbe 0xa4198
movq -0x38(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl -0x3c(%rbp), %ecx
movb %al, -0x56(%rbp)
je 0xa4192
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl -0x40(%rbp), %eax
sete %al
movb %al, -0x56(%rbp)
movb -0x56(%rbp), %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %al
testb $0x1, %al
jne 0xa41a1
jmp 0xa41af
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xa4162
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x44(%rbp)
movq -0x38(%rbp), %rcx
xorl %eax, %eax
cmpq -0x28(%rbp), %rcx
movb %al, -0x57(%rbp)
jbe 0xa41f7
movq -0x38(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl -0x3c(%rbp), %ecx
movb %al, -0x58(%rbp)
je 0xa41f1
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl -0x40(%rbp), %eax
setne %al
movb %al, -0x58(%rbp)
movb -0x58(%rbp), %al
movb %al, -0x57(%rbp)
movb -0x57(%rbp), %al
testb $0x1, %al
jne 0xa4200
jmp 0xa420e
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xa41c1
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jbe 0xa4226
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0xa422e
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
cmpl $0x1, -0x14(%rbp)
jle 0xa42b7
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
je 0xa42b7
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x54(%rbp), %rsi
callq 0x56e20
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x54(%rbp)
jle 0xa42b5
movl -0x54(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0xa42b5
movq -0x38(%rbp), %rdi
xorl %eax, %eax
subl -0x54(%rbp), %eax
cltq
addq %rax, %rdi
movq -0x50(%rbp), %rsi
movl -0x54(%rbp), %edx
callq 0x5d3c0
cmpl $0x0, %eax
jne 0xa42b5
movl -0x54(%rbp), %ecx
movq -0x38(%rbp), %rax
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0xa42b7
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
callq 0x57180
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)