// File: /workspace/github_c_makefile_star2_O1/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, %r15
movq %rdi, %r14
movl %esi, %r12d
addq %rdi, %r12
xorl %r13d, %r13d
testl %esi, %esi
je 0x40c89
callq 0xc170
movq (%rax), %rax
movsbq (%r14), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x40c6f
incq %r14
cmpq %r12, %r14
jb 0x40c5a
jmp 0x40c89
movzbl %cl, %eax
cmpl $0x2b, %eax
je 0x40c7c
cmpl $0x2d, %eax
jne 0x40c89
xorl %r13d, %r13d
cmpl $0x2d, %eax
sete %r13b
incq %r14
cmpq %r12, %r14
jae 0x40c94
cmpb $0x30, (%r14)
je 0x40c86
movl %r12d, %eax
subl %r14d, %eax
movw $0x13, %bx
cmpl $0x13, %eax
jb 0x40ccf
testl %r13d, %r13d
leaq 0x353f2(%rip), %rax     # 0x7609f
leaq 0x353d7(%rip), %rsi     # 0x7608b
cmoveq %rax, %rsi
movq %r14, %rdi
movl $0x13, %edx
callq 0x34ebe
xorl %ebx, %ebx
testl %eax, %eax
setle %bl
orl $0x12, %ebx
movl %r13d, -0x2c(%rbp)
cmpq %r12, %r14
jae 0x40dfc
callq 0xc170
movq (%rax), %rax
movzwl %bx, %ecx
leaq -0x1(%rcx), %rdx
leaq -0x2(%rcx), %rsi
leaq -0x4(%rcx), %rdi
addq $-0x3, %rcx
xorl %r8d, %r8d
xorl %r13d, %r13d
movq %r14, %r9
movsbq (%r14,%r8), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x40e5f
leaq (,%r13,4), %r11
addq %r13, %r11
leaq (%r10,%r11,2), %r13
addq $-0x30, %r13
leaq (%r14,%r8), %rbx
incq %rbx
cmpq %r12, %rbx
jae 0x40e02
cmpw %r8w, %dx
je 0x40e02
movsbq (%rbx), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x40e64
leaq (,%r13,4), %r11
addq %r13, %r11
leaq (%r10,%r11,2), %r13
addq $-0x30, %r13
leaq 0x2(%r9), %r10
leaq (%r14,%r8), %rbx
addq $0x2, %rbx
cmpq %r12, %rbx
jae 0x40e69
cmpw %r8w, %si
je 0x40e69
movsbq (%rbx), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x40e02
leaq (,%r13,4), %r11
addq %r13, %r11
leaq (%r10,%r11,2), %r13
addq $-0x30, %r13
leaq (%r14,%r8), %rbx
addq $0x3, %rbx
cmpq %r12, %rbx
jae 0x40e02
cmpw %r8w, %cx
je 0x40e02
movsbq (%rbx), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x40e6e
leaq (,%r13,4), %r11
addq %r13, %r11
leaq (%r10,%r11,2), %r13
addq $-0x30, %r13
leaq (%r8,%r14), %r11
addq $0x4, %r11
leaq 0x4(%r8), %r10
cmpq %r12, %r11
jae 0x40df7
addq $0x4, %r9
cmpw %r8w, %di
movq %r10, %r8
jne 0x40d00
addq %r10, %r14
jmp 0x40dff
xorl %r13d, %r13d
movq %r14, %rbx
cmpq %r12, %rbx
jae 0x40e30
callq 0xc170
movq (%rax), %rax
movsbq (%rbx), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x40e30
incq %rbx
cmpq %r12, %rbx
jae 0x40e30
movsbq (%rbx), %rcx
incq %rbx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x40e1d
testq %r15, %r15
je 0x40e50
movq %r13, %rax
negq %rax
setb %cl
testb $0x1, %cl
cmoveq %r13, %rax
cmpl $0x0, -0x2c(%rbp)
cmoveq %r13, %rax
movq %rax, (%r15)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %r8, %r14
jmp 0x40dff
incq %r9
jmp 0x40e72
movq %r10, %rbx
jmp 0x40e02
addq $0x3, %r9
movq %r9, %rbx
jmp 0x40e02