// File: /workspace/github_c_makefile_star2_O2/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
subq $0x58, %rsp
movl %esi, %r15d
movq %rdi, %r12
movl %esi, %r14d
addq %rdi, %r14
movq %rdi, -0x30(%rbp)
movq %rdx, -0x48(%rbp)
xorl %r13d, %r13d
cmpq %r14, %r12
jae 0x3d88f
callq 0xc190
movq (%rax), %rcx
movsbq (%r12), %rax
testb $0x20, 0x1(%rcx,%rax,2)
je 0x3d875
incq %r12
jmp 0x3d857
movzbl %al, %eax
cmpl $0x2b, %eax
je 0x3d882
cmpl $0x2d, %eax
jne 0x3d88f
xorl %r13d, %r13d
cmpl $0x2d, %eax
sete %r13b
incq %r12
xorl %edi, %edi
leaq (%r12,%rdi), %rbx
cmpq %r14, %rbx
jae 0x3d8a4
cmpb $0x30, (%rbx)
jne 0x3d8a4
incq %rdi
jmp 0x3d891
movq %r14, -0x38(%rbp)
movq -0x30(%rbp), %rax
addl %r15d, %eax
subl %r12d, %eax
subl %edi, %eax
movw $0xa, %cx
cmpl $0xa, %eax
jb 0x3d8ed
testl %r13d, %r13d
leaq 0x270be(%rip), %rax     # 0x64985
leaq 0x270ac(%rip), %rsi     # 0x6497a
cmoveq %rax, %rsi
movq %rdi, %r14
movq %rbx, %rdi
movl %r15d, %edx
callq 0x2d30e
movq %r14, %rdi
xorl %ecx, %ecx
testl %eax, %eax
setle %cl
addl $0x9, %ecx
movl %r13d, -0x3c(%rbp)
movzwl %cx, %eax
leaq -0x3(%rax), %rcx
movq %rcx, -0x50(%rbp)
leaq -0x2(%rax), %rcx
movq %rcx, -0x58(%rbp)
movq %rax, -0x70(%rbp)
decq %rax
movq %rax, -0x60(%rbp)
leaq (%r12,%rdi), %r15
xorl %r13d, %r13d
xorl %eax, %eax
movq %rdi, -0x68(%rbp)
leaq (%r15,%r13), %r14
cmpq -0x38(%rbp), %r14
movl %eax, -0x30(%rbp)
jae 0x3da23
cmpw %r13w, -0x70(%rbp)
je 0x3da23
leaq (%r12,%r13), %rax
movq %rax, -0x78(%rbp)
callq 0xc190
movq -0x78(%rbp), %r8
movq -0x68(%rbp), %rdi
movq (%rax), %rax
movsbq (%r8,%rdi), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x3da38
imull $0xa, -0x30(%rbp), %edx
addl %ecx, %edx
addl $-0x30, %edx
leaq (%r15,%r13), %rcx
incq %rcx
cmpq -0x38(%rbp), %rcx
jae 0x3d9fb
cmpw %r13w, -0x60(%rbp)
je 0x3d9fb
movsbq 0x1(%r8,%rdi), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x3da07
imull $0xa, %edx, %edx
addl %ecx, %edx
addl $-0x30, %edx
leaq (%r15,%r13), %rcx
addq $0x2, %rcx
cmpq -0x38(%rbp), %rcx
jae 0x3da0f
cmpw %r13w, -0x58(%rbp)
je 0x3da0f
movsbq 0x2(%r8,%rdi), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x3da1c
imull $0xa, %edx, %edx
addl %ecx, %edx
addl $-0x30, %edx
leaq 0x3(%rbx), %r14
leaq (%r15,%r13), %rcx
addq $0x3, %rcx
cmpq -0x38(%rbp), %rcx
jae 0x3da28
cmpw %r13w, -0x50(%rbp)
je 0x3da28
movsbq 0x3(%r8,%rdi), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x3da2d
imull $0xa, %edx, %eax
addl %ecx, %eax
addl $-0x30, %eax
addq $0x4, %rbx
addq $0x4, %r13
jmp 0x3d91c
movl %edx, -0x30(%rbp)
leaq (%r15,%r13), %r14
incq %r14
jmp 0x3da38
movl %edx, -0x30(%rbp)
incq %rbx
jmp 0x3da23
movl %edx, -0x30(%rbp)
leaq (%r15,%r13), %r14
addq $0x2, %r14
jmp 0x3da38
movl %edx, -0x30(%rbp)
addq $0x2, %rbx
movq %rbx, %r14
jmp 0x3da38
movl %edx, -0x30(%rbp)
jmp 0x3da38
movl %edx, -0x30(%rbp)
leaq (%r15,%r13), %r14
addq $0x3, %r14
movq -0x48(%rbp), %rbx
movq -0x38(%rbp), %r15
movl -0x3c(%rbp), %r12d
cmpq %r15, %r14
jae 0x3da5f
callq 0xc190
movq (%rax), %rax
movsbq (%r14), %rcx
incq %r14
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x3da44
testq %rbx, %rbx
je 0x3da7c
movl -0x30(%rbp), %edx
movl %edx, %eax
negl %eax
setb %cl
testb $0x1, %cl
cmovel %edx, %eax
testl %r12d, %r12d
cmovel %edx, %eax
movl %eax, (%rbx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq