// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: vm_builtin_parse_url
static int vm_builtin_parse_url(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zStr; /* Input string */
	SyString *pComp;  /* Pointer to the URI component */
	SyhttpUri sURI;   /* Parse of the given URI */
	int nLen;
	sxi32 rc;
	if( nArg < 1 || !jx9_value_is_string(apArg[0]) ){
		/* Missing/Invalid arguments, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Extract the given URI */
	zStr = jx9_value_to_string(apArg[0], &nLen);
	if( nLen < 1 ){
		/* Nothing to process, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	/* Get a parse */
	rc = VmHttpSplitURI(&sURI, zStr, (sxu32)nLen);
	if( rc != SXRET_OK ){
		/* Malformed input, return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	if( nArg > 1 ){
		int nComponent = jx9_value_to_int(apArg[1]);
		/* Refer to constant.c for constants values */
		switch(nComponent){
		case 1: /* JX9_URL_SCHEME */
			pComp = &sURI.sScheme;
			if( pComp->nByte < 1 ){
				/* No available value, return NULL */
				jx9_result_null(pCtx);
			}else{
				jx9_result_string(pCtx, pComp->zString, (int)pComp->nByte);
			}
			break;
		case 2: /* JX9_URL_HOST */
			pComp = &sURI.sHost;
			if( pComp->nByte < 1 ){
				/* No available value, return NULL */
				jx9_result_null(pCtx);
			}else{
				jx9_result_string(pCtx, pComp->zString, (int)pComp->nByte);
			}
			break;
		case 3: /* JX9_URL_PORT */
			pComp = &sURI.sPort;
			if( pComp->nByte < 1 ){
				/* No available value, return NULL */
				jx9_result_null(pCtx);
			}else{
				int iPort = 0;
				/* Cast the value to integer */
				SyStrToInt32(pComp->zString, pComp->nByte, (void *)&iPort, 0);
				jx9_result_int(pCtx, iPort);
			}
			break;
		case 4: /* JX9_URL_USER */
			pComp = &sURI.sUser;
			if( pComp->nByte < 1 ){
				/* No available value, return NULL */
				jx9_result_null(pCtx);
			}else{
				jx9_result_string(pCtx, pComp->zString, (int)pComp->nByte);
			}
			break;
		case 5: /* JX9_URL_PASS */
			pComp = &sURI.sPass;
			if( pComp->nByte < 1 ){
				/* No available value, return NULL */
				jx9_result_null(pCtx);
			}else{
				jx9_result_string(pCtx, pComp->zString, (int)pComp->nByte);
			}
			break;
		case 7: /* JX9_URL_QUERY */
			pComp = &sURI.sQuery;
			if( pComp->nByte < 1 ){
				/* No available value, return NULL */
				jx9_result_null(pCtx);
			}else{
				jx9_result_string(pCtx, pComp->zString, (int)pComp->nByte);
			}
			break;
		case 8: /* JX9_URL_FRAGMENT */
			pComp = &sURI.sFragment;
			if( pComp->nByte < 1 ){
				/* No available value, return NULL */
				jx9_result_null(pCtx);
			}else{
				jx9_result_string(pCtx, pComp->zString, (int)pComp->nByte);
			}
			break;
		case 6: /*  JX9_URL_PATH */
			pComp = &sURI.sPath;
			if( pComp->nByte < 1 ){
				/* No available value, return NULL */
				jx9_result_null(pCtx);
			}else{
				jx9_result_string(pCtx, pComp->zString, (int)pComp->nByte);
			}
			break;
		default:
			/* No such entry, return NULL */
			jx9_result_null(pCtx);
			break;
		}
	}else{
		jx9_value *pArray, *pValue;
		/* Return an associative array */
		pArray = jx9_context_new_array(pCtx);  /* Empty array */
		pValue = jx9_context_new_scalar(pCtx); /* Array value */
		if( pArray == 0 || pValue == 0 ){
			/* Out of memory */
			jx9_context_throw_error(pCtx, JX9_CTX_ERR, "jx9 engine is running out of memory");
			/* Return false */
			jx9_result_bool(pCtx, 0);
			return JX9_OK;
		}
		/* Fill the array */
		pComp = &sURI.sScheme;
		if( pComp->nByte > 0 ){
			jx9_value_string(pValue, pComp->zString, (int)pComp->nByte);
			jx9_array_add_strkey_elem(pArray, "scheme", pValue); /* Will make it's own copy */
		}
		/* Reset the string cursor */
		jx9_value_reset_string_cursor(pValue);
		pComp = &sURI.sHost;
		if( pComp->nByte > 0 ){
			jx9_value_string(pValue, pComp->zString, (int)pComp->nByte);
			jx9_array_add_strkey_elem(pArray, "host", pValue); /* Will make it's own copy */
		}
		/* Reset the string cursor */
		jx9_value_reset_string_cursor(pValue);
		pComp = &sURI.sPort;
		if( pComp->nByte > 0 ){
			int iPort = 0;/* cc warning */
			/* Convert to integer */
			SyStrToInt32(pComp->zString, pComp->nByte, (void *)&iPort, 0);
			jx9_value_int(pValue, iPort);
			jx9_array_add_strkey_elem(pArray, "port", pValue); /* Will make it's own copy */
		}
		/* Reset the string cursor */
		jx9_value_reset_string_cursor(pValue);
		pComp = &sURI.sUser;
		if( pComp->nByte > 0 ){
			jx9_value_string(pValue, pComp->zString, (int)pComp->nByte);
			jx9_array_add_strkey_elem(pArray, "user", pValue); /* Will make it's own copy */
		}
		/* Reset the string cursor */
		jx9_value_reset_string_cursor(pValue);
		pComp = &sURI.sPass;
		if( pComp->nByte > 0 ){
			jx9_value_string(pValue, pComp->zString, (int)pComp->nByte);
			jx9_array_add_strkey_elem(pArray, "pass", pValue); /* Will make it's own copy */
		}
		/* Reset the string cursor */
		jx9_value_reset_string_cursor(pValue);
		pComp = &sURI.sPath;
		if( pComp->nByte > 0 ){
			jx9_value_string(pValue, pComp->zString, (int)pComp->nByte);
			jx9_array_add_strkey_elem(pArray, "path", pValue); /* Will make it's own copy */
		}
		/* Reset the string cursor */
		jx9_value_reset_string_cursor(pValue);
		pComp = &sURI.sQuery;
		if( pComp->nByte > 0 ){
			jx9_value_string(pValue, pComp->zString, (int)pComp->nByte);
			jx9_array_add_strkey_elem(pArray, "query", pValue); /* Will make it's own copy */
		}
		/* Reset the string cursor */
		jx9_value_reset_string_cursor(pValue);
		pComp = &sURI.sFragment;
		if( pComp->nByte > 0 ){
			jx9_value_string(pValue, pComp->zString, (int)pComp->nByte);
			jx9_array_add_strkey_elem(pArray, "fragment", pValue); /* Will make it's own copy */
		}
		/* Return the created array */
		jx9_result_value(pCtx, pArray);
		/* NOTE:
		 * Don't worry about freeing 'pValue', everything will be released
		 * automatically as soon we return from this function.
		 */
	}
	/* All done */
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpl $0x1, -0x14(%rbp)
jl 0x8b2dd
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
jne 0x8b2f4
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x8b928
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0xc4(%rbp), %rsi
callq 0x56e20
movq %rax, -0x28(%rbp)
cmpl $0x1, -0xc4(%rbp)
jge 0x8b32b
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x8b928
movq -0x28(%rbp), %rsi
movl -0xc4(%rbp), %edx
leaq -0xc0(%rbp), %rdi
callq 0x7c6d0
movl %eax, -0xc8(%rbp)
cmpl $0x0, -0xc8(%rbp)
je 0x8b367
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x8b928
cmpl $0x1, -0x14(%rbp)
jle 0x8b5d9
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x56c90
movl %eax, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0xf0(%rbp)
subl $0x7, %eax
ja 0x8b5cb
movq -0xf0(%rbp), %rax
leaq 0x35928(%rip), %rcx     # 0xc0cd4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0xc0(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jae 0x8b3d9
movq -0x10(%rbp), %rdi
callq 0x57120
jmp 0x8b3f0
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x57180
jmp 0x8b5d4
leaq -0xc0(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jae 0x8b415
movq -0x10(%rbp), %rdi
callq 0x57120
jmp 0x8b42c
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x57180
jmp 0x8b5d4
leaq -0xc0(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jae 0x8b455
movq -0x10(%rbp), %rdi
callq 0x57120
jmp 0x8b48c
movl $0x0, -0xd0(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %esi
leaq -0xd0(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x7c210
movq -0x10(%rbp), %rdi
movl -0xd0(%rbp), %esi
callq 0x56fb0
jmp 0x8b5d4
leaq -0xc0(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jae 0x8b4b5
movq -0x10(%rbp), %rdi
callq 0x57120
jmp 0x8b4cc
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x57180
jmp 0x8b5d4
leaq -0xc0(%rbp), %rax
addq $0x70, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jae 0x8b4f5
movq -0x10(%rbp), %rdi
callq 0x57120
jmp 0x8b50c
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x57180
jmp 0x8b5d4
leaq -0xc0(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jae 0x8b535
movq -0x10(%rbp), %rdi
callq 0x57120
jmp 0x8b54c
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x57180
jmp 0x8b5d4
leaq -0xc0(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jae 0x8b575
movq -0x10(%rbp), %rdi
callq 0x57120
jmp 0x8b58c
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x57180
jmp 0x8b5d4
leaq -0xc0(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jae 0x8b5b2
movq -0x10(%rbp), %rdi
callq 0x57120
jmp 0x8b5c9
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x57180
jmp 0x8b5d4
movq -0x10(%rbp), %rdi
callq 0x57120
jmp 0x8b921
movq -0x10(%rbp), %rdi
callq 0x58570
movq %rax, -0xd8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x58510
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xd8(%rbp)
je 0x8b60d
cmpq $0x0, -0xe0(%rbp)
jne 0x8b639
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x39269(%rip), %rdx     # 0xc4886
callq 0x580b0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x57070
movl $0x0, -0x4(%rbp)
jmp 0x8b928
leaq -0xc0(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jbe 0x8b686
movq -0xe0(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x56950
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x375f7(%rip), %rsi     # 0xc2c78
callq 0x579b0
movq -0xe0(%rbp), %rdi
callq 0x56b80
leaq -0xc0(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jbe 0x8b6db
movq -0xe0(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x56950
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x391d4(%rip), %rsi     # 0xc48aa
callq 0x579b0
movq -0xe0(%rbp), %rdi
callq 0x56b80
leaq -0xc0(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jbe 0x8b754
movl $0x0, -0xe4(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %esi
leaq -0xe4(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x7c210
movq -0xe0(%rbp), %rdi
movl -0xe4(%rbp), %esi
callq 0x56700
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x3b5b7(%rip), %rsi     # 0xc6d06
callq 0x579b0
movq -0xe0(%rbp), %rdi
callq 0x56b80
leaq -0xc0(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jbe 0x8b7ad
movq -0xe0(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x56950
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x3b581(%rip), %rsi     # 0xc6d29
callq 0x579b0
movq -0xe0(%rbp), %rdi
callq 0x56b80
leaq -0xc0(%rbp), %rax
addq $0x70, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jbe 0x8b806
movq -0xe0(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x56950
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x390ae(%rip), %rsi     # 0xc48af
callq 0x579b0
movq -0xe0(%rbp), %rdi
callq 0x56b80
leaq -0xc0(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jbe 0x8b85f
movq -0xe0(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x56950
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x3a299(%rip), %rsi     # 0xc5af3
callq 0x579b0
movq -0xe0(%rbp), %rdi
callq 0x56b80
leaq -0xc0(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jbe 0x8b8b8
movq -0xe0(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x56950
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x39001(%rip), %rsi     # 0xc48b4
callq 0x579b0
movq -0xe0(%rbp), %rdi
callq 0x56b80
leaq -0xc0(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jbe 0x8b911
movq -0xe0(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x56950
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x38fae(%rip), %rsi     # 0xc48ba
callq 0x579b0
movq -0x10(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x572c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)