// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: SyHexStrToInt64
JX9_PRIVATE sxi32 SyHexStrToInt64(const char *zSrc, sxu32 nLen, void * pOutVal, const char **zRest)
{
	const char *zIn, *zEnd;
	int isNeg = FALSE;
	sxi64 nVal = 0;
#if defined(UNTRUST)
	if( SX_EMPTY_STR(zSrc) ){
		if( pOutVal ){
			*(sxi32 *)pOutVal = 0;
		}
		return SXERR_EMPTY;
	}
#endif
	zEnd = &zSrc[nLen];
	while( zSrc < zEnd && SyisSpace(zSrc[0]) ){
		zSrc++;
	}
	if( zSrc < zEnd && ( *zSrc == '-' || *zSrc == '+' ) ){
		isNeg = (zSrc[0] == '-') ? TRUE :FALSE;
		zSrc++;
	}
	if( zSrc < &zEnd[-2] && zSrc[0] == '0' && (zSrc[1] == 'x' || zSrc[1] == 'X') ){
		/* Bypass hex prefix */
		zSrc += sizeof(char) * 2;
	}	
	/* Skip leading zero */
	while(zSrc < zEnd && zSrc[0] == '0' ){
		zSrc++;
	}
	zIn = zSrc;
	for(;;){
		if(zSrc >= zEnd || !SyisHex(zSrc[0]) || (int)(zSrc-zIn) > 15) break; nVal = nVal * 16 + SyHexToint(zSrc[0]);  zSrc++ ;
		if(zSrc >= zEnd || !SyisHex(zSrc[0]) || (int)(zSrc-zIn) > 15) break; nVal = nVal * 16 + SyHexToint(zSrc[0]);  zSrc++ ;
		if(zSrc >= zEnd || !SyisHex(zSrc[0]) || (int)(zSrc-zIn) > 15) break; nVal = nVal * 16 + SyHexToint(zSrc[0]);  zSrc++ ;
		if(zSrc >= zEnd || !SyisHex(zSrc[0]) || (int)(zSrc-zIn) > 15) break; nVal = nVal * 16 + SyHexToint(zSrc[0]);  zSrc++ ;
	}
	while( zSrc < zEnd && SyisSpace(zSrc[0]) ){
		zSrc++;
	}	
	if( zRest ){
		*zRest = zSrc;
	}
	if( pOutVal ){
		if( isNeg == TRUE && nVal != 0 ){
			nVal = -nVal;
		}
		*(sxi64 *)pOutVal = nVal;
	}
	return zSrc >= zEnd ? SXRET_OK : SXERR_SYNTAX;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, -0x50(%rbp)
movq %rdi, %r14
movl %esi, %ebx
addq %rdi, %rbx
cmpq %rbx, %r14
jae 0x37645
callq 0xc190
movq (%rax), %rcx
movsbq (%r14), %rax
testb $0x20, 0x1(%rcx,%rax,2)
je 0x3762a
incq %r14
jmp 0x3760d
movzbl %al, %eax
cmpl $0x2b, %eax
je 0x37637
cmpl $0x2d, %eax
jne 0x37645
cmpl $0x2d, %eax
sete %al
movl %eax, -0x34(%rbp)
incq %r14
jmp 0x3764c
movl $0x0, -0x34(%rbp)
leaq -0x2(%rbx), %rax
cmpq %rax, %r14
jae 0x37677
cmpb $0x30, (%r14)
jne 0x37677
movzbl 0x1(%r14), %eax
orl $0x20, %eax
cmpl $0x78, %eax
jne 0x37677
addq $0x2, %r14
jmp 0x37677
cmpb $0x30, (%r14)
jne 0x3767c
incq %r14
cmpq %rbx, %r14
jb 0x3766e
movq %rbx, -0x30(%rbp)
xorl %r12d, %r12d
movq %r14, -0x40(%rbp)
xorl %r15d, %r15d
leaq (%r14,%r12), %r13
cmpq -0x30(%rbp), %r13
jae 0x377c6
callq 0xc190
movq (%rax), %rax
movsbq (%r13), %rdi
movq %rax, -0x48(%rbp)
testb $0x10, 0x1(%rax,%rdi,2)
je 0x377b4
cmpl $0xf, %r12d
jg 0x377b4
shlq $0x4, %r15
callq 0x37e12
movslq %eax, %rbx
addq %r15, %rbx
leaq (%r14,%r12), %r13
incq %r13
movq -0x30(%rbp), %r15
cmpq %r15, %r13
jae 0x377ba
leal 0x1(%r12), %eax
cmpl $0xf, %eax
jg 0x377cd
movsbq (%r13), %rdi
movq -0x48(%rbp), %rax
movzwl (%rax,%rdi,2), %eax
andl $0x1000, %eax           # imm = 0x1000
je 0x377cd
shlq $0x4, %rbx
callq 0x37e12
movq %r15, %rcx
movslq %eax, %r15
addq %rbx, %r15
leaq (%r14,%r12), %r13
addq $0x2, %r13
cmpq %rcx, %r13
jae 0x377c6
movq -0x40(%rbp), %rax
addq $0x2, %rax
leal 0x2(%r12), %ecx
cmpl $0xf, %ecx
jg 0x377c3
movsbq (%r13), %rdi
movq -0x48(%rbp), %rcx
movzwl (%rcx,%rdi,2), %ecx
andl $0x1000, %ecx           # imm = 0x1000
je 0x377c3
shlq $0x4, %r15
callq 0x37e12
movslq %eax, %rbx
addq %r15, %rbx
leaq (%r14,%r12), %r13
addq $0x3, %r13
movq -0x30(%rbp), %r15
cmpq %r15, %r13
jae 0x3781c
leal 0x3(%r12), %eax
cmpl $0xf, %eax
jg 0x377cd
movsbq (%r13), %rdi
movq -0x48(%rbp), %rax
movzwl (%rax,%rdi,2), %eax
andl $0x1000, %eax           # imm = 0x1000
je 0x377cd
shlq $0x4, %rbx
callq 0x37e12
movslq %eax, %r15
addq %rbx, %r15
addq $0x4, -0x40(%rbp)
addq $0x4, %r12
jmp 0x3768a
movq -0x40(%rbp), %r13
jmp 0x377c6
movq -0x40(%rbp), %r13
incq %r13
jmp 0x377cd
movq %rax, %r13
movq %r15, %rbx
movq -0x30(%rbp), %r15
cmpq %r15, %r13
jae 0x377e9
callq 0xc190
movq (%rax), %rax
movsbq (%r13), %rcx
incq %r13
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x377cd
movq -0x50(%rbp), %rdx
testq %rdx, %rdx
je 0x3780d
movq %rbx, %rax
negq %rax
setb %cl
testb $0x1, %cl
cmoveq %rbx, %rax
cmpb $0x0, -0x34(%rbp)
cmoveq %rbx, %rax
movq %rax, (%rdx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x40(%rbp), %r13
addq $0x3, %r13
jmp 0x377cd