// File: /workspace/github_c_makefile_star2_O3/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, %r12
movl %esi, %r15d
addq %rdi, %r15
testl %esi, %esi
je 0x4007e
callq 0xc170
movq (%rax), %rax
movsbq (%r12), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x40066
incq %r12
cmpq %r15, %r12
jb 0x40050
jmp 0x4007e
movzbl %cl, %eax
cmpl $0x2b, %eax
je 0x40073
cmpl $0x2d, %eax
jne 0x4007e
cmpl $0x2d, %eax
sete %al
movl %eax, -0x2c(%rbp)
jmp 0x40087
movl $0x0, -0x2c(%rbp)
jmp 0x4008a
incq %r12
cmpq %r15, %r12
jae 0x40096
cmpb $0x30, (%r12)
je 0x40087
cmpq %r15, %r12
jae 0x4019f
callq 0xc170
movq (%rax), %rcx
xorl %eax, %eax
xorl %r13d, %r13d
movq %r12, %rdx
movb (%r12,%rax), %dil
movsbq %dil, %rsi
testb $0x8, 0x1(%rcx,%rsi,2)
je 0x4019a
cmpb $0x37, %dil
jg 0x4019a
leaq (%rsi,%r13,8), %r13
addq $-0x30, %r13
leaq 0x1(%rdx), %rsi
leaq (%r12,%rax), %r14
incq %r14
cmpq %r15, %r14
jae 0x401a7
movsbq (%r14), %rdi
testb $0x8, 0x1(%rcx,%rdi,2)
je 0x401af
leal 0x1(%rax), %r8d
cmpl $0x14, %r8d
jg 0x401a7
cmpb $0x37, %dil
jg 0x401a7
leaq (%rdi,%r13,8), %r13
addq $-0x30, %r13
leaq 0x2(%rdx), %rdi
leaq (%r12,%rax), %r14
addq $0x2, %r14
cmpq %r15, %r14
jae 0x401ac
movsbq (%r14), %rsi
testb $0x8, 0x1(%rcx,%rsi,2)
je 0x401ac
leal 0x2(%rax), %edi
cmpl $0x14, %edi
jg 0x401af
cmpb $0x37, %sil
jg 0x401af
leaq (%rsi,%r13,8), %r13
addq $-0x30, %r13
leaq 0x3(%rdx), %rsi
leaq (%r12,%rax), %r14
addq $0x3, %r14
cmpq %r15, %r14
jae 0x401a7
movsbq (%r14), %rdi
testb $0x8, 0x1(%rcx,%rdi,2)
je 0x401af
leal 0x3(%rax), %r8d
cmpl $0x14, %r8d
jg 0x401a7
cmpb $0x37, %dil
jg 0x401a7
leaq (%rdi,%r13,8), %r13
addq $-0x30, %r13
addq $0x4, %rdx
leaq (%r12,%rax), %rsi
addq $0x4, %rsi
addq $0x4, %rax
cmpq %r15, %rsi
jb 0x400af
addq %rax, %r12
jmp 0x401a2
xorl %r13d, %r13d
movq %r12, %r14
jmp 0x401af
movq %rsi, %r14
jmp 0x401af
movq %rdi, %r14
cmpq %r15, %r14
jae 0x401d7
callq 0xc170
movq (%rax), %rax
incq %r14
movsbq -0x1(%r14), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x401d7
leaq 0x1(%r14), %rcx
cmpq %r15, %r14
movq %rcx, %r14
jb 0x401bf
testq %rbx, %rbx
je 0x401f7
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