// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movl %esi, %r15d
movq %rdi, %r14
movl %esi, %r13d
addq %rdi, %r13
xorl %r12d, %r12d
testl %esi, %esi
je 0x47c3c
callq 0xc170
movq (%rax), %rax
movsbq (%r14), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x47c22
incq %r14
cmpq %r13, %r14
jb 0x47c0d
jmp 0x47c3c
movzbl %cl, %eax
cmpl $0x2b, %eax
je 0x47c2f
cmpl $0x2d, %eax
jne 0x47c3c
xorl %r12d, %r12d
cmpl $0x2d, %eax
sete %r12b
incq %r14
cmpq %r13, %r14
jae 0x47c47
cmpb $0x30, (%r14)
je 0x47c39
movq %rbx, -0x30(%rbp)
movl %r13d, %eax
subl %r14d, %eax
movw $0xa, %bx
cmpl $0xa, %eax
jb 0x47c84
testl %r12d, %r12d
leaq 0x2ed39(%rip), %rax     # 0x7699d
leaq 0x2ed27(%rip), %rsi     # 0x76992
cmoveq %rax, %rsi
movq %r14, %rdi
movl %r15d, %edx
callq 0x34ebe
xorl %ebx, %ebx
testl %eax, %eax
setle %bl
addl $0x9, %ebx
xorl %r15d, %r15d
cmpq %r13, %r14
jae 0x47d97
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 %r15d, %r15d
movq %r14, %r9
movsbq (%r14,%r8), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x47d94
leal (%r15,%r15,4), %r11d
leal (%r10,%r11,2), %r15d
addl $-0x30, %r15d
leaq (%r14,%r8), %rbx
incq %rbx
cmpq %r13, %rbx
jae 0x47d9a
cmpw %r8w, %dx
je 0x47d9a
movsbq (%rbx), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x47df8
leal (%r15,%r15,4), %r11d
leal (%r10,%r11,2), %r15d
addl $-0x30, %r15d
leaq 0x2(%r9), %r10
leaq (%r14,%r8), %rbx
addq $0x2, %rbx
cmpq %r13, %rbx
jae 0x47dfd
cmpw %r8w, %si
je 0x47dfd
movsbq (%rbx), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x47d9a
leal (%r15,%r15,4), %r11d
leal (%r10,%r11,2), %r15d
addl $-0x30, %r15d
leaq (%r14,%r8), %rbx
addq $0x3, %rbx
cmpq %r13, %rbx
jae 0x47d9a
cmpw %r8w, %cx
je 0x47d9a
movsbq (%rbx), %r10
testb $0x8, 0x1(%rax,%r10,2)
je 0x47e02
leal (%r15,%r15,4), %r11d
leal (%r10,%r11,2), %r15d
addl $-0x30, %r15d
leaq (%r8,%r14), %r11
addq $0x4, %r11
leaq 0x4(%r8), %r10
cmpq %r13, %r11
jae 0x47d8f
addq $0x4, %r9
cmpw %r8w, %di
movq %r10, %r8
jne 0x47cb4
addq %r10, %r14
jmp 0x47d97
addq %r8, %r14
movq %r14, %rbx
cmpq %r13, %rbx
jae 0x47dc8
callq 0xc170
movq (%rax), %rax
movsbq (%rbx), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x47dc8
incq %rbx
cmpq %r13, %rbx
jae 0x47dc8
movsbq (%rbx), %rcx
incq %rbx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x47db5
movq -0x30(%rbp), %rdx
testq %rdx, %rdx
je 0x47de9
movl %r15d, %eax
negl %eax
setb %cl
testb $0x1, %cl
cmovel %r15d, %eax
testl %r12d, %r12d
cmovel %r15d, %eax
movl %eax, (%rdx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incq %r9
jmp 0x47e06
movq %r10, %rbx
jmp 0x47d9a
addq $0x3, %r9
movq %r9, %rbx
jmp 0x47d9a