// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: VmHttpSplitURI
static sxi32 VmHttpSplitURI(SyhttpUri *pOut, const char *zUri, sxu32 nLen)
 {
	 const char *zEnd = &zUri[nLen];
	 sxu8 bHostOnly = FALSE;
	 sxu8 bIPv6 = FALSE	; 
	 const char *zCur;
	 SyString *pComp;
	 sxu32 nPos = 0;
	 sxi32 rc;
	 /* Zero the structure first */
	 SyZero(pOut, sizeof(SyhttpUri));
	 /* Remove leading and trailing white spaces  */
	 SyStringInitFromBuf(&pOut->sRaw, zUri, nLen);
	 SyStringFullTrim(&pOut->sRaw);
	 /* Find the first '/' separator */
	 rc = SyByteFind(zUri, (sxu32)(zEnd - zUri), '/', &nPos);
	 if( rc != SXRET_OK ){
		 /* Assume a host name only */
		 zCur = zEnd;
		 bHostOnly = TRUE;
		 goto ProcessHost;
	 }
	 zCur = &zUri[nPos];
	 if( zUri != zCur && zCur[-1] == ':' ){
		 /* Extract a scheme:
		  * Not that we can get an invalid scheme here.
		  * Fortunately the caller can discard any URI by comparing this scheme with its 
		  * registered schemes and will report the error as soon as his comparison function
		  * fail.
		  */
	 	pComp = &pOut->sScheme;
		SyStringInitFromBuf(pComp, zUri, (sxu32)(zCur - zUri - 1));
		SyStringLeftTrim(pComp);		
	 }
	 if( zCur[1] != '/' ){
		 if( zCur == zUri || zCur[-1] == ':' ){
		  /* No authority */
		  goto PathSplit;
		}
		 /* There is something here , we will assume its an authority
		  * and someone has forgot the two prefix slashes "//", 
		  * sooner or later we will detect if we are dealing with a malicious
		  * user or not, but now assume we are dealing with an authority
		  * and let the caller handle all the validation process.
		  */
		 goto ProcessHost;
	 }	 
	 zUri = &zCur[2];
	 zCur = zEnd;
	 rc = SyByteFind(zUri, (sxu32)(zEnd - zUri), '/', &nPos);
	 if( rc == SXRET_OK ){
		 zCur = &zUri[nPos];
	 }
 ProcessHost:
	 /* Extract user information if present */
	 rc = SyByteFind(zUri, (sxu32)(zCur - zUri), '@', &nPos);
	 if( rc == SXRET_OK ){
		 if( nPos > 0 ){
			 sxu32 nPassOfft; /* Password offset */
			 pComp = &pOut->sUser;
			 SyStringInitFromBuf(pComp, zUri, nPos);
			 /* Extract the password if available */
			 rc = SyByteFind(zUri, (sxu32)(zCur - zUri), ':', &nPassOfft);
			 if( rc == SXRET_OK && nPassOfft < nPos){
				 pComp->nByte = nPassOfft;
				 pComp = &pOut->sPass;
				 pComp->zString = &zUri[nPassOfft+sizeof(char)];
				 pComp->nByte = nPos - nPassOfft - 1;
			 }
			 /* Update the cursor */
			 zUri = &zUri[nPos+1];
		 }else{
			 zUri++;
		 }
	 }
	 pComp = &pOut->sHost;
	 while( zUri < zCur && SyisSpace(zUri[0])){
		 zUri++;
	 }	
	 SyStringInitFromBuf(pComp, zUri, (sxu32)(zCur - zUri));
	 if( pComp->zString[0] == '[' ){
		 /* An IPv6 Address: Make a simple naive test
		  */
		 zUri++; pComp->zString++; pComp->nByte = 0;
		 while( ((unsigned char)zUri[0] < 0xc0 && SyisHex(zUri[0])) || zUri[0] == ':' ){
			 zUri++; pComp->nByte++;
		 }
		 if( zUri[0] != ']' ){
			 return SXERR_CORRUPT; /* Malformed IPv6 address */
		 }
		 zUri++;
		 bIPv6 = TRUE;
	 }
	 /* Extract a port number if available */
	 rc = SyByteFind(zUri, (sxu32)(zCur - zUri), ':', &nPos);
	 if( rc == SXRET_OK ){
		 if( bIPv6 == FALSE ){
			 pComp->nByte = (sxu32)(&zUri[nPos] - zUri);
		 }
		 pComp = &pOut->sPort;
		 SyStringInitFromBuf(pComp, &zUri[nPos+1], (sxu32)(zCur - &zUri[nPos+1]));	
	 }
	 if( bHostOnly == TRUE ){
		 return SXRET_OK;
	 }
PathSplit:
	 zUri = zCur;
	 pComp = &pOut->sPath;
	 SyStringInitFromBuf(pComp, zUri, (sxu32)(zEnd-zUri));
	 if( pComp->nByte == 0 ){
		 return SXRET_OK; /* Empty path */
	 }
	 if( SXRET_OK == SyByteFind(zUri, (sxu32)(zEnd-zUri), '?', &nPos) ){
		 pComp->nByte = nPos; /* Update path length */
		 pComp = &pOut->sQuery;
		 SyStringInitFromBuf(pComp, &zUri[nPos+1], (sxu32)(zEnd-&zUri[nPos+1]));
	 }
	 if( SXRET_OK == SyByteFind(zUri, (sxu32)(zEnd-zUri), '#', &nPos) ){
		 /* Update path or query length */
		 if( pComp == &pOut->sPath ){
			 pComp->nByte = nPos;
		 }else{
			 if( &zUri[nPos] < (char *)SyStringData(pComp) ){
				 /* Malformed syntax : Query must be present before fragment */
				 return SXERR_SYNTAX;
			 }
			 pComp->nByte -= (sxu32)(zEnd - &zUri[nPos]);
		 }
		 pComp = &pOut->sFragment;
		 SyStringInitFromBuf(pComp, &zUri[nPos+1], (sxu32)(zEnd-&zUri[nPos+1]))
	 }
	 return SXRET_OK;
 }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
movb $0x0, -0x2a(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x10(%rbp), %rdi
movl $0x90, %esi
callq 0x54280
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x80(%rax)
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x88(%rax)
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x88(%rcx)
movb %al, -0x4d(%rbp)
jbe 0x7c782
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xc0, %ecx
movb %al, -0x4d(%rbp)
jge 0x7c782
callq 0xd1f0
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x80(%rcx), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x4d(%rbp)
movb -0x4d(%rbp), %al
testb $0x1, %al
jne 0x7c78b
jmp 0x7c7b9
movq -0x10(%rbp), %rax
movl 0x88(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x88(%rax)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x80(%rax)
jmp 0x7c72a
jmp 0x7c7bb
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x88(%rcx)
movb %al, -0x4e(%rbp)
jbe 0x7c833
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x88(%rcx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0xc0, %ecx
movb %al, -0x4e(%rbp)
jge 0x7c833
callq 0xd1f0
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x80(%rcx), %rcx
movq -0x10(%rbp), %rdx
movl 0x88(%rdx), %edx
subl $0x1, %edx
movl %edx, %edx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x4e(%rbp)
movb -0x4e(%rbp), %al
testb $0x1, %al
jne 0x7c83c
jmp 0x7c854
movq -0x10(%rbp), %rax
movl 0x88(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x88(%rax)
jmp 0x7c7bb
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
movl $0x2f, %edx
leaq -0x44(%rbp), %rcx
callq 0x7d040
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x7c88d
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movb $0x1, -0x29(%rbp)
jmp 0x7c9d5
movq -0x18(%rbp), %rax
movl -0x44(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x7c95e
movq -0x38(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x3a, %eax
jne 0x7c95e
movq -0x10(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
subq $0x1, %rax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x40(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x8(%rcx)
movb %al, -0x4f(%rbp)
jbe 0x7c936
movq -0x40(%rbp), %rax
movq (%rax), %rax
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xc0, %ecx
movb %al, -0x4f(%rbp)
jge 0x7c936
callq 0xd1f0
movq (%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x4f(%rbp)
movb -0x4f(%rbp), %al
testb $0x1, %al
jne 0x7c93f
jmp 0x7c95c
movq -0x40(%rbp), %rax
movl 0x8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0x7c8e9
jmp 0x7c95e
movq -0x38(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2f, %eax
je 0x7c989
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
je 0x7c982
movq -0x38(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x3a, %eax
jne 0x7c987
jmp 0x7cc96
jmp 0x7c9d5
movq -0x38(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
movl $0x2f, %edx
leaq -0x44(%rbp), %rcx
callq 0x7d040
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jne 0x7c9d3
movq -0x18(%rbp), %rax
movl -0x44(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x7c9d5
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
movl $0x40, %edx
leaq -0x44(%rbp), %rcx
callq 0x7d040
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jne 0x7caba
cmpl $0x0, -0x44(%rbp)
jbe 0x7caac
movq -0x10(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movl -0x44(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
movl $0x3a, %edx
leaq -0x4c(%rbp), %rcx
callq 0x7d040
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jne 0x7ca97
movl -0x4c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x7ca97
movl -0x4c(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
addq $0x70, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rcx
movl -0x4c(%rbp), %eax
addq $0x1, %rax
addq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movl -0x44(%rbp), %ecx
subl -0x4c(%rbp), %ecx
subl $0x1, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
jmp 0x7cab8
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x7caba
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpq -0x38(%rbp), %rcx
movb %al, -0x50(%rbp)
jae 0x7caf5
callq 0xd1f0
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x50(%rbp)
movb -0x50(%rbp), %al
testb $0x1, %al
jne 0x7cafe
jmp 0x7cb0c
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x7cac2
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x7cbf3
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xc0, %eax
jge 0x7cb97
callq 0xd1f0
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %ecx
andl $0x1000, %ecx           # imm = 0x1000
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x51(%rbp)
jne 0x7cba7
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
sete %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x7cbb0
jmp 0x7cbcb
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x40(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x7cb63
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5d, %eax
je 0x7cbe3
movl $0xffffffe8, -0x4(%rbp) # imm = 0xFFFFFFE8
jmp 0x7ce1c
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movb $0x1, -0x2a(%rbp)
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
movl $0x3a, %edx
leaq -0x44(%rbp), %rcx
callq 0x7d040
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jne 0x7cc7f
movzbl -0x2a(%rbp), %eax
cmpl $0x0, %eax
jne 0x7cc3e
movq -0x18(%rbp), %rax
movl -0x44(%rbp), %ecx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rcx
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
addq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
movl -0x44(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
addq %rdx, %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movzbl -0x29(%rbp), %eax
cmpl $0x1, %eax
jne 0x7cc94
movl $0x0, -0x4(%rbp)
jmp 0x7ce1c
jmp 0x7cc96
movq -0x38(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x40(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x7ccdf
movl $0x0, -0x4(%rbp)
jmp 0x7ce1c
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
movl $0x3f, %edx
leaq -0x44(%rbp), %rcx
callq 0x7d040
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x7cd51
movl -0x44(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rcx
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
addq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movl -0x44(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
addq %rdx, %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
movl $0x23, %edx
leaq -0x44(%rbp), %rcx
callq 0x7d040
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x7ce15
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
addq $0x20, %rcx
cmpq %rcx, %rax
jne 0x7cd99
movl -0x44(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
jmp 0x7cdd4
movq -0x18(%rbp), %rax
movl -0x44(%rbp), %ecx
addq %rcx, %rax
movq -0x40(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x7cdb5
movl $0xfffffff4, -0x4(%rbp) # imm = 0xFFFFFFF4
jmp 0x7ce1c
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movl -0x44(%rbp), %edx
addq %rdx, %rcx
subq %rcx, %rax
movl %eax, %edx
movq -0x40(%rbp), %rax
movl 0x8(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rcx
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
addq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movl -0x44(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
addq %rdx, %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)