// File: /workspace/github_c_makefile_star2_O2/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 %rdx, -0x30(%rbp)
movq %rdi, %r14
movq (%rsi), %r15
movl 0x8(%rsi), %ebx
testl %ecx, %ecx
je 0x3d627
leaq 0x27343(%rip), %rsi     # 0x64966
pushq $0x5
jmp 0x3d630
leaq 0x2733e(%rip), %rsi     # 0x6496c
pushq $0x4
popq %rdx
movq %r14, %rdi
callq 0x3d3ee
movq %rax, -0x40(%rbp)
addq %r15, %rbx
leaq 0x2732a(%rip), %rsi     # 0x64971
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x3d3ee
movabsq $0x2800004000000000, %r14 # imm = 0x2800004000000000
movq %rax, -0x48(%rbp)
cmpq %rbx, %r15
jae 0x3d79c
callq 0xc190
movq (%rax), %rax
movsbq (%r15), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
movq %r15, %r13
jne 0x3d69a
cmpq %rbx, %r13
jae 0x3d6a2
movzbl (%r13), %eax
cmpq $0x3d, %rax
ja 0x3d695
btq %rax, %r14
jb 0x3d6a2
incq %r13
jmp 0x3d67f
movq %r15, %r13
jmp 0x3d791
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x31b1e
movl %r13d, %esi
subl %r15d, %esi
movq %r15, %rdi
leaq -0x95a0(%rip), %rdx     # 0x3411e
movq %r14, %rcx
callq 0x3dff1
movl 0x10(%r14), %r12d
cmpq %rbx, %r13
jae 0x3d6f9
cmpb $0x3d, (%r13)
jne 0x3d6f9
leaq 0x1(%r13), %rdi
pushq $0x1
popq %rsi
leaq (%rsi,%r13), %r15
cmpq %rbx, %r15
jae 0x3d700
movzbl (%r15), %eax
cmpl $0x26, %eax
je 0x3d700
cmpl $0x3b, %eax
je 0x3d700
incq %rsi
jmp 0x3d6dd
xorl %r14d, %r14d
xorl %ecx, %ecx
jmp 0x3d733
cmpq $0x2, %rsi
jb 0x3d72b
decl %esi
leaq -0x95f1(%rip), %rdx     # 0x3411e
movq -0x30(%rbp), %r13
movq %r13, %rcx
callq 0x3dff1
movq 0x8(%r13), %rcx
addq %r12, %rcx
movl 0x10(%r13), %r14d
subl %r12d, %r14d
jmp 0x3d730
xorl %r14d, %r14d
xorl %ecx, %ecx
movq %r15, %r13
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x40(%rbp), %rax
testq %rax, %rax
je 0x3d76a
testb $0x40, 0x8(%rax)
je 0x3d76a
movq (%rax), %rdi
movq %rsi, -0x38(%rbp)
movq -0x38(%rbp), %rsi
movl %r12d, %edx
movq %rcx, %r15
movl %r14d, %r8d
callq 0x3d42c
movq -0x38(%rbp), %rsi
movq %r15, %rcx
movq -0x48(%rbp), %rax
testq %rax, %rax
je 0x3d787
testb $0x40, 0x8(%rax)
je 0x3d787
movq (%rax), %rdi
movl %r12d, %edx
movl %r14d, %r8d
callq 0x3d42c
movabsq $0x2800004000000000, %r14 # imm = 0x2800004000000000
incq %r13
movq %r13, %r15
jmp 0x3d660
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq