// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: SyStrToInt64
JX9_PRIVATE sxi32 SyStrToInt64(const char *zSrc, sxu32 nLen, void * pOutVal, const char **zRest)
{
	int isNeg = FALSE;
	const char *zEnd;
	sxi64 nVal;
	sxi16 i;
#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[0] == '-' || zSrc[0] == '+' ) ){
		isNeg = (zSrc[0] == '-') ? TRUE :FALSE;
		zSrc++;
	}
	/* Skip leading zero */
	while(zSrc < zEnd && zSrc[0] == '0' ){
		zSrc++;
	}
	i = 19;
	if( (sxu32)(zEnd-zSrc) >= 19 ){
		i = SyMemcmp(zSrc, isNeg ? SXINT64_MIN_STR : SXINT64_MAX_STR, 19) <= 0 ? 19 : 18 ;
	}
	nVal = 0;
	for(;;){
		if(zSrc >= zEnd || !i || !SyisDigit(zSrc[0])){ break; } nVal = nVal * 10 + ( zSrc[0] - '0' ) ; --i ; zSrc++;
		if(zSrc >= zEnd || !i || !SyisDigit(zSrc[0])){ break; } nVal = nVal * 10 + ( zSrc[0] - '0' ) ; --i ; zSrc++;
		if(zSrc >= zEnd || !i || !SyisDigit(zSrc[0])){ break; } nVal = nVal * 10 + ( zSrc[0] - '0' ) ; --i ; zSrc++;
		if(zSrc >= zEnd || !i || !SyisDigit(zSrc[0])){ break; } nVal = nVal * 10 + ( zSrc[0] - '0' ) ; --i ; zSrc++;
	}
	/* Skip trailing spaces */
	while(zSrc < zEnd && SyisSpace(zSrc[0])){
		zSrc++;
	}
	if( zRest ){
		*zRest = (char *)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
pushq %rax
movq %rdx, -0x30(%rbp)
movq %rdi, %rbx
movl %esi, %r12d
addq %rdi, %r12
xorl %r15d, %r15d
testl %esi, %esi
je 0x4025f
callq 0xc170
movq (%rax), %rax
movsbq (%rbx), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x40245
incq %rbx
cmpq %r12, %rbx
jb 0x40230
jmp 0x4025f
movzbl %cl, %eax
cmpl $0x2b, %eax
je 0x40252
cmpl $0x2d, %eax
jne 0x4025f
xorl %r15d, %r15d
cmpl $0x2d, %eax
sete %r15b
incq %rbx
cmpq %r12, %rbx
jae 0x40269
cmpb $0x30, (%rbx)
je 0x4025c
movl %r12d, %eax
subl %ebx, %eax
movw $0x13, %r14w
cmpl $0x13, %eax
jb 0x402a7
testl %r15d, %r15d
leaq 0x33e25(%rip), %rax     # 0x740a7
leaq 0x33e0a(%rip), %rsi     # 0x74093
cmoveq %rax, %rsi
movq %rbx, %rdi
movl $0x13, %edx
callq 0x347f1
xorl %r14d, %r14d
testl %eax, %eax
setle %r14b
orl $0x12, %r14d
cmpq %r12, %rbx
jae 0x403dd
callq 0xc170
movq (%rax), %rax
movzwl %r14w, %ecx
leaq -0x1(%rcx), %rdx
leaq -0x2(%rcx), %rsi
leaq -0x4(%rcx), %rdi
addq $-0x3, %rcx
xorl %r8d, %r8d
xorl %r13d, %r13d
movq %rbx, %r9
movsbq (%rbx,%r8), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x40442
leaq (,%r13,4), %r11
addq %r13, %r11
leaq (%r10,%r11,2), %r13
addq $-0x30, %r13
leaq 0x1(%r9), %r10
leaq (%rbx,%r8), %r14
incq %r14
cmpq %r12, %r14
jae 0x4043d
cmpw %r8w, %dx
je 0x4043d
movsbq (%r14), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x403e3
leaq (,%r13,4), %r11
addq %r13, %r11
leaq (%r10,%r11,2), %r13
addq $-0x30, %r13
leaq (%rbx,%r8), %r14
addq $0x2, %r14
cmpq %r12, %r14
jae 0x403e3
cmpw %r8w, %si
je 0x403e3
movsbq (%r14), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x40447
leaq (,%r13,4), %r11
addq %r13, %r11
leaq (%r10,%r11,2), %r13
addq $-0x30, %r13
leaq 0x3(%r9), %r10
leaq (%rbx,%r8), %r14
addq $0x3, %r14
cmpq %r12, %r14
jae 0x4043d
cmpw %r8w, %cx
je 0x4043d
movsbq (%r14), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x403e3
leaq (,%r13,4), %r11
addq %r13, %r11
leaq (%r10,%r11,2), %r13
addq $-0x30, %r13
leaq (%r8,%rbx), %r11
addq $0x4, %r11
leaq 0x4(%r8), %r10
cmpq %r12, %r11
jae 0x403d8
addq $0x4, %r9
cmpw %r8w, %di
movq %r10, %r8
jne 0x402d5
addq %r10, %rbx
jmp 0x403e0
xorl %r13d, %r13d
movq %rbx, %r14
cmpq %r12, %r14
movq -0x30(%rbp), %rbx
jae 0x4040f
callq 0xc170
movq (%rax), %rax
incq %r14
movsbq -0x1(%r14), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x4040f
leaq 0x1(%r14), %rcx
cmpq %r12, %r14
movq %rcx, %r14
jb 0x403f7
testq %rbx, %rbx
je 0x4042e
movq %r13, %rax
negq %rax
setb %cl
testb $0x1, %cl
cmoveq %r13, %rax
testl %r15d, %r15d
cmoveq %r13, %rax
movq %rax, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r10, %r14
jmp 0x403e3
addq %r8, %rbx
jmp 0x403e0
addq $0x2, %r9
movq %r9, %r14
jmp 0x403e3