// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: VmJsonTokenize
static sxi32 VmJsonTokenize(SyStream *pStream, SyToken *pToken, void *pUserData, void *pCtxData)
{
	int *pJsonErr = (int *)pUserData;
	SyString *pStr;
	int c;
	/* Ignore leading white spaces */
	while( pStream->zText < pStream->zEnd && pStream->zText[0] < 0xc0 && SyisSpace(pStream->zText[0]) ){
		/* Advance the stream cursor */
		if( pStream->zText[0] == '\n' ){
			/* Update line counter */
			pStream->nLine++;
		}
		pStream->zText++;
	}
	if( pStream->zText >= pStream->zEnd ){
		/* End of input reached */
		SXUNUSED(pCtxData); /* cc warning */
		return SXERR_EOF;
	}
	/* Record token starting position and line */
	pToken->nLine = pStream->nLine;
	pToken->pUserData = 0;
	pStr = &pToken->sData;
	SyStringInitFromBuf(pStr, pStream->zText, 0);
	if( pStream->zText[0] >= 0xc0 || SyisAlpha(pStream->zText[0]) || pStream->zText[0] == '_' ){
		/* The following code fragment is taken verbatim from the xPP source tree.
		 * xPP is a modern embeddable macro processor with advanced features useful for
		 * application seeking for a production quality, ready to use macro processor.
		 * xPP is a widely used library developed and maintened by Symisc Systems.
		 * You can reach the xPP home page by following this link:
		 * http://xpp.symisc.net/
		 */
		const unsigned char *zIn;
		/* Isolate UTF-8 or alphanumeric stream */
		if( pStream->zText[0] < 0xc0 ){
			pStream->zText++;
		}
		for(;;){
			zIn = pStream->zText;
			if( zIn[0] >= 0xc0 ){
				zIn++;
				/* UTF-8 stream */
				while( zIn < pStream->zEnd && ((zIn[0] & 0xc0) == 0x80) ){
					zIn++;
				}
			}
			/* Skip alphanumeric stream */
			while( zIn < pStream->zEnd && zIn[0] < 0xc0 && (SyisAlphaNum(zIn[0]) || zIn[0] == '_') ){
				zIn++;
			}
			if( zIn == pStream->zText ){
				/* Not an UTF-8 or alphanumeric stream */
				break;
			}
			/* Synchronize pointers */
			pStream->zText = zIn;
		}
		/* Record token length */
		pStr->nByte = (sxu32)((const char *)pStream->zText-pStr->zString);
		/* A simple identifier */
		pToken->nType = JSON_TK_ID;
		if( pStr->nByte == sizeof("true") -1 && SyStrnicmp(pStr->zString, "true", sizeof("true")-1) == 0 ){
			/* boolean true */
			pToken->nType = JSON_TK_TRUE;
		}else if( pStr->nByte == sizeof("false") -1 && SyStrnicmp(pStr->zString,"false", sizeof("false")-1) == 0 ){
			/* boolean false */
			pToken->nType = JSON_TK_FALSE;
		}else if( pStr->nByte == sizeof("null") -1 && SyStrnicmp(pStr->zString,"null", sizeof("null")-1) == 0 ){
			/* NULL */
			pToken->nType = JSON_TK_NULL;
		}
		return SXRET_OK;
	}
	if( pStream->zText[0] == '{' || pStream->zText[0] == '[' || pStream->zText[0] == '}' || pStream->zText[0] == ']'
		|| pStream->zText[0] == ':' || pStream->zText[0] == ',' ){
			/* Single character */
			c = pStream->zText[0];
			/* Set token type */
			switch(c){
			case '[': pToken->nType = JSON_TK_OSB;   break;
			case '{': pToken->nType = JSON_TK_OCB;   break;
			case '}': pToken->nType = JSON_TK_CCB;   break;
			case ']': pToken->nType = JSON_TK_CSB;   break;
			case ':': pToken->nType = JSON_TK_COLON; break;
			case ',': pToken->nType = JSON_TK_COMMA; break;
			default:
				break;
			}
			/* Advance the stream cursor */
			pStream->zText++;
	}else if( pStream->zText[0] == '"') {
		/* JSON string */
		pStream->zText++;
		pStr->zString++;
		/* Delimit the string */
		while( pStream->zText < pStream->zEnd ){
			if( pStream->zText[0] == '"' && pStream->zText[-1] != '\\' ){
				break;
			}
			if( pStream->zText[0] == '\n' ){
				/* Update line counter */
				pStream->nLine++;
			}
			pStream->zText++;
		}
		if( pStream->zText >= pStream->zEnd ){
			/* Missing closing '"' */
			pToken->nType = JSON_TK_INVALID;
			*pJsonErr = SXERR_SYNTAX;
		}else{
			pToken->nType = JSON_TK_STR;
			pStream->zText++; /* Jump the closing double quotes */
		}
	}else if( pStream->zText[0] < 0xc0 && SyisDigit(pStream->zText[0]) ){
		/* Number */
		pStream->zText++;
		pToken->nType = JSON_TK_NUM;
		while( pStream->zText < pStream->zEnd && pStream->zText[0] < 0xc0 && SyisDigit(pStream->zText[0]) ){
			pStream->zText++;
		}
		if( pStream->zText < pStream->zEnd ){
			c = pStream->zText[0];
			if( c == '.' ){
					/* Real number */
					pStream->zText++;
					while( pStream->zText < pStream->zEnd && pStream->zText[0] < 0xc0 && SyisDigit(pStream->zText[0]) ){
						pStream->zText++;
					}
					if( pStream->zText < pStream->zEnd ){
						c = pStream->zText[0];
						if( c=='e' || c=='E' ){
							pStream->zText++;
							if( pStream->zText < pStream->zEnd ){
								c = pStream->zText[0];
								if( c =='+' || c=='-' ){
									pStream->zText++;
								}
								while( pStream->zText < pStream->zEnd && pStream->zText[0] < 0xc0 && SyisDigit(pStream->zText[0]) ){
									pStream->zText++;
								}
							}
						}
					}					
				}else if( c=='e' || c=='E' ){
					/* Real number */
					pStream->zText++;
					if( pStream->zText < pStream->zEnd ){
						c = pStream->zText[0];
						if( c =='+' || c=='-' ){
							pStream->zText++;
						}
						while( pStream->zText < pStream->zEnd && pStream->zText[0] < 0xc0 && SyisDigit(pStream->zText[0]) ){
							pStream->zText++;
						}
					}					
				}
			}
	}else{
		/* Unexpected token */
		pToken->nType = JSON_TK_INVALID;
		/* Advance the stream cursor */
		pStream->zText++;
		*pJsonErr = SXERR_SYNTAX;
		/* Abort processing immediatley */
		return SXERR_ABORT;
	}
	/* record token length */
	pStr->nByte = (sxu32)((const char *)pStream->zText-pStr->zString);
	if( pToken->nType == JSON_TK_STR ){
		pStr->nByte--;
	}
	/* Return to the lexer */
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r15
movq 0x8(%rdi), %rbx
movq 0x10(%rdi), %r14
movl $0xffffffee, %edi       # imm = 0xFFFFFFEE
cmpq %r14, %rbx
setb %r12b
jae 0x521d4
movq %rsi, -0x40(%rbp)
movb (%rbx), %r13b
cmpb $-0x41, %r13b
ja 0x51fda
movq %rdx, -0x38(%rbp)
callq 0xc170
movl $0xffffffee, %edi       # imm = 0xFFFFFFEE
incq %rbx
movq (%rax), %rcx
movzbl %r13b, %edx
testb $0x20, 0x1(%rcx,%rdx,2)
je 0x51fcd
cmpb $0xa, %r13b
jne 0x51fb0
incl 0x18(%r15)
movq %rbx, 0x8(%r15)
cmpq %r14, %rbx
je 0x521d4
setb %r12b
movb (%rbx), %r13b
incq %rbx
cmpb $-0x41, %r13b
jbe 0x51f98
decq %rbx
movq %rbx, -0x30(%rbp)
movq -0x38(%rbp), %rdx
jmp 0x51fde
movq %rbx, -0x30(%rbp)
testb $0x1, %r12b
movq -0x40(%rbp), %rbx
je 0x521d4
movl 0x18(%r15), %eax
movl %eax, 0x14(%rbx)
movq $0x0, 0x18(%rbx)
movq -0x30(%rbp), %rax
movq %rax, (%rbx)
movl $0x0, 0x8(%rbx)
movzbl (%rax), %r12d
cmpq $0xbf, %r12
movq %r15, -0x38(%rbp)
jbe 0x52144
cmpb $-0x41, %r12b
movq -0x30(%rbp), %rdi
ja 0x52030
leaq 0x1(%rdi), %rax
movq %rax, 0x8(%r15)
movq 0x8(%r15), %r12
movq %r12, %r13
cmpb $-0x40, (%r12)
jb 0x5205a
leaq 0x1(%r12), %rax
movq %rax, %r13
cmpq %r14, %rax
jae 0x5205a
movb (%r13), %cl
andb $-0x40, %cl
leaq 0x1(%r13), %rax
negb %cl
jo 0x52043
cmpq %r14, %r13
jae 0x5209e
movq %r14, %rbx
subq %r13, %rbx
movzbl (%r13), %r15d
cmpq $0xbf, %r15
ja 0x52096
callq 0xc170
cmpq $0x5f, %r15
je 0x5208b
movq (%rax), %rax
movzwl (%rax,%r15,2), %eax
andl $0x8, %eax
je 0x52096
incq %r13
decq %rbx
jne 0x52065
movq %r14, %r13
movq -0x38(%rbp), %r15
movq -0x30(%rbp), %rdi
cmpq %r12, %r13
je 0x520ac
movq %r13, 0x8(%r15)
movq %r13, %r12
jmp 0x52037
subl %edi, %r12d
movq -0x40(%rbp), %rbx
movl %r12d, 0x8(%rbx)
movl $0x800, 0x10(%rbx)      # imm = 0x800
cmpl $0x4, %r12d
jne 0x520dd
leaq 0x21bac(%rip), %rsi     # 0x73c77
movl $0x4, %edx
callq 0x3a837
testl %eax, %eax
je 0x5219e
xorl %edi, %edi
cmpl $0x4, %r12d
je 0x5211b
cmpl $0x5, %r12d
jne 0x521d4
leaq 0x21b86(%rip), %rsi     # 0x73c7c
movq -0x30(%rbp), %rdi
movl $0x5, %edx
callq 0x3a837
testl %eax, %eax
je 0x521cb
cmpl $0x4, %r12d
movl $0x0, %edi
jne 0x521d4
leaq 0x269b2(%rip), %rsi     # 0x78ad4
movq -0x30(%rbp), %rdi
movl $0x4, %edx
callq 0x3a837
testl %eax, %eax
jne 0x521d2
movl $0x8, 0x10(%rbx)
jmp 0x521d2
movq %rdx, %r13
callq 0xc170
cmpq $0x5f, %r12
je 0x5201e
movq (%rax), %rcx
movzwl (%rcx,%r12,2), %ecx
movl %ecx, %edx
andl $0x400, %edx            # imm = 0x400
jne 0x5201e
movq %r13, %rsi
cmpl $0x5a, %r12d
jle 0x521a7
cmpl $0x7a, %r12d
jg 0x521e5
movl $0x80, %edx
cmpl $0x5b, %r12d
je 0x52275
cmpl $0x5d, %r12d
jne 0x52241
movl $0x100, %edx            # imm = 0x100
jmp 0x52275
movl $0x1, 0x10(%rbx)
jmp 0x521d2
cmpl $0x22, %r12d
je 0x521f8
cmpl $0x2c, %r12d
je 0x52270
cmpl $0x3a, %r12d
jne 0x52241
movl $0x200, %edx            # imm = 0x200
jmp 0x52275
movl $0x2, 0x10(%rbx)
xorl %edi, %edi
movl %edi, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x7d, %r12d
je 0x52269
cmpl $0x7b, %r12d
jne 0x52241
movl $0x20, %edx
jmp 0x52275
movq -0x30(%rbp), %rcx
incq %rcx
movq %rcx, 0x8(%r15)
movq %rcx, (%rbx)
cmpq %r14, %rcx
setb %al
jae 0x523dc
movq %rcx, %rdx
movzbl (%rcx), %ecx
cmpl $0xa, %ecx
je 0x52231
cmpl $0x22, %ecx
jne 0x52235
cmpb $0x5c, -0x1(%rdx)
jne 0x523c5
cmpb $0xa, %cl
jne 0x52235
incl 0x18(%r15)
movq %rdx, %rcx
incq %rcx
movq %rcx, 0x8(%r15)
jmp 0x52206
btl $0xb, %ecx
jb 0x522a2
movl $0x1000, 0x10(%rbx)     # imm = 0x1000
movq -0x30(%rbp), %rax
incq %rax
movq %rax, 0x8(%r15)
movl $0xfffffff4, (%rsi)     # imm = 0xFFFFFFF4
movl $0xfffffff6, %edi       # imm = 0xFFFFFFF6
jmp 0x521d4
movl $0x40, %edx
jmp 0x52275
movl $0x400, %edx            # imm = 0x400
movl %edx, 0x10(%rbx)
movq -0x30(%rbp), %rax
incq %rax
movq %rax, 0x8(%r15)
movl 0x8(%r15), %eax
subl (%rbx), %eax
movl %eax, 0x8(%rbx)
xorl %edi, %edi
cmpl $0x4, 0x10(%rbx)
jne 0x521d4
decl %eax
movl %eax, 0x8(%rbx)
jmp 0x521d4
movq -0x30(%rbp), %rcx
incq %rcx
movq %rcx, 0x8(%r15)
movl $0x10, 0x10(%rbx)
cmpq %r14, %rcx
setb %dl
jae 0x52283
movb (%rcx), %sil
cmpb $-0x41, %sil
ja 0x522ff
addq $0x2, -0x30(%rbp)
movq (%rax), %rcx
movzbl %sil, %esi
testb $0x8, 0x1(%rcx,%rsi,2)
je 0x522f8
movq -0x30(%rbp), %rcx
movq %rcx, 0x8(%r15)
cmpq %r14, %rcx
setb %dl
jae 0x52283
movb (%rcx), %sil
incq %rcx
movq %rcx, -0x30(%rbp)
cmpb $-0x41, %sil
jbe 0x522ca
movq -0x30(%rbp), %rcx
decq %rcx
testb $0x1, %dl
je 0x52283
movb (%rcx), %dl
cmpb $0x2e, %dl
jne 0x523ee
incq %rcx
movq %rcx, 0x8(%r15)
cmpq %r14, %rcx
jae 0x52283
movq %rcx, %rdx
movzbl (%rcx), %esi
cmpq $0xbf, %rsi
ja 0x52340
movq (%rax), %rdi
leaq 0x1(%rdx), %rcx
testb $0x8, 0x1(%rdi,%rsi,2)
jne 0x52316
cmpq %r14, %rdx
jae 0x52283
movb (%rdx), %cl
andb $-0x21, %cl
cmpb $0x45, %cl
jne 0x52283
leaq 0x1(%rdx), %rcx
movq %rcx, 0x8(%r15)
cmpq %r14, %rcx
jae 0x52283
movzbl (%rcx), %ecx
cmpl $0x2d, %ecx
je 0x52375
cmpl $0x2b, %ecx
jne 0x52381
addq $0x2, %rdx
movq -0x38(%rbp), %rcx
movq %rdx, 0x8(%rcx)
movq -0x38(%rbp), %r15
movq 0x8(%r15), %rcx
cmpq %r14, %rcx
movq -0x40(%rbp), %rbx
jae 0x52283
movzbl (%rcx), %edx
cmpq $0xbf, %rdx
ja 0x52283
movq (%rax), %rsi
testb $0x8, 0x1(%rsi,%rdx,2)
je 0x52283
incq %rcx
movq %rcx, 0x8(%r15)
cmpq %r14, %rcx
jne 0x52396
jmp 0x52283
testb $0x1, %al
je 0x523dc
movl $0x4, 0x10(%rbx)
incq %rdx
movq %rdx, 0x8(%r15)
jmp 0x52283
movl $0x1000, 0x10(%rbx)     # imm = 0x1000
movl $0xfffffff4, (%rsi)     # imm = 0xFFFFFFF4
jmp 0x52283
andb $-0x21, %dl
cmpb $0x45, %dl
jne 0x52283
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r15)
cmpq %r14, %rdx
jae 0x52283
movzbl (%rdx), %edx
cmpl $0x2d, %edx
je 0x52418
cmpl $0x2b, %edx
jne 0x52420
addq $0x2, %rcx
movq %rcx, 0x8(%r15)
movq 0x8(%r15), %rcx
cmpq %r14, %rcx
jae 0x52283
movzbl (%rcx), %edx
cmpq $0xbf, %rdx
ja 0x52283
movq (%rax), %rsi
testb $0x8, 0x1(%rsi,%rdx,2)
je 0x52283
incq %rcx
movq %rcx, 0x8(%r15)
cmpq %r14, %rcx
jne 0x5242d
jmp 0x52283