// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: SyOctalStrToInt64
JX9_PRIVATE sxi32 SyOctalStrToInt64(const char *zSrc, sxu32 nLen, void * pOutVal, const char **zRest)
{
	const char *zIn, *zEnd;
	int isNeg = FALSE;
	sxi64 nVal = 0;
	int c;
#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++; 
	}
	zIn = zSrc;
	for(;;){
		if(zSrc >= zEnd || !SyisDigit(zSrc[0])){ break; } if( (c=zSrc[0]-'0') > 7 || (int)(zSrc-zIn) > 20){ break;} nVal = nVal * 8 +  c; zSrc++;
		if(zSrc >= zEnd || !SyisDigit(zSrc[0])){ break; } if( (c=zSrc[0]-'0') > 7 || (int)(zSrc-zIn) > 20){ break;} nVal = nVal * 8 +  c; zSrc++;
		if(zSrc >= zEnd || !SyisDigit(zSrc[0])){ break; } if( (c=zSrc[0]-'0') > 7 || (int)(zSrc-zIn) > 20){ break;} nVal = nVal * 8 +  c; zSrc++;
		if(zSrc >= zEnd || !SyisDigit(zSrc[0])){ break; } if( (c=zSrc[0]-'0') > 7 || (int)(zSrc-zIn) > 20){ break;} nVal = nVal * 8 +  c; zSrc++;
	}
	/* Skip trailing spaces */
	while(zSrc < zEnd && SyisSpace(zSrc[0])){
		zSrc++;
	}
	if( zRest ){
		*zRest = 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, %rbx
movq %rdi, %r14
movl %esi, %r15d
addq %rdi, %r15
testl %esi, %esi
je 0x40aa1
callq 0xc170
movq (%rax), %rax
movsbq (%r14), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x40a89
incq %r14
cmpq %r15, %r14
jb 0x40a74
jmp 0x40aa1
movzbl %cl, %eax
cmpl $0x2b, %eax
je 0x40a96
cmpl $0x2d, %eax
jne 0x40aa1
cmpl $0x2d, %eax
sete %al
movl %eax, -0x2c(%rbp)
jmp 0x40aaa
movl $0x0, -0x2c(%rbp)
jmp 0x40aad
incq %r14
cmpq %r15, %r14
jae 0x40ab8
cmpb $0x30, (%r14)
je 0x40aaa
cmpq %r15, %r14
jae 0x40bc2
callq 0xc170
movq (%rax), %rcx
xorl %eax, %eax
xorl %r13d, %r13d
movq %r14, %rdx
movb (%r14,%rax), %dil
movsbq %dil, %rsi
testb $0x8, 0x1(%rcx,%rsi,2)
je 0x40bbd
cmpb $0x37, %dil
jg 0x40bbd
leaq (%rsi,%r13,8), %r13
addq $-0x30, %r13
leaq 0x1(%rdx), %rdi
leaq (%r14,%rax), %r12
incq %r12
cmpq %r15, %r12
jae 0x40bca
movsbq (%r12), %rsi
testb $0x8, 0x1(%rcx,%rsi,2)
je 0x40bca
leal 0x1(%rax), %edi
cmpl $0x14, %edi
jg 0x40bd2
cmpb $0x37, %sil
jg 0x40bd2
leaq (%rsi,%r13,8), %r13
addq $-0x30, %r13
leaq 0x2(%rdx), %rsi
leaq (%r14,%rax), %r12
addq $0x2, %r12
cmpq %r15, %r12
jae 0x40bcf
movsbq (%r12), %rdi
testb $0x8, 0x1(%rcx,%rdi,2)
je 0x40bd2
leal 0x2(%rax), %r8d
cmpl $0x14, %r8d
jg 0x40bcf
cmpb $0x37, %dil
jg 0x40bcf
leaq (%rdi,%r13,8), %r13
addq $-0x30, %r13
leaq 0x3(%rdx), %rdi
leaq (%r14,%rax), %r12
addq $0x3, %r12
cmpq %r15, %r12
jae 0x40bca
movsbq (%r12), %rsi
testb $0x8, 0x1(%rcx,%rsi,2)
je 0x40bca
leal 0x3(%rax), %edi
cmpl $0x14, %edi
jg 0x40bd2
cmpb $0x37, %sil
jg 0x40bd2
leaq (%rsi,%r13,8), %r13
addq $-0x30, %r13
addq $0x4, %rdx
leaq (%r14,%rax), %rsi
addq $0x4, %rsi
addq $0x4, %rax
cmpq %r15, %rsi
jb 0x40ad1
addq %rax, %r14
jmp 0x40bc5
xorl %r13d, %r13d
movq %r14, %r12
jmp 0x40bd2
movq %rdi, %r12
jmp 0x40bd2
movq %rsi, %r12
cmpq %r15, %r12
jae 0x40c02
callq 0xc170
movq (%rax), %rax
movsbq (%r12), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x40c02
incq %r12
cmpq %r15, %r12
jae 0x40c02
movsbq (%r12), %rcx
incq %r12
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x40bee
testq %rbx, %rbx
je 0x40c22
movq %r13, %rax
negq %rax
setb %cl
testb $0x1, %cl
cmoveq %r13, %rax
cmpb $0x0, -0x2c(%rbp)
cmoveq %r13, %rax
movq %rax, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq