// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: VmHttpSplitEncodedQuery
static sxi32 VmHttpSplitEncodedQuery(
	 jx9_vm *pVm,       /* Target VM */
	 SyString *pQuery,  /* Raw query to decode */
	 SyBlob *pWorker,   /* Working buffer */
	 int is_post        /* TRUE if we are dealing with a POST request */
	 )
 {
	 const char *zEnd = &pQuery->zString[pQuery->nByte];
	 const char *zIn = pQuery->zString;
	 jx9_value *pGet, *pRequest;
	 SyString sName, sValue;
	 const char *zPtr;
	 sxu32 nBlobOfft;
	 /* Extract superglobals */
	 if( is_post ){
		 /* $_POST superglobal */
		 pGet = VmExtractSuper(&(*pVm), "_POST", sizeof("_POST")-1);
	 }else{
		 /* $_GET superglobal */
		 pGet = VmExtractSuper(&(*pVm), "_GET", sizeof("_GET")-1);
	 }
	 pRequest = VmExtractSuper(&(*pVm), "_REQUEST", sizeof("_REQUEST")-1);
	 /* Split up the raw query */
	 for(;;){
		 /* Jump leading white spaces */
		 while(zIn < zEnd  && SyisSpace(zIn[0]) ){
			 zIn++;
		 }
		 if( zIn >= zEnd ){
			 break;
		 }
		 zPtr = zIn;
		 while( zPtr < zEnd && zPtr[0] != '=' && zPtr[0] != '&' && zPtr[0] != ';' ){
			 zPtr++;
		 }
		 /* Reset the working buffer */
		 SyBlobReset(pWorker);
		 /* Decode the entry */
		 SyUriDecode(zIn, (sxu32)(zPtr-zIn), jx9VmBlobConsumer, pWorker, TRUE);
		 /* Save the entry */
		 sName.nByte = SyBlobLength(pWorker);
		 sValue.zString = 0;
		 sValue.nByte = 0;
		 if( zPtr < zEnd && zPtr[0] == '=' ){
			 zPtr++;
			 zIn = zPtr;
			 /* Store field value */
			 while( zPtr < zEnd && zPtr[0] != '&' && zPtr[0] != ';' ){
				 zPtr++;
			 }
			 if( zPtr > zIn ){
				 /* Decode the value */
				  nBlobOfft = SyBlobLength(pWorker);
				  SyUriDecode(zIn, (sxu32)(zPtr-zIn), jx9VmBlobConsumer, pWorker, TRUE);
				  sValue.zString = (const char *)SyBlobDataAt(pWorker, nBlobOfft);
				  sValue.nByte = SyBlobLength(pWorker) - nBlobOfft;
				 
			 }
			 /* Synchronize pointers */
			 zIn = zPtr;
		 }
		 sName.zString = (const char *)SyBlobData(pWorker);
		 /* Install the decoded query in the $_GET/$_REQUEST array */
		 if( pGet && (pGet->iFlags & MEMOBJ_HASHMAP) ){
			 VmHashmapInsert((jx9_hashmap *)pGet->x.pOther, 
				 sName.zString, (int)sName.nByte, 
				 sValue.zString, (int)sValue.nByte
				 );
		 }
		 if( pRequest && (pRequest->iFlags & MEMOBJ_HASHMAP) ){
			 VmHashmapInsert((jx9_hashmap *)pRequest->x.pOther, 
				 sName.zString, (int)sName.nByte, 
				 sValue.zString, (int)sValue.nByte
					 );
		 }
		 /* Advance the pointer */
		 zIn = &zPtr[1];
	 }
	/* All done*/
	return SXRET_OK;
 }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %rbx
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %r12
testl %r8d, %r8d
je 0x4696a
leaq 0x2e026(%rip), %rsi     # 0x74986
movq %r12, %rdi
movl $0x5, %edx
jmp 0x46979
leaq 0x2e01b(%rip), %rsi     # 0x7498c
movq %r12, %rdi
movl $0x4, %edx
callq 0x463a3
movq %rax, -0x30(%rbp)
leaq 0x2e008(%rip), %rsi     # 0x74991
movq %r12, %rdi
movl $0x8, %edx
callq 0x463a3
movq %rax, -0x50(%rbp)
testl %r14d, %r14d
je 0x46b4e
movl %r14d, %r13d
addq %r15, %r13
callq 0xc170
movabsq $0x2800004000000000, %rsi # imm = 0x2800004000000000
leaq -0xa9cb(%rip), %r12     # 0x3bff4
movq (%rax), %rcx
movl %r15d, %r8d
movq %r15, %rdi
movsbq (%rdi), %rdx
testb $0x20, 0x1(%rcx,%rdx,2)
je 0x469e3
incq %rdi
incl %r8d
cmpq %r13, %rdi
jb 0x469c8
jmp 0x46b4e
movq %rdi, %r15
cmpq %r13, %rdi
movq %rax, -0x48(%rbp)
jae 0x46a0c
movzbl (%r15), %ecx
cmpq $0x3d, %rcx
ja 0x469ff
btq %rcx, %rsi
jb 0x46a14
incq %r15
cmpq %r13, %r15
jb 0x469ef
xorl %r14d, %r14d
jmp 0x46a17
xorl %r14d, %r14d
movq %rdi, %r15
jmp 0x46a17
movb $0x1, %r14b
movl $0x0, 0x10(%rbx)
movl 0x18(%rbx), %ecx
testb $0x4, %cl
je 0x46a3b
movq $0x0, 0x8(%rbx)
movl $0x0, 0x14(%rbx)
andl $-0x5, %ecx
movl %ecx, 0x18(%rbx)
movl %r15d, %esi
subl %r8d, %esi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x473ab
movl 0x10(%rbx), %edx
testb %r14b, %r14b
je 0x46acb
cmpb $0x3d, (%r15)
jne 0x46acb
leaq 0x1(%r15), %rdi
cmpq %r13, %rdi
jae 0x46a94
movq %r13, %rax
subq %r15, %rax
movl $0x1, %esi
movzbl (%r15,%rsi), %ecx
cmpl $0x26, %ecx
je 0x46a9f
cmpl $0x3b, %ecx
je 0x46a9f
leaq (%r15,%rsi), %rcx
incq %rcx
incq %rsi
cmpq %r13, %rcx
jb 0x46a6e
addq %rsi, %r15
movq %rax, %rsi
jmp 0x46aa2
xorl %r8d, %r8d
xorl %r12d, %r12d
movq %rdi, %r15
jmp 0x46ad1
addq %rsi, %r15
cmpq $0x2, %rsi
jb 0x46acb
decl %esi
movq %rdx, %r14
movq %r12, %rdx
movq %rbx, %rcx
callq 0x473ab
movq %r14, %rdx
movq 0x8(%rbx), %r12
addq %r14, %r12
movl 0x10(%rbx), %r8d
subl %edx, %r8d
jmp 0x46ad1
xorl %r8d, %r8d
xorl %r12d, %r12d
movq -0x30(%rbp), %rax
movq 0x8(%rbx), %rsi
testq %rax, %rax
je 0x46b13
testb $0x40, 0x8(%rax)
je 0x46b13
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq %rsi, -0x38(%rbp)
movq -0x38(%rbp), %rsi
movq %rdx, %r14
movq %r12, %rcx
movq %rbx, -0x40(%rbp)
movq %r8, %rbx
callq 0x463f0
movq -0x38(%rbp), %rsi
movq %rbx, %r8
movq -0x40(%rbp), %rbx
movq %r14, %rdx
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x46b2d
testb $0x40, 0x8(%rax)
je 0x46b2d
movq (%rax), %rdi
movq %r12, %rcx
callq 0x463f0
incq %r15
cmpq %r13, %r15
movq -0x48(%rbp), %rax
movabsq $0x2800004000000000, %rsi # imm = 0x2800004000000000
leaq -0xab54(%rip), %r12     # 0x3bff4
jb 0x469bf
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq