// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: VmJsonDecode
static sxi32 VmJsonDecode(
	json_decoder *pDecoder, /* JSON decoder */      
	jx9_value *pArrayKey    /* Key for the decoded array */
	){
	jx9_value *pWorker; /* Worker variable */
	sxi32 rc;
	/* Check if we do not nest to much */
	if( pDecoder->rec_count > 31 ){
		/* Nesting limit reached, abort decoding immediately */
		return SXERR_ABORT;
	}
	if( pDecoder->pIn->nType & (JSON_TK_STR|JSON_TK_ID|JSON_TK_TRUE|JSON_TK_FALSE|JSON_TK_NULL|JSON_TK_NUM) ){
		/* Scalar value */
		pWorker = jx9_context_new_scalar(pDecoder->pCtx);
		if( pWorker == 0 ){
			jx9_context_throw_error(pDecoder->pCtx, JX9_CTX_ERR, "JX9 is running out of memory");
			/* Abort the decoding operation immediately */
			return SXERR_ABORT;
		}
		/* Reflect the JSON image */
		if( pDecoder->pIn->nType & JSON_TK_NULL ){
			/* Nullify the value.*/
			jx9_value_null(pWorker);
		}else if( pDecoder->pIn->nType & (JSON_TK_TRUE|JSON_TK_FALSE) ){
			/* Boolean value */
			jx9_value_bool(pWorker, (pDecoder->pIn->nType & JSON_TK_TRUE) ? 1 : 0 );
		}else if( pDecoder->pIn->nType & JSON_TK_NUM ){
			SyString *pStr = &pDecoder->pIn->sData;
			/* 
			 * Numeric value.
			 * Get a string representation first then try to get a numeric
			 * value.
			 */
			jx9_value_string(pWorker, pStr->zString, (int)pStr->nByte);
			/* Obtain a numeric representation */
			jx9MemObjToNumeric(pWorker);
		}else if( pDecoder->pIn->nType & JSON_TK_ID ){
			SyString *pStr = &pDecoder->pIn->sData;
			jx9_value_string(pWorker, pStr->zString, (int)pStr->nByte);
		}else{
			/* Dequote the string */
			VmJsonDequoteString(&pDecoder->pIn->sData, pWorker);
		}
		/* Invoke the consumer callback */
		rc = pDecoder->xConsumer(pDecoder->pCtx, pArrayKey, pWorker, pDecoder->pUserData);
		if( rc == SXERR_ABORT ){
			return SXERR_ABORT;
		}
		/* All done, advance the stream cursor */
		pDecoder->pIn++;
	}else if( pDecoder->pIn->nType & JSON_TK_OSB /*'[' */) {
		ProcJSONConsumer xOld;
		void *pOld;
		/* Array representation*/
		pDecoder->pIn++;
		/* Create a working array */
		pWorker = jx9_context_new_array(pDecoder->pCtx);
		if( pWorker == 0 ){
			jx9_context_throw_error(pDecoder->pCtx, JX9_CTX_ERR, "JX9 is running out of memory");
			/* Abort the decoding operation immediately */
			return SXERR_ABORT;
		}
		/* Save the old consumer */
		xOld = pDecoder->xConsumer;
		pOld = pDecoder->pUserData;
		/* Set the new consumer */
		pDecoder->xConsumer = VmJsonArrayDecoder;
		pDecoder->pUserData = pWorker;
		/* Decode the array */
		for(;;){
			/* Jump trailing comma. Note that the standard JX9 engine will not let you
			 * do this.
			 */
			while( (pDecoder->pIn < pDecoder->pEnd) && (pDecoder->pIn->nType & JSON_TK_COMMA) ){
				pDecoder->pIn++;
			}
			if( pDecoder->pIn >= pDecoder->pEnd || (pDecoder->pIn->nType & JSON_TK_CSB) /*']'*/ ){
				if( pDecoder->pIn < pDecoder->pEnd ){
					pDecoder->pIn++; /* Jump the trailing ']' */
				}
				break;
			}
			/* Recurse and decode the entry */
			pDecoder->rec_count++;
			rc = VmJsonDecode(pDecoder, 0);
			pDecoder->rec_count--;
			if( rc == SXERR_ABORT ){
				/* Abort processing immediately */
				return SXERR_ABORT;
			}
			/*The cursor is automatically advanced by the VmJsonDecode() function */
			if( (pDecoder->pIn < pDecoder->pEnd) &&
				((pDecoder->pIn->nType & (JSON_TK_CSB/*']'*/|JSON_TK_COMMA/*','*/))==0) ){
					/* Unexpected token, abort immediatley */
					*pDecoder->pErr = SXERR_SYNTAX;
					return SXERR_ABORT;
			}
		}
		/* Restore the old consumer */
		pDecoder->xConsumer = xOld;
		pDecoder->pUserData = pOld;
		/* Invoke the old consumer on the decoded array */
		xOld(pDecoder->pCtx, pArrayKey, pWorker, pOld);
	}else if( pDecoder->pIn->nType & JSON_TK_OCB /*'{' */) {
		ProcJSONConsumer xOld;
		jx9_value *pKey;
		void *pOld;
		/* Object representation*/
		pDecoder->pIn++;
		/* Create a working array */
		pWorker = jx9_context_new_array(pDecoder->pCtx);
		pKey = jx9_context_new_scalar(pDecoder->pCtx);
		if( pWorker == 0 || pKey == 0){
			jx9_context_throw_error(pDecoder->pCtx, JX9_CTX_ERR, "JX9 is running out of memory");
			/* Abort the decoding operation immediately */
			return SXERR_ABORT;
		}
		/* Save the old consumer */
		xOld = pDecoder->xConsumer;
		pOld = pDecoder->pUserData;
		/* Set the new consumer */
		pDecoder->xConsumer = VmJsonArrayDecoder;
		pDecoder->pUserData = pWorker;
		/* Decode the object */
		for(;;){
			/* Jump trailing comma. Note that the standard JX9 engine will not let you
			 * do this.
			 */
			while( (pDecoder->pIn < pDecoder->pEnd) && (pDecoder->pIn->nType & JSON_TK_COMMA) ){
				pDecoder->pIn++;
			}
			if( pDecoder->pIn >= pDecoder->pEnd || (pDecoder->pIn->nType & JSON_TK_CCB) /*'}'*/ ){
				if( pDecoder->pIn < pDecoder->pEnd ){
					pDecoder->pIn++; /* Jump the trailing ']' */
				}
				break;
			}
			if( (pDecoder->pIn->nType & (JSON_TK_ID|JSON_TK_STR)) == 0 || &pDecoder->pIn[1] >= pDecoder->pEnd
				|| (pDecoder->pIn[1].nType & JSON_TK_COLON) == 0){
					/* Syntax error, return immediately */
					*pDecoder->pErr = SXERR_SYNTAX;
					return SXERR_ABORT;
			}
			if( pDecoder->pIn->nType & JSON_TK_ID ){
				SyString *pStr = &pDecoder->pIn->sData;
				jx9_value_string(pKey, pStr->zString, (int)pStr->nByte);
			}else{
				/* Dequote the key */
				VmJsonDequoteString(&pDecoder->pIn->sData, pKey);
			}
			/* Jump the key and the colon */
			pDecoder->pIn += 2; 
			/* Recurse and decode the value */
			pDecoder->rec_count++;
			rc = VmJsonDecode(pDecoder, pKey);
			pDecoder->rec_count--;
			if( rc == SXERR_ABORT ){
				/* Abort processing immediately */
				return SXERR_ABORT;
			}
			/* Reset the internal buffer of the key */
			jx9_value_reset_string_cursor(pKey);
			/*The cursor is automatically advanced by the VmJsonDecode() function */
		}
		/* Restore the old consumer */
		pDecoder->xConsumer = xOld;
		pDecoder->pUserData = pOld;
		/* Invoke the old consumer on the decoded object*/
		xOld(pDecoder->pCtx, pArrayKey, pWorker, pOld);
		/* Release the key */
		jx9_context_release_value(pDecoder->pCtx, pKey);
	}else{
		/* Unexpected token */
		return SXERR_ABORT; /* Abort immediately */
	}
	/* Release the worker variable */
	jx9_context_release_value(pDecoder->pCtx, pWorker);
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1f, 0x30(%rax)
jle 0x8cb46
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x8d166
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x81f, %eax            # imm = 0x81F
cmpl $0x0, %eax
je 0x8ccd4
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x58510
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x8cb9a
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %esi
leaq 0x37c28(%rip), %rdx     # 0xc47b1
callq 0x580b0
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x8d166
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x8cbbb
movq -0x20(%rbp), %rdi
callq 0x56880
jmp 0x8cc89
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x8cbf7
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %ecx
andl $0x1, %ecx
xorl %esi, %esi
movl $0x1, %eax
cmpl $0x0, %ecx
cmovnel %eax, %esi
callq 0x56800
jmp 0x8cc87
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x8cc38
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x56950
movq -0x20(%rbp), %rdi
callq 0x76a30
jmp 0x8cc85
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x8cc72
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq -0x38(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x56950
jmp 0x8cc83
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x8d170
jmp 0x8cc85
jmp 0x8cc87
jmp 0x8cc89
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
callq *%rax
movl %eax, -0x24(%rbp)
cmpl $-0xa, -0x24(%rbp)
jne 0x8ccbf
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x8d166
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x20(%rax)
jmp 0x8d14f
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x8cebe
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x58570
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x8cd38
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %esi
leaq 0x37a8a(%rip), %rdx     # 0xc47b1
callq 0x580b0
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x8d166
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
leaq 0x5d5(%rip), %rcx       # 0x8d330
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x8cd6d
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpq 0x28(%rdx), %rcx
movb %al, -0x69(%rbp)
jae 0x8cd9d
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
setne %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x8cda6
jmp 0x8cdb8
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x20(%rax)
jmp 0x8cd6d
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jae 0x8cddf
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x8ce06
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jae 0x8ce01
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x20(%rax)
jmp 0x8ce88
movq -0x10(%rbp), %rax
movl 0x30(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x30(%rax)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8cb20
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x30(%rax)
cmpl $-0xa, -0x24(%rbp)
jne 0x8ce42
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x8d166
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jae 0x8ce83
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x500, %eax            # imm = 0x500
cmpl $0x0, %eax
jne 0x8ce83
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movl $0xfffffff4, (%rax)     # imm = 0xFFFFFFF4
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x8d166
jmp 0x8cd6b
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x48(%rbp), %rcx
callq *%rax
jmp 0x8d14d
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x8d142
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x58570
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x58510
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x8cf13
cmpq $0x0, -0x58(%rbp)
jne 0x8cf37
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %esi
leaq 0x3788b(%rip), %rdx     # 0xc47b1
callq 0x580b0
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x8d166
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
leaq 0x3d6(%rip), %rcx       # 0x8d330
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x8cf6c
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpq 0x28(%rdx), %rcx
movb %al, -0x6a(%rbp)
jae 0x8cf9c
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
setne %al
movb %al, -0x6a(%rbp)
movb -0x6a(%rbp), %al
testb $0x1, %al
jne 0x8cfa5
jmp 0x8cfb7
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x20(%rax)
jmp 0x8cf6c
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jae 0x8cfdc
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x8d003
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jae 0x8cffe
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x20(%rax)
jmp 0x8d0ff
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x804, %eax            # imm = 0x804
cmpl $0x0, %eax
je 0x8d043
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
addq $0x20, %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jae 0x8d043
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x30(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
jne 0x8d05d
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movl $0xfffffff4, (%rax)     # imm = 0xFFFFFFF4
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x8d166
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x8d097
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rdi
movq -0x68(%rbp), %rax
movq (%rax), %rsi
movq -0x68(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x56950
jmp 0x8d0a8
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x58(%rbp), %rsi
callq 0x8d170
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x40, %rcx
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x30(%rax)
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x8cb20
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x30(%rax)
cmpl $-0xa, -0x24(%rbp)
jne 0x8d0f1
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x8d166
movq -0x58(%rbp), %rdi
callq 0x56b80
jmp 0x8cf6a
movq -0x50(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x60(%rbp), %rcx
callq *%rax
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x58(%rbp), %rsi
callq 0x585e0
jmp 0x8d14b
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x8d166
jmp 0x8d14d
jmp 0x8d14f
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x585e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nop