// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: SyBase64Decode
JX9_PRIVATE sxi32 SyBase64Decode(const char *zB64, sxu32 nLen, ProcConsumer xConsumer, void *pUserData)
{
	static const sxu32 aBase64Trans[] = {
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 
	5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 
	28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 
	0, 0, 0
	};
	sxu32 n, w, x, y, z;
	sxi32 rc;
	unsigned char zOut[10];
#if defined(UNTRUST)
	if( SX_EMPTY_STR(zB64) || xConsumer == 0 ){
		return SXERR_EMPTY;
	}
#endif
	while(nLen > 0 && zB64[nLen - 1] == '=' ){
		nLen--;
	}
	for( n = 0 ; n+3<nLen ; n += 4){
		w = aBase64Trans[zB64[n] & 0x7F];
		x = aBase64Trans[zB64[n+1] & 0x7F];
		y = aBase64Trans[zB64[n+2] & 0x7F];
		z = aBase64Trans[zB64[n+3] & 0x7F];
		zOut[0] = ((w<<2) & 0xFC) | ((x>>4) & 0x03);
		zOut[1] = ((x<<4) & 0xF0) | ((y>>2) & 0x0F);
		zOut[2] = ((y<<6) & 0xC0) | (z & 0x3F);

		rc = xConsumer((const void *)zOut, sizeof(unsigned char)*3, pUserData);
		if( rc != SXRET_OK ){ return SXERR_ABORT;}
	}
	if( n+2 < nLen ){
		w = aBase64Trans[zB64[n] & 0x7F];
		x = aBase64Trans[zB64[n+1] & 0x7F];
		y = aBase64Trans[zB64[n+2] & 0x7F];

		zOut[0] = ((w<<2) & 0xFC) | ((x>>4) & 0x03);
		zOut[1] = ((x<<4) & 0xF0) | ((y>>2) & 0x0F);

		rc = xConsumer((const void *)zOut, sizeof(unsigned char)*2, pUserData);
		if( rc != SXRET_OK ){ return SXERR_ABORT;}
	}else if( n+1 < nLen ){
		w = aBase64Trans[zB64[n] & 0x7F];
		x = aBase64Trans[zB64[n+1] & 0x7F];

		zOut[0] = ((w<<2) & 0xFC) | ((x>>4) & 0x03);

		rc = xConsumer((const void *)zOut, sizeof(unsigned char)*1, pUserData);
		if( rc != SXRET_OK ){ return SXERR_ABORT;}
	}
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x14(%rbp)
movb %al, -0x4b(%rbp)
jbe 0x9e40b
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x3d, %eax
sete %al
movb %al, -0x4b(%rbp)
movb -0x4b(%rbp), %al
testb $0x1, %al
jne 0x9e414
jmp 0x9e41f
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x9e3e7
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addl $0x3, %eax
cmpl -0x14(%rbp), %eax
jae 0x9e53c
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
andl $0x7f, %eax
movslq %eax, %rcx
leaq 0x23283(%rip), %rax     # 0xc16d0
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
andl $0x7f, %eax
movslq %eax, %rcx
leaq 0x23260(%rip), %rax     # 0xc16d0
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
andl $0x7f, %eax
movslq %eax, %rcx
leaq 0x2323d(%rip), %rax     # 0xc16d0
movl (%rax,%rcx,4), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
andl $0x7f, %eax
movslq %eax, %rcx
leaq 0x2321a(%rip), %rax     # 0xc16d0
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movl -0x30(%rbp), %eax
shll $0x2, %eax
andl $0xfc, %eax
movl -0x34(%rbp), %ecx
shrl $0x4, %ecx
andl $0x3, %ecx
orl %ecx, %eax
movb %al, -0x4a(%rbp)
movl -0x34(%rbp), %eax
shll $0x4, %eax
andl $0xf0, %eax
movl -0x38(%rbp), %ecx
shrl $0x2, %ecx
andl $0xf, %ecx
orl %ecx, %eax
movb %al, -0x49(%rbp)
movl -0x38(%rbp), %eax
shll $0x6, %eax
andl $0xc0, %eax
movl -0x3c(%rbp), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movb %al, -0x48(%rbp)
movq -0x20(%rbp), %rax
leaq -0x4a(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x3, %esi
callq *%rax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x9e52c
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x9e6a7
jmp 0x9e52e
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
jmp 0x9e426
movl -0x2c(%rbp), %eax
addl $0x2, %eax
cmpl -0x14(%rbp), %eax
jae 0x9e60e
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
andl $0x7f, %eax
movslq %eax, %rcx
leaq 0x2316d(%rip), %rax     # 0xc16d0
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
andl $0x7f, %eax
movslq %eax, %rcx
leaq 0x2314a(%rip), %rax     # 0xc16d0
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
andl $0x7f, %eax
movslq %eax, %rcx
leaq 0x23127(%rip), %rax     # 0xc16d0
movl (%rax,%rcx,4), %eax
movl %eax, -0x38(%rbp)
movl -0x30(%rbp), %eax
shll $0x2, %eax
andl $0xfc, %eax
movl -0x34(%rbp), %ecx
shrl $0x4, %ecx
andl $0x3, %ecx
orl %ecx, %eax
movb %al, -0x4a(%rbp)
movl -0x34(%rbp), %eax
shll $0x4, %eax
andl $0xf0, %eax
movl -0x38(%rbp), %ecx
shrl $0x2, %ecx
andl $0xf, %ecx
orl %ecx, %eax
movb %al, -0x49(%rbp)
movq -0x20(%rbp), %rax
leaq -0x4a(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x2, %esi
callq *%rax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x9e609
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x9e6a7
jmp 0x9e6a0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
cmpl -0x14(%rbp), %eax
jae 0x9e69e
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
andl $0x7f, %eax
movslq %eax, %rcx
leaq 0x2309b(%rip), %rax     # 0xc16d0
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
andl $0x7f, %eax
movslq %eax, %rcx
leaq 0x23078(%rip), %rax     # 0xc16d0
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
shll $0x2, %eax
andl $0xfc, %eax
movl -0x34(%rbp), %ecx
shrl $0x4, %ecx
andl $0x3, %ecx
orl %ecx, %eax
movb %al, -0x4a(%rbp)
movq -0x20(%rbp), %rax
leaq -0x4a(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x1, %esi
callq *%rax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x9e69c
movl $0xfffffff6, -0x4(%rbp) # imm = 0xFFFFFFF6
jmp 0x9e6a7
jmp 0x9e69e
jmp 0x9e6a0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq