// File: /workspace/github_c_makefile_star2_O1/orestesleal[P]base64/base64.c
// Function: b64_dec
unsigned int b64_dec(unsigned char *s, char b[], unsigned int len)
{
	unsigned int x,w,i,rtsize,z;
	unsigned char pad,t,l = 0;
	t = l = pad = 0;

	/* this is non-standard behavior:
		if the input file or stream contains a LINE FEED or CARRIAGE
		RETURN characters  at the end of the file (maybe generated by
		an editor) remove it to allow the padding trimming do his job */
	for (i = len-1; s[i] == '\r' || s[i] == '\n'; i--, --len); 

	/* remove trailing padding and count them, 1 or 2 '='s 
	   for base64 */	
	for (i = len-1; s[i] == PAD; --i) {
		++pad;
		--len;
	}
	w = 0;
	for (i = 0; i < len; i++) {
		for (x = 0, z = 0; z < 4 && i < len; z++, i++) {
			/* if the rfc is modified to include ignoring CRLF or 
			   PAD's in between encoded data the next block of code
			   should be uncommented
		       rfc4648 sec 3.3: */
			/*
			if (s[i] == PAD || 
				s[i] == '\n' || 
				s[i] == '\r') {
				--z;
				--i;
				continue;
			}
			*/

			/*	rfc4648 section 3.3 */ 
			if ((s[i] >= 'A' && s[i] <= 'z') || 
   		   		(s[i] >= '0' && s[i] <= '9') || 
	       		(s[i] == '+' || s[i] == '/') ) {

				/* since the input is in range within the alphabet
				   there is not possibility of failure, loop and 
				   find the position */
				for (t = 0; s[i] != b64_alp[t]; t++);
				x |= t;
				z < 3 && i+1 < len ? x <<= 6 : 0;
			} else {
				fprintf(stderr, "b64_dec: error, non alphabet char found -> %c -> %d\n",
																			s[i], s[i]);
				exit(EXIT_FAILURE);
			}
		}
		for (;z < 4; z++, x <<= 6);
		x <<= 8;
		b[w++] = x >> 24;
		b[w++] = (x << 8) >> 24;
		b[w++] = (x << 16) >> 24;
		--i;
	}
	rtsize = (len >> 2) * 3;
	if (pad) {
		rtsize += pad == 2 ? 1 : 2;
	}
	b[rtsize] = '\0';
	return rtsize; /* number of decoded bytes */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ecx
leal -0x1(%rcx), %edx
movzbl (%rdi,%rdx), %eax
cmpl $0xa, %eax
je 0x1b4a
cmpl $0xd, %eax
je 0x1b4a
leal -0x1(%rcx), %eax
cmpb $0x3d, (%rdi,%rax)
jne 0x1b7e
xorl %r13d, %r13d
movl %ecx, %eax
incb %r13b
leal -0x1(%rax), %ecx
addl $-0x2, %eax
cmpb $0x3d, (%rdi,%rax)
movl %ecx, %eax
je 0x1b6b
jmp 0x1b81
xorl %r13d, %r13d
testl %ecx, %ecx
je 0x1c47
xorl %r8d, %r8d
leaq 0x34fd(%rip), %r9       # 0x5090
xorl %r10d, %r10d
xorl %eax, %eax
xorl %ebx, %ebx
movl %eax, %r11d
movl %r8d, %eax
movzbl (%rdi,%rax), %eax
leal -0x41(%rax), %r14d
cmpb $0x3a, %r14b
setb %r14b
leal -0x30(%rax), %r15d
cmpb $0xa, %r15b
setb %r15b
orb %r14b, %r15b
jne 0x1bd2
movl %eax, %r14d
orl $0x4, %r14d
cmpl $0x2f, %r14d
jne 0x1c76
movb $-0x1, %r14b
incb %r14b
movzbl %r14b, %r15d
movsbl (%r15,%r9), %r12d
cmpl %r12d, %eax
jne 0x1bd5
movl %ebx, %eax
orl %r15d, %eax
incl %r8d
movl %eax, %ebx
shll $0x6, %ebx
cmpl %ecx, %r8d
cmovael %eax, %ebx
cmpl $0x3, %r11d
cmovael %eax, %ebx
jae 0x1c0b
leal 0x1(%r11), %eax
cmpl %ecx, %r8d
jb 0x1b9a
cmpl $0x2, %r11d
ja 0x1c20
movl $0x3, %eax
subl %r11d, %eax
shll $0x6, %ebx
decl %eax
jne 0x1c19
movl %ebx, %eax
shrl $0x10, %eax
leal 0x1(%r10), %edx
movl %r10d, %r11d
movb %al, (%rsi,%r11)
leal 0x2(%r10), %eax
movb %bh, (%rsi,%rdx)
addl $0x3, %r10d
movb %bl, (%rsi,%rax)
cmpl %ecx, %r8d
jb 0x1b96
shrl $0x2, %ecx
xorl %edx, %edx
cmpb $0x2, %r13b
setne %dl
incl %edx
xorl %eax, %eax
testb %r13b, %r13b
cmovnel %edx, %eax
leal (%rcx,%rcx,2), %ecx
addq %rcx, %rax
movb $0x0, (%rsi,%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x117e