// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rdi, %r14
testl %esi, %esi
jle 0x6202a
movq %rdx, %r15
movq (%rdx), %rdi
testb $0x1, 0x8(%rdi)
je 0x6202a
movl %esi, %r13d
leaq -0x54(%rbp), %rbx
movq %rbx, %rsi
callq 0x30b04
movslq (%rbx), %rdx
testq %rdx, %rdx
jle 0x6202a
movq %r14, -0x30(%rbp)
cmpl $0x1, %edx
jne 0x6204d
cmpb $0x2f, (%rax)
jne 0x6204d
leaq 0x195a2(%rip), %rax     # 0x7b5ac
movq %rax, -0x38(%rbp)
movl $0x1, %r12d
xorl %ebx, %ebx
movq $0x0, -0x40(%rbp)
xorl %edx, %edx
xorl %r14d, %r14d
xorl %edi, %edi
jmp 0x6212b
movq 0x8(%r14), %rdi
leaq 0x17632(%rip), %rsi     # 0x79667
xorl %edx, %edx
callq 0x3087c
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%rdx,%rax), %rcx
decq %rcx
cmpq %rax, %rcx
jbe 0x6206b
leaq -0x1(%rcx), %r14
cmpb $0x2f, (%rcx)
movq %r14, %rcx
jne 0x62054
addq $0x2, %r14
jmp 0x6206e
movq %rax, %r14
leaq (%rax,%rdx), %rcx
movq %r14, %r12
subq %rax, %r12
cmpl $0x2, %r12d
jb 0x620a6
leal -0x1(%r12), %esi
cmpb $0x2f, (%rax,%rsi)
jne 0x620cc
movq %r12, %rsi
addq $-0x2, %rsi
cmpl $0x1, %r12d
je 0x620c9
movl %esi, %edi
decq %rsi
decl %r12d
cmpb $0x2f, (%rax,%rdi)
je 0x62090
jmp 0x620cc
cmpb $0x2f, (%rax)
movl $0x1, %esi
cmovnel %r12d, %esi
leaq 0x194f3(%rip), %rdi     # 0x7b5ac
movq %rax, %r8
cmoveq %rdi, %r8
movq %r8, -0x38(%rbp)
movl %esi, %r12d
jmp 0x620d0
xorl %r12d, %r12d
movq %rax, -0x38(%rbp)
movl %ecx, %ebx
subl %r14d, %ebx
sete %sil
je 0x62114
cmpb $0x2f, (%r14)
jne 0x62112
addl %edx, %eax
movl %r14d, %edx
notl %edx
addl %eax, %edx
xorl %eax, %eax
xorl %r8d, %r8d
movq %r8, %rdi
decl %ebx
cmpl %edi, %edx
sete %sil
je 0x6210a
leaq 0x1(%rdi), %r8
cmpb $0x2f, 0x1(%r14,%rdi)
je 0x620ef
movl %ebx, %eax
addq %rdi, %r14
incq %r14
jmp 0x62116
xorl %esi, %esi
movl %ebx, %eax
movl %eax, %edi
testb %sil, %sil
je 0x62296
movq $0x0, -0x40(%rbp)
xorl %edx, %edx
movq %rdx, -0x48(%rbp)
movq %rdi, -0x50(%rbp)
cmpl $0x1, %r13d
je 0x62148
movq 0x8(%r15), %r15
testb $0x2, 0x8(%r15)
jne 0x622f5
movq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0x317eb
movq %rax, %r13
movq %r15, %rdi
callq 0x317a5
movq %r13, %rdx
testq %r13, %r13
movq %rax, %r13
setne %al
testq %r13, %r13
setne %cl
testb %cl, %al
je 0x622cf
testl %r12d, %r12d
movq %rdx, %r15
je 0x621a2
movq %r13, %rdi
movq -0x38(%rbp), %rsi
movl %r12d, %edx
callq 0x3087c
leaq 0x171ef(%rip), %rsi     # 0x79386
movq %r15, %rdi
movq %r13, %rdx
callq 0x3106a
movl $0x0, 0x28(%r13)
movl 0x30(%r13), %eax
testb $0x4, %al
je 0x621c9
movq $0x0, 0x20(%r13)
movl $0x0, 0x2c(%r13)
andl $-0x5, %eax
movl %eax, 0x30(%r13)
testl %ebx, %ebx
je 0x621ec
movq %r13, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x3087c
leaq 0x171ad(%rip), %rsi     # 0x7938e
movq %r15, %rdi
movq %r13, %rdx
callq 0x3106a
movl $0x0, 0x28(%r13)
movl 0x30(%r13), %eax
testb $0x4, %al
je 0x62213
movq $0x0, 0x20(%r13)
movl $0x0, 0x2c(%r13)
andl $-0x5, %eax
movl %eax, 0x30(%r13)
movq -0x48(%rbp), %rdx
testl %edx, %edx
je 0x62239
movq %r13, %rdi
movq -0x40(%rbp), %rsi
callq 0x3087c
leaq 0x173bd(%rip), %rsi     # 0x795eb
movq %r15, %rdi
movq %r13, %rdx
callq 0x3106a
movl $0x0, 0x28(%r13)
movl 0x30(%r13), %eax
testb $0x4, %al
je 0x62260
movq $0x0, 0x20(%r13)
movl $0x0, 0x2c(%r13)
andl $-0x5, %eax
movl %eax, 0x30(%r13)
movq -0x50(%rbp), %rdx
testl %edx, %edx
je 0x62285
movq %r13, %rdi
movq %r14, %rsi
callq 0x3087c
leaq 0x1737b(%rip), %rsi     # 0x795f5
movq %r15, %rdi
movq %r13, %rdx
callq 0x3106a
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x30d83
jmp 0x6203c
xorl %eax, %eax
leaq (%rcx,%rax), %rdx
decq %rdx
cmpq %r14, %rdx
jbe 0x62121
decq %rax
cmpb $0x2e, (%rdx)
jne 0x62298
movq %rax, %rdx
notq %rdx
addq %rax, %rcx
incq %rcx
movq %rcx, -0x40(%rbp)
cmpl %edx, %edi
jbe 0x6212b
addl %eax, %edi
jmp 0x6212b
movq 0x8(%r15), %rbx
movq %rbx, %rdi
callq 0x309f2
movq $0x0, (%rbx)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%rbx), %eax
orl $0x8, %eax
movl %eax, 0x8(%rbx)
jmp 0x6203c
movq %r15, %rdi
callq 0x3fd5f
movl (%r15), %eax
decl %eax
cmpl $0x3, %eax
ja 0x62384
leaq 0x12852(%rip), %rcx     # 0x74b60
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
testl %r12d, %r12d
je 0x6202e
movq -0x38(%rbp), %rsi
movl %r12d, %edx
jmp 0x62037
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x48(%rbp), %rdx
testl %edx, %edx
je 0x6202e
movq -0x40(%rbp), %rsi
jmp 0x62365
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x50(%rbp), %rdx
testl %edx, %edx
je 0x6202e
movq %r14, %rsi
jmp 0x62037
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
testl %ebx, %ebx
je 0x6202e
movq %r14, %rsi
movl %ebx, %edx
jmp 0x62037
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
jmp 0x6202e