// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: SyStrToReal
JX9_PRIVATE sxi32 SyStrToReal(const char *zSrc, sxu32 nLen, void * pOutVal, const char **zRest)
{
#define SXDBL_DIG        15
#define SXDBL_MAX_EXP    308
#define SXDBL_MIN_EXP_PLUS	307
	static const sxreal aTab[] = {
	10, 
	1.0e2, 
	1.0e4, 
	1.0e8, 
	1.0e16, 
	1.0e32, 
	1.0e64, 
	1.0e128, 
	1.0e256
	};
	sxu8 neg = FALSE;
	sxreal Val = 0.0;
	const char *zEnd;
	sxi32 Lim, exp;
	sxreal *p = 0;
#ifdef UNTRUST
	if( SX_EMPTY_STR(zSrc)  ){
		if( pOutVal ){
			*(sxreal *)pOutVal = 0.0;
		}
		return SXERR_EMPTY;
	}
#endif
	zEnd = &zSrc[nLen];
	while( zSrc < zEnd && SyisSpace(zSrc[0]) ){
		zSrc++; 
	}
	if( zSrc < zEnd && (zSrc[0] == '-' || zSrc[0] == '+' ) ){
		neg =  zSrc[0] == '-' ? TRUE : FALSE ;
		zSrc++;
	}
	Lim = SXDBL_DIG ;
	for(;;){
		if(zSrc >= zEnd||!Lim||!SyisDigit(zSrc[0])) break ; Val = Val * 10.0 + (zSrc[0] - '0') ; zSrc++ ; --Lim;
		if(zSrc >= zEnd||!Lim||!SyisDigit(zSrc[0])) break ; Val = Val * 10.0 + (zSrc[0] - '0') ; zSrc++ ; --Lim;
		if(zSrc >= zEnd||!Lim||!SyisDigit(zSrc[0])) break ; Val = Val * 10.0 + (zSrc[0] - '0') ; zSrc++ ; --Lim;
		if(zSrc >= zEnd||!Lim||!SyisDigit(zSrc[0])) break ; Val = Val * 10.0 + (zSrc[0] - '0') ; zSrc++ ; --Lim;
	}
	if( zSrc < zEnd && ( zSrc[0] == '.' || zSrc[0] == ',' ) ){
		sxreal dec = 1.0;
		zSrc++;
		for(;;){
			if(zSrc >= zEnd||!Lim||!SyisDigit(zSrc[0])) break ; Val = Val * 10.0 + (zSrc[0] - '0') ; dec *= 10.0; zSrc++ ;--Lim;
			if(zSrc >= zEnd||!Lim||!SyisDigit(zSrc[0])) break ; Val = Val * 10.0 + (zSrc[0] - '0') ; dec *= 10.0; zSrc++ ;--Lim;
			if(zSrc >= zEnd||!Lim||!SyisDigit(zSrc[0])) break ; Val = Val * 10.0 + (zSrc[0] - '0') ; dec *= 10.0; zSrc++ ;--Lim;
			if(zSrc >= zEnd||!Lim||!SyisDigit(zSrc[0])) break ; Val = Val * 10.0 + (zSrc[0] - '0') ; dec *= 10.0; zSrc++ ;--Lim;
		}
		Val /= dec;
	}
	if( neg == TRUE && Val != 0.0 ) {
		Val = -Val ; 
	}
	if( Lim <= 0 ){
		/* jump overflow digit */
		while( zSrc < zEnd ){
			if( zSrc[0] == 'e' || zSrc[0] == 'E' ){
				break;  
			}
			zSrc++;
		}
	}
	neg = FALSE;
	if( zSrc < zEnd && ( zSrc[0] == 'e' || zSrc[0] == 'E' ) ){
		zSrc++;
		if( zSrc < zEnd && ( zSrc[0] == '-' || zSrc[0] == '+') ){
			neg = zSrc[0] == '-' ? TRUE : FALSE ;
			zSrc++;
		}
		exp = 0;
		while( zSrc < zEnd && SyisDigit(zSrc[0]) && exp < SXDBL_MAX_EXP ){
			exp = exp * 10 + (zSrc[0] - '0');
			zSrc++;
		}
		if( neg  ){
			if( exp > SXDBL_MIN_EXP_PLUS ) exp = SXDBL_MIN_EXP_PLUS ;
		}else if ( exp > SXDBL_MAX_EXP ){
			exp = SXDBL_MAX_EXP; 
		}		
		for( p = (sxreal *)aTab ; exp ; exp >>= 1 , p++ ){
			if( exp & 01 ){
				if( neg ){
					Val /= *p ;
				}else{
					Val *= *p;
				}
			}
		}
	}
	while( zSrc < zEnd && SyisSpace(zSrc[0]) ){
		zSrc++;
	}
	if( zRest ){
		*zRest = zSrc; 
	}
	if( pOutVal ){
		*(sxreal *)pOutVal = Val;
	}
	return zSrc >= zEnd ? SXRET_OK : SXERR_SYNTAX;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
movl %esi, %r15d
addq %rdi, %r15
testl %esi, %esi
movq %rdx, -0x48(%rbp)
je 0x3e9c0
callq 0xc170
movq (%rax), %rax
movsbq (%r14), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x3e9a7
incq %r14
cmpq %r15, %r14
jb 0x3e992
jmp 0x3e9c0
movzbl %cl, %eax
cmpl $0x2b, %eax
je 0x3e9b4
cmpl $0x2d, %eax
jne 0x3e9c0
cmpl $0x2d, %eax
sete %r12b
incq %r14
jmp 0x3e9c3
xorl %r12d, %r12d
cmpq %r15, %r14
jae 0x3eac0
callq 0xc170
movq (%rax), %rcx
xorpd %xmm3, %xmm3
movl $0xf, %ebx
xorl %eax, %eax
movsd 0x34c01(%rip), %xmm0    # 0x735e8
movq %r14, %r13
movsbq (%r14,%rax), %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
je 0x3eddf
addl $-0x30, %edx
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
mulsd %xmm0, %xmm3
addsd %xmm1, %xmm3
leaq (%r14,%rax), %rdx
incq %rdx
cmpq %r15, %rdx
jae 0x3eace
movsbq (%rdx), %rsi
testb $0x8, 0x1(%rcx,%rsi,2)
je 0x3eace
addl $-0x30, %esi
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd %xmm0, %xmm3
addsd %xmm1, %xmm3
leaq (%r14,%rax), %rdx
addq $0x2, %rdx
cmpq %r15, %rdx
jae 0x3ead5
movsbq (%rdx), %rsi
testb $0x8, 0x1(%rcx,%rsi,2)
je 0x3ead5
addl $-0x30, %esi
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd %xmm0, %xmm3
addsd %xmm1, %xmm3
leaq (%r14,%rax), %rdx
addq $0x3, %rdx
cmpq %r15, %rdx
jae 0x3eae1
cmpl $0xc, %eax
je 0x3eae1
movsbq (%rdx), %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
je 0x3eae1
addl $-0x30, %edx
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
mulsd %xmm0, %xmm3
addsd %xmm1, %xmm3
addq $0x4, %r13
addl $-0x4, %ebx
leaq (%rax,%r14), %rdx
addq $0x4, %rdx
cmpq %r15, %rdx
jae 0x3eae8
leaq 0x4(%rax), %rdx
cmpl $0xb, %eax
movq %rdx, %rax
jne 0x3e9ea
jmp 0x3eae8
movl $0xf, %ebx
xorpd %xmm3, %xmm3
movq %r14, %r13
jmp 0x3eae8
movl $0xe, %ebx
jmp 0x3eada
movl $0xd, %ebx
subl %eax, %ebx
movq %rdx, %r13
jmp 0x3eae8
addq $0x3, %r13
addl $-0x3, %ebx
cmpq %r15, %r13
jae 0x3ec81
movzbl (%r13), %eax
orl $0x2, %eax
cmpl $0x2e, %eax
jne 0x3ec81
leaq 0x1(%r13), %r14
movsd 0x34ae2(%rip), %xmm0    # 0x735f0
cmpq %r15, %r14
jae 0x3ec7a
testl %ebx, %ebx
je 0x3ec7a
movapd %xmm3, -0x40(%rbp)
callq 0xc170
movapd -0x40(%rbp), %xmm3
movq (%rax), %rax
movl %ebx, %ecx
leaq -0x1(%rcx), %rdx
leaq -0x2(%rcx), %rsi
leaq -0x3(%rcx), %rdi
addq $-0x4, %rcx
movsd 0x34aa5(%rip), %xmm0    # 0x735f0
xorl %r8d, %r8d
movsd 0x34a92(%rip), %xmm1    # 0x735e8
movsbq 0x1(%r13,%r8), %r9
testb $0x8, 0x1(%rax,%r9,2)
je 0x3ede7
addl $-0x30, %r9d
xorps %xmm2, %xmm2
cvtsi2sd %r9d, %xmm2
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
mulsd %xmm1, %xmm0
leaq 0x1(%r14), %r9
leaq (%r8,%r13), %r11
addq $0x2, %r11
leal -0x1(%rbx), %r10d
cmpq %r15, %r11
jae 0x3ec74
cmpl %r8d, %edx
je 0x3ec74
movsbq (%r11), %r11
testb $0x8, 0x1(%rax,%r11,2)
je 0x3ec74
addl $-0x30, %r11d
xorps %xmm2, %xmm2
cvtsi2sd %r11d, %xmm2
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
mulsd %xmm1, %xmm0
leaq 0x2(%r14), %r9
leaq (%r8,%r13), %r11
addq $0x3, %r11
leal -0x2(%rbx), %r10d
cmpq %r15, %r11
jae 0x3ec74
cmpl %r8d, %esi
je 0x3ec74
movsbq (%r11), %r11
testb $0x8, 0x1(%rax,%r11,2)
je 0x3ec74
addl $-0x30, %r11d
xorps %xmm2, %xmm2
cvtsi2sd %r11d, %xmm2
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
mulsd %xmm1, %xmm0
leaq 0x3(%r14), %r9
leaq (%r8,%r13), %r11
addq $0x4, %r11
leal -0x3(%rbx), %r10d
cmpq %r15, %r11
jae 0x3ec74
cmpl %r8d, %edi
je 0x3ec74
movsbq (%r11), %r11
testb $0x8, 0x1(%rax,%r11,2)
je 0x3ec74
addl $-0x30, %r11d
xorps %xmm2, %xmm2
cvtsi2sd %r11d, %xmm2
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
mulsd %xmm1, %xmm0
addq $0x4, %r14
addl $-0x4, %ebx
leaq (%r8,%r13), %r9
addq $0x5, %r9
cmpq %r15, %r9
jae 0x3ec7a
leaq 0x4(%r8), %r9
cmpl %r8d, %ecx
movq %r9, %r8
jne 0x3eb56
jmp 0x3ec7a
movq %r9, %r14
movl %r10d, %ebx
divsd %xmm0, %xmm3
movq %r14, %r13
testb %r12b, %r12b
je 0x3ecab
movapd 0x34982(%rip), %xmm0    # 0x73610
xorpd %xmm3, %xmm0
movapd %xmm3, %xmm1
cmpneqsd %xmm0, %xmm1
andpd %xmm1, %xmm0
andnpd %xmm3, %xmm1
orpd %xmm0, %xmm1
movapd %xmm1, %xmm3
movq -0x48(%rbp), %r12
testl %ebx, %ebx
jg 0x3ecca
cmpq %r15, %r13
jae 0x3ecca
movzbl (%r13), %eax
orl $0x20, %eax
cmpl $0x65, %eax
je 0x3ecca
incq %r13
jmp 0x3ecb3
cmpq %r15, %r13
jae 0x3ed93
movzbl (%r13), %eax
orl $0x20, %eax
cmpl $0x65, %eax
jne 0x3ed93
leaq 0x1(%r13), %rbx
movb $0x1, %r14b
cmpq %r15, %rbx
jae 0x3ed0a
movzbl (%rbx), %eax
cmpl $0x2d, %eax
je 0x3ecfd
cmpl $0x2b, %eax
jne 0x3ed0a
cmpb $0x2d, %al
setne %r14b
addq $0x2, %r13
movq %r13, %rbx
xorl %eax, %eax
cmpq %r15, %rbx
jae 0x3ed48
movapd %xmm3, -0x40(%rbp)
callq 0xc170
movapd -0x40(%rbp), %xmm3
movq (%rax), %rcx
xorl %eax, %eax
movsbq (%rbx), %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
je 0x3ed48
cmpl $0x133, %eax            # imm = 0x133
jg 0x3ed48
leal (%rax,%rax,4), %eax
leal (%rdx,%rax,2), %eax
addl $-0x30, %eax
incq %rbx
cmpq %r15, %rbx
jb 0x3ed25
testb %r14b, %r14b
je 0x3ed54
movl $0x134, %ecx            # imm = 0x134
jmp 0x3ed59
movl $0x133, %ecx            # imm = 0x133
cmpl %ecx, %eax
cmovll %eax, %ecx
testl %ecx, %ecx
je 0x3ed90
leaq 0x33e77(%rip), %rax     # 0x72be0
testb $0x1, %cl
je 0x3ed81
movsd (%rax), %xmm0
testb %r14b, %r14b
je 0x3ed7d
mulsd %xmm0, %xmm3
jmp 0x3ed81
divsd %xmm0, %xmm3
movl %ecx, %edx
sarl %edx
addq $0x8, %rax
cmpl $0x1, %ecx
movl %edx, %ecx
ja 0x3ed69
movq %rbx, %r13
cmpq %r15, %r13
jae 0x3edc5
movapd %xmm3, -0x40(%rbp)
callq 0xc170
movapd -0x40(%rbp), %xmm3
movq (%rax), %rax
incq %r13
movsbq -0x1(%r13), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x3edc5
leaq 0x1(%r13), %rcx
cmpq %r15, %r13
movq %rcx, %r13
jb 0x3edad
testq %r12, %r12
je 0x3edd0
movsd %xmm3, (%r12)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %rax, %r14
jmp 0x3eac9
leaq (%r8,%r13), %r14
incq %r14
jmp 0x3ec7a