// File: /workspace/github_c_makefile_star2_O0/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
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movb $0x0, -0x2b(%rbp)
movb $0x0, -0x29(%rbp)
movb $0x0, -0x2b(%rbp)
movb $0x0, -0x2a(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %ecx
movb $0x1, %al
cmpl $0xd, %ecx
movb %al, -0x2c(%rbp)
je 0x1f55
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xa, %eax
sete %al
movb %al, -0x2c(%rbp)
movb -0x2c(%rbp), %al
testb $0x1, %al
jne 0x1f5e
jmp 0x1f74
jmp 0x1f60
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1f2c
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x3d, %eax
jne 0x1fa9
movb -0x29(%rbp), %al
addb $0x1, %al
movb %al, -0x29(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1f7d
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x2197
movl $0x0, -0x18(%rbp)
movl $0x0, -0x28(%rbp)
xorl %eax, %eax
cmpl $0x4, -0x28(%rbp)
movb %al, -0x2d(%rbp)
jae 0x1fe8
movl -0x20(%rbp), %eax
cmpl -0x14(%rbp), %eax
setb %al
movb %al, -0x2d(%rbp)
movb -0x2d(%rbp), %al
testb $0x1, %al
jne 0x1ff4
jmp 0x20ff
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x41, %eax
jl 0x2014
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x7a, %eax
jle 0x2054
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x30, %eax
jl 0x2034
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x39, %eax
jle 0x2054
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x2b, %eax
je 0x2054
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x20ae
movb $0x0, -0x2a(%rbp)
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x2a(%rbp), %ecx
movl %ecx, %edx
leaq 0x3010(%rip), %rcx      # 0x5080
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x2084
jmp 0x207a
movb -0x2a(%rbp), %al
addb $0x1, %al
movb %al, -0x2a(%rbp)
jmp 0x2058
movzbl -0x2a(%rbp), %eax
orl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
cmpl $0x3, -0x28(%rbp)
jae 0x20aa
movl -0x20(%rbp), %eax
addl $0x1, %eax
cmpl -0x14(%rbp), %eax
jae 0x20aa
movl -0x18(%rbp), %eax
shll $0x6, %eax
movl %eax, -0x18(%rbp)
jmp 0x20ac
jmp 0x20ac
jmp 0x20e6
movq 0x2f43(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %edx
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %ecx
leaq 0xfbc(%rip), %rsi       # 0x3091
movb $0x0, %al
callq 0x1080
movl $0x1, %edi
callq 0x10c0
jmp 0x20e8
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1fd1
jmp 0x2101
cmpl $0x4, -0x28(%rbp)
jae 0x211d
jmp 0x2109
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x18(%rbp), %eax
shll $0x6, %eax
movl %eax, -0x18(%rbp)
jmp 0x2101
movl -0x18(%rbp), %eax
shll $0x8, %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
shrl $0x18, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x1c(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x18(%rbp), %eax
shll $0x8, %eax
shrl $0x18, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x1c(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x18(%rbp), %eax
shll $0x10, %eax
shrl $0x18, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x1c(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1fb7
movl -0x14(%rbp), %eax
shrl $0x2, %eax
imull $0x3, %eax, %eax
movl %eax, -0x24(%rbp)
cmpb $0x0, -0x29(%rbp)
je 0x21c3
movzbl -0x29(%rbp), %edx
movl $0x2, %eax
movl $0x1, %ecx
cmpl $0x2, %edx
cmovel %ecx, %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl -0x24(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)