// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: SyStrToInt32
JX9_PRIVATE sxi32 SyStrToInt32(const char *zSrc, sxu32 nLen, void * pOutVal, const char **zRest)
{
	int isNeg = FALSE;
	const char *zEnd;
	sxi32 nVal = 0;
	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 = 10;
	if( (sxu32)(zEnd-zSrc) >= 10 ){
		/* Handle overflow */
		i = SyMemcmp(zSrc, (isNeg == TRUE) ? SXINT32_MIN_STR : SXINT32_MAX_STR, nLen) <= 0 ? 10 : 9; 
	}
	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;
		}
		*(sxi32 *)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)
movl %esi, %r15d
movq %rdi, %rbx
movl %esi, %r13d
addq %rdi, %r13
xorl %r12d, %r12d
testl %esi, %esi
je 0x46c0a
callq 0xc170
movq (%rax), %rax
movsbq (%rbx), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x46bf0
incq %rbx
cmpq %r13, %rbx
jb 0x46bdb
jmp 0x46c0a
movzbl %cl, %eax
cmpl $0x2b, %eax
je 0x46bfd
cmpl $0x2d, %eax
jne 0x46c0a
xorl %r12d, %r12d
cmpl $0x2d, %eax
sete %r12b
incq %rbx
cmpq %r13, %rbx
jae 0x46c14
cmpb $0x30, (%rbx)
je 0x46c07
movl %r13d, %eax
subl %ebx, %eax
movw $0xa, %r14w
cmpl $0xa, %eax
jb 0x46c50
testl %r12d, %r12d
leaq 0x2dd78(%rip), %rax     # 0x749a5
leaq 0x2dd66(%rip), %rsi     # 0x7499a
cmoveq %rax, %rsi
movq %rbx, %rdi
movl %r15d, %edx
callq 0x347f1
xorl %r14d, %r14d
testl %eax, %eax
setle %r14b
addl $0x9, %r14d
xorl %r15d, %r15d
cmpq %r13, %rbx
jae 0x46d69
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 %r15d, %r15d
movq %rbx, %r9
movsbq (%rbx,%r8), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x46d66
leal (%r15,%r15,4), %r11d
leal (%r10,%r11,2), %r15d
addl $-0x30, %r15d
leaq 0x1(%r9), %r10
leaq (%rbx,%r8), %r14
incq %r14
cmpq %r13, %r14
jae 0x46d61
cmpw %r8w, %dx
je 0x46d61
movsbq (%r14), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x46d6c
leal (%r15,%r15,4), %r11d
leal (%r10,%r11,2), %r15d
addl $-0x30, %r15d
leaq (%rbx,%r8), %r14
addq $0x2, %r14
cmpq %r13, %r14
jae 0x46d6c
cmpw %r8w, %si
je 0x46d6c
movsbq (%r14), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x46dc4
leal (%r15,%r15,4), %r11d
leal (%r10,%r11,2), %r15d
addl $-0x30, %r15d
leaq 0x3(%r9), %r10
leaq (%rbx,%r8), %r14
addq $0x3, %r14
cmpq %r13, %r14
jae 0x46d61
cmpw %r8w, %cx
je 0x46d61
movsbq (%r14), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x46d6c
leal (%r15,%r15,4), %r11d
leal (%r10,%r11,2), %r15d
addl $-0x30, %r15d
leaq (%r8,%rbx), %r11
addq $0x4, %r11
leaq 0x4(%r8), %r10
cmpq %r13, %r11
jae 0x46d5c
addq $0x4, %r9
cmpw %r8w, %di
movq %r10, %r8
jne 0x46c81
addq %r10, %rbx
jmp 0x46d69
movq %r10, %r14
jmp 0x46d6c
addq %r8, %rbx
movq %rbx, %r14
cmpq %r13, %r14
movq -0x30(%rbp), %rbx
jae 0x46d98
callq 0xc170
movq (%rax), %rax
incq %r14
movsbq -0x1(%r14), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x46d98
leaq 0x1(%r14), %rcx
cmpq %r13, %r14
movq %rcx, %r14
jb 0x46d80
testq %rbx, %rbx
je 0x46db5
movl %r15d, %eax
negl %eax
setb %cl
testb $0x1, %cl
cmovel %r15d, %eax
testl %r12d, %r12d
cmovel %r15d, %eax
movl %eax, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x2, %r9
movq %r9, %r14
jmp 0x46d6c