// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_pathinfo
static int jx9Builtin_pathinfo(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zPath;
	path_info sInfo;
	SyString *pComp;
	int 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;
	}
	/* 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;
	}
	/* Extract path info */
	ExtractPathInfo(zPath, iLen, &sInfo);
	if( nArg > 1 && jx9_value_is_int(apArg[1]) ){
		/* Return path component */
		int nComp = jx9_value_to_int(apArg[1]);
		switch(nComp){
		case 1: /* PATHINFO_DIRNAME */
			pComp = &sInfo.sDir;
			if( pComp->nByte > 0 ){
				jx9_result_string(pCtx, pComp->zString, (int)pComp->nByte);
			}else{
				/* Expand the empty string */
				jx9_result_string(pCtx, "", 0);
			}
			break;
		case 2: /*PATHINFO_BASENAME*/
			pComp = &sInfo.sBasename;
			if( pComp->nByte > 0 ){
				jx9_result_string(pCtx, pComp->zString, (int)pComp->nByte);
			}else{
				/* Expand the empty string */
				jx9_result_string(pCtx, "", 0);
			}
			break;
		case 3: /*PATHINFO_EXTENSION*/
			pComp = &sInfo.sExtension;
			if( pComp->nByte > 0 ){
				jx9_result_string(pCtx, pComp->zString, (int)pComp->nByte);
			}else{
				/* Expand the empty string */
				jx9_result_string(pCtx, "", 0);
			}
			break;
		case 4: /*PATHINFO_FILENAME*/
			pComp = &sInfo.sFilename;
			if( pComp->nByte > 0 ){
				jx9_result_string(pCtx, pComp->zString, (int)pComp->nByte);
			}else{
				/* Expand the empty string */
				jx9_result_string(pCtx, "", 0);
			}
			break;
		default:
			/* Expand the empty string */
			jx9_result_string(pCtx, "", 0);
			break;
		}
	}else{
		/* Return an associative array */
		jx9_value *pArray, *pValue;
		pArray = jx9_context_new_array(pCtx);
		pValue = jx9_context_new_scalar(pCtx);
		if( pArray == 0 || pValue == 0 ){
			/* Out of mem, return NULL */
			jx9_result_bool(pCtx, 0);
			return JX9_OK;
		}
		/* dirname */
		pComp = &sInfo.sDir;
		if( pComp->nByte > 0 ){
			jx9_value_string(pValue, pComp->zString, (int)pComp->nByte);
			/* Perform the insertion */
			jx9_array_add_strkey_elem(pArray, "dirname", pValue); /* Will make it's own copy */
		}
		/* Reset the string cursor */
		jx9_value_reset_string_cursor(pValue);
		/* basername */
		pComp = &sInfo.sBasename;
		if( pComp->nByte > 0 ){
			jx9_value_string(pValue, pComp->zString, (int)pComp->nByte);
			/* Perform the insertion */
			jx9_array_add_strkey_elem(pArray, "basename", pValue); /* Will make it's own copy */
		}
		/* Reset the string cursor */
		jx9_value_reset_string_cursor(pValue);
		/* extension */
		pComp = &sInfo.sExtension;
		if( pComp->nByte > 0 ){
			jx9_value_string(pValue, pComp->zString, (int)pComp->nByte);
			/* Perform the insertion */
			jx9_array_add_strkey_elem(pArray, "extension", pValue); /* Will make it's own copy */
		}
		/* Reset the string cursor */
		jx9_value_reset_string_cursor(pValue);
		/* filename */
		pComp = &sInfo.sFilename;
		if( pComp->nByte > 0 ){
			jx9_value_string(pValue, pComp->zString, (int)pComp->nByte);
			/* Perform the insertion */
			jx9_array_add_strkey_elem(pArray, "filename", pValue); /* Will make it's own copy */
		}
		/* Return the created array */
		jx9_result_value(pCtx, pArray);
		/* Don't worry about freeing memory, everything will be released
		 * automatically as soon we return from this foreign function.
		 */
	}
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
testl %esi, %esi
jle 0x52ea4
movq %rdx, %r14
movq (%rdx), %rdi
testb $0x1, 0x8(%rdi)
je 0x52ea4
movl %esi, %r15d
leaq -0x6c(%rbp), %r13
movq %r13, %rsi
callq 0x297ed
movslq (%r13), %r13
testq %r13, %r13
jle 0x52ea4
movq %rax, %r12
leaq -0x68(%rbp), %rdi
pushq $0x40
popq %rsi
callq 0x27aea
cmpl $0x1, %r13d
jne 0x52c65
cmpb $0x2f, (%r12)
jne 0x52c65
leaq 0x16937(%rip), %rax     # 0x6958c
movq %rax, -0x68(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0x52cfa
leaq (%r12,%r13), %rax
leaq (%r12,%r13), %rdx
decq %rdx
cmpq %r12, %rdx
jbe 0x52c87
leaq -0x1(%rdx), %rcx
cmpb $0x2f, (%rdx)
movq %rcx, %rdx
jne 0x52c70
addq $0x2, %rcx
jmp 0x52c8a
movq %r12, %rcx
movq %r12, -0x68(%rbp)
movq %rcx, %rdx
subq %r12, %rdx
movl %edx, -0x60(%rbp)
cmpl $0x2, %edx
jb 0x52cb5
movl %edx, %edx
decq %rdx
cmpq $-0x1, %rdx
je 0x52cce
movl %edx, %esi
cmpb $0x2f, (%r12,%rsi)
jne 0x52cce
movl %edx, -0x60(%rbp)
jmp 0x52c9e
cmpb $0x2f, (%r12)
jne 0x52cce
leaq 0x168c9(%rip), %rdx     # 0x6958c
movq %rdx, -0x68(%rbp)
movl $0x1, -0x60(%rbp)
movq %rcx, -0x58(%rbp)
subl %ecx, %eax
movl %eax, %edx
movl %eax, -0x50(%rbp)
subl $0x1, %edx
jb 0x52cf2
cmpb $0x2f, (%rcx)
jne 0x52e0a
incq %rcx
movq %rcx, -0x58(%rbp)
movl %edx, %eax
jmp 0x52cd6
movq %rcx, -0x38(%rbp)
andl $0x0, -0x30(%rbp)
cmpl $0x1, %r15d
je 0x52d0e
movq 0x8(%r14), %rdi
testb $0x2, 0x8(%rdi)
jne 0x52e51
movq %rbx, %rdi
callq 0x2a2b0
movq %rax, %r14
movq %rbx, %rdi
callq 0x2a26a
movq %rax, %r12
testq %r14, %r14
setne %al
testq %r12, %r12
setne %cl
testb %cl, %al
je 0x52dfb
movq %r12, %r15
movl -0x60(%rbp), %edx
testl %edx, %edx
je 0x52d60
movq -0x68(%rbp), %rsi
movq %r15, %rdi
callq 0x29588
leaq 0x1461c(%rip), %rsi     # 0x67371
movq %r14, %rdi
movq %r15, %rdx
callq 0x29c6c
addq $0x18, %r12
movq %r12, %rdi
callq 0x31b1e
movl -0x50(%rbp), %edx
testl %edx, %edx
je 0x52d91
movq -0x58(%rbp), %rsi
movq %r15, %rdi
callq 0x29588
leaq 0x145f3(%rip), %rsi     # 0x67379
movq %r14, %rdi
movq %r15, %rdx
callq 0x29c6c
movq %r12, %rdi
callq 0x31b1e
movl -0x40(%rbp), %edx
testl %edx, %edx
je 0x52dbe
movq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x29588
leaq 0x14823(%rip), %rsi     # 0x675d6
movq %r14, %rdi
movq %r15, %rdx
callq 0x29c6c
movq %r12, %rdi
callq 0x31b1e
movl -0x30(%rbp), %edx
testl %edx, %edx
je 0x52deb
movq -0x38(%rbp), %rsi
movq %r15, %rdi
callq 0x29588
leaq 0x14800(%rip), %rsi     # 0x675e0
movq %r14, %rdi
movq %r15, %rdx
callq 0x29c6c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x299d3
jmp 0x52eb5
movq %rbx, %rdi
xorl %esi, %esi
callq 0x298b2
jmp 0x52eb5
movq %rcx, -0x38(%rbp)
movl %eax, -0x30(%rbp)
leaq (%r12,%r13), %rsi
decq %rsi
xorl %edx, %edx
cmpq %rcx, %rsi
jbe 0x52cfa
incl %edx
leaq -0x1(%rsi), %rdi
cmpb $0x2e, (%rsi)
movq %rdi, %rsi
jne 0x52e1a
addq $0x2, %rdi
movq %rdi, -0x48(%rbp)
leal -0x1(%rdx), %ecx
movl %ecx, -0x40(%rbp)
cmpl %ecx, %eax
jbe 0x52cfa
subl %edx, %eax
movl %eax, -0x30(%rbp)
jmp 0x52cfa
callq 0x29772
decl %eax
cmpl $0x3, %eax
ja 0x52ea4
leaq 0xfcec(%rip), %rcx      # 0x62b50
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x60(%rbp), %edx
testl %edx, %edx
je 0x52ea4
movq -0x68(%rbp), %rsi
jmp 0x52e9f
movl -0x40(%rbp), %edx
testl %edx, %edx
je 0x52ea4
movq -0x48(%rbp), %rsi
jmp 0x52e9f
movl -0x30(%rbp), %edx
testl %edx, %edx
je 0x52ea4
movq -0x38(%rbp), %rsi
jmp 0x52e9f
movl -0x50(%rbp), %edx
testl %edx, %edx
je 0x52ea4
movq -0x58(%rbp), %rsi
movq %rbx, %rdi
jmp 0x52eb0
leaq 0x147a7(%rip), %rsi     # 0x67652
movq %rbx, %rdi
xorl %edx, %edx
callq 0x29903
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq