// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa0, %rsp
movq %rdi, %rbx
testl %esi, %esi
jle 0x4ffd5
movq %rdx, %r14
movq (%rdx), %rdi
testb $0x1, 0x8(%rdi)
je 0x4ffd5
movl %esi, %r15d
leaq -0x28(%rbp), %r12
movq %r12, %rsi
callq 0x30577
movl (%r12), %edx
testl %edx, %edx
jle 0x4ffd5
leaq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x46ee0
testl %eax, %eax
je 0x50008
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
movq $0x0, (%rbx)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%rbx), %eax
orl $0x8, %eax
movl %eax, 0x8(%rbx)
xorl %eax, %eax
addq $0xa0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1, %r15d
jne 0x502c5
movq %rbx, %rdi
callq 0x31231
movq %rax, %r14
movq %rbx, %rdi
callq 0x311eb
movq %rax, %r15
testq %r14, %r14
setne %al
testq %r15, %r15
setne %cl
testb %cl, %al
je 0x50303
movl -0x60(%rbp), %edx
testl %edx, %edx
je 0x50061
movq -0x68(%rbp), %rsi
movq %r15, %rdi
callq 0x302f6
leaq 0x24751(%rip), %rsi     # 0x747a7
movq %r14, %rdi
movq %r15, %rdx
callq 0x30ad3
movl $0x0, 0x28(%r15)
movl 0x30(%r15), %eax
testb $0x4, %al
je 0x50088
movq $0x0, 0x20(%r15)
movl $0x0, 0x2c(%r15)
andl $-0x5, %eax
movl %eax, 0x30(%r15)
movl -0xb0(%rbp), %edx
testl %edx, %edx
je 0x500b7
movq -0xb8(%rbp), %rsi
movq %r15, %rdi
callq 0x302f6
leaq 0x26321(%rip), %rsi     # 0x763c9
movq %r14, %rdi
movq %r15, %rdx
callq 0x30ad3
movl 0x30(%r15), %eax
movl $0x0, 0x28(%r15)
testb $0x4, %al
je 0x500da
movq $0x0, 0x20(%r15)
movl $0x0, 0x2c(%r15)
andl $-0x5, %eax
movl %eax, 0x30(%r15)
movl -0xa0(%rbp), %esi
testl %esi, %esi
je 0x50134
leaq -0x24(%rbp), %r12
movl $0x0, (%r12)
movq -0xa8(%rbp), %rdi
movq %r12, %rdx
callq 0x46bae
movslq (%r12), %r12
movq %r15, %rdi
callq 0x30465
movq %r12, (%r15)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%r15), %eax
orl $0x2, %eax
movl %eax, 0x8(%r15)
leaq 0x282fa(%rip), %rsi     # 0x7841f
movq %r14, %rdi
movq %r15, %rdx
callq 0x30ad3
movl 0x30(%r15), %eax
movl $0x0, 0x28(%r15)
testb $0x4, %al
je 0x50157
movq $0x0, 0x20(%r15)
movl $0x0, 0x2c(%r15)
andl $-0x5, %eax
movl %eax, 0x30(%r15)
movl -0x50(%rbp), %edx
testl %edx, %edx
je 0x50180
movq -0x58(%rbp), %rsi
movq %r15, %rdi
callq 0x302f6
leaq 0x282d1(%rip), %rsi     # 0x78442
movq %r14, %rdi
movq %r15, %rdx
callq 0x30ad3
movl 0x30(%r15), %eax
movl $0x0, 0x28(%r15)
testb $0x4, %al
je 0x501a3
movq $0x0, 0x20(%r15)
movl $0x0, 0x2c(%r15)
andl $-0x5, %eax
movl %eax, 0x30(%r15)
movl -0x40(%rbp), %edx
testl %edx, %edx
je 0x501cc
movq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x302f6
leaq 0x26211(%rip), %rsi     # 0x763ce
movq %r14, %rdi
movq %r15, %rdx
callq 0x30ad3
movl 0x30(%r15), %eax
movl $0x0, 0x28(%r15)
testb $0x4, %al
je 0x501ef
movq $0x0, 0x20(%r15)
movl $0x0, 0x2c(%r15)
andl $-0x5, %eax
movl %eax, 0x30(%r15)
movl -0x90(%rbp), %edx
testl %edx, %edx
je 0x5021e
movq -0x98(%rbp), %rsi
movq %r15, %rdi
callq 0x302f6
leaq 0x2740b(%rip), %rsi     # 0x7761a
movq %r14, %rdi
movq %r15, %rdx
callq 0x30ad3
movl 0x30(%r15), %eax
movl $0x0, 0x28(%r15)
testb $0x4, %al
je 0x50241
movq $0x0, 0x20(%r15)
movl $0x0, 0x2c(%r15)
andl $-0x5, %eax
movl %eax, 0x30(%r15)
movl -0x80(%rbp), %edx
testl %edx, %edx
je 0x5026d
movq -0x88(%rbp), %rsi
movq %r15, %rdi
callq 0x302f6
leaq 0x26175(%rip), %rsi     # 0x763d3
movq %r14, %rdi
movq %r15, %rdx
callq 0x30ad3
movl 0x30(%r15), %eax
movl $0x0, 0x28(%r15)
testb $0x4, %al
je 0x50290
movq $0x0, 0x20(%r15)
movl $0x0, 0x2c(%r15)
andl $-0x5, %eax
movl %eax, 0x30(%r15)
movl -0x70(%rbp), %edx
testl %edx, %edx
je 0x502b5
movq -0x78(%rbp), %rsi
movq %r15, %rdi
callq 0x302f6
leaq 0x2612f(%rip), %rsi     # 0x763d9
movq %r14, %rdi
movq %r15, %rdx
callq 0x30ad3
movq %rbx, %rdi
movq %r14, %rsi
callq 0x307f4
jmp 0x4fff6
movq 0x8(%r14), %r14
movq %r14, %rdi
callq 0x3f362
movl (%r14), %eax
decl %eax
cmpl $0x7, %eax
ja 0x503de
leaq 0x22552(%rip), %rcx     # 0x72838
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x60(%rbp), %edx
testl %edx, %edx
je 0x503de
movq -0x68(%rbp), %rsi
jmp 0x503d0
movq (%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
leaq 0x26090(%rip), %rcx     # 0x763a5
movl $0x1, %edx
callq 0x40afa
jmp 0x4ffd5
movl -0x40(%rbp), %edx
testl %edx, %edx
je 0x503de
movq -0x48(%rbp), %rsi
jmp 0x503d0
movl -0xa0(%rbp), %esi
testl %esi, %esi
je 0x503de
leaq -0x24(%rbp), %r14
movl $0x0, (%r14)
movq -0xa8(%rbp), %rdi
movq %r14, %rdx
callq 0x46bae
movslq (%r14), %r14
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
movq %r14, (%rbx)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%rbx), %eax
orl $0x2, %eax
jmp 0x4fff3
movl -0x50(%rbp), %edx
testl %edx, %edx
je 0x503de
movq -0x58(%rbp), %rsi
jmp 0x503d0
movl -0x70(%rbp), %edx
testl %edx, %edx
je 0x503de
movq -0x78(%rbp), %rsi
jmp 0x503d0
movl -0xb0(%rbp), %edx
testl %edx, %edx
je 0x503de
movq -0xb8(%rbp), %rsi
jmp 0x503d0
movl -0x90(%rbp), %edx
testl %edx, %edx
je 0x503de
movq -0x98(%rbp), %rsi
jmp 0x503d0
movl -0x80(%rbp), %edx
testl %edx, %edx
je 0x503de
movq -0x88(%rbp), %rsi
movq 0x8(%rbx), %rdi
callq 0x302f6
jmp 0x4fff6
movq 0x8(%rbx), %rdi
callq 0x30465
jmp 0x4fff6