// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/base64.c
// Function: base64Decode
char *base64Decode(char *input, size_t *returnSize)
/* Use base64 to decode a string.  Return decoded
 * string which will be freeMem'd. Note: big-endian algorithm.
 * Call eraseWhiteSpace() and check for invalid input 
 * before passing in input if needed.  
 * Optionally set return size for use with binary data.
 */
{
static int *map=NULL;
char b64[] = B64CHARS;
size_t inplen = strlen(input);
int words = (inplen+3)/4;
char *result = (char *)needMem(3*words+1);
size_t i=0, j=0;
int word = 0;
char *p = input;

if (!map)
    {
    int i = 0;
    map = needMem(256*sizeof(int));
    for (i = 0; i < 256; ++i)
	{
	map[i]=0;
	}
    for (i = 0; i < 64; ++i)
	{
	map[(int)b64[i]]=i;
	}
    }
for(i=0; i<words; i++)
    {
    word = 0;
    word |= map[(int)*p++];
    word <<= 6;
    word |= map[(int)*p++];
    word <<= 6;
    word |= map[(int)*p++];
    word <<= 6;
    word |= map[(int)*p++];
    result[j++]=word >> 16 & 0xFF;
    result[j++]=word >> 8 & 0xFF;
    result[j++]=word & 0xFF;
    }
result[j] = 0;
if (returnSize)
    *returnSize = j;
     
return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x60(%rbp), %rdi
leaq 0x7e7b2(%rip), %rsi     # 0xdf3d0
movl $0x41, %edx
callq 0x6570
movq -0x8(%rbp), %rdi
callq 0x62c0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
addq $0x3, %rax
shrq $0x2, %rax
movl %eax, -0x6c(%rbp)
imull $0x3, -0x6c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x40c50
movq %rax, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movl $0x0, -0x8c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, 0xa99d9(%rip)     # 0x10a660
jne 0x60d29
movl $0x0, -0x9c(%rbp)
movl $0x400, %edi            # imm = 0x400
callq 0x40c50
movq %rax, 0xa99b8(%rip)     # 0x10a660
movl $0x0, -0x9c(%rbp)
cmpl $0x100, -0x9c(%rbp)     # imm = 0x100
jge 0x60ce4
movq 0xa999b(%rip), %rax     # 0x10a660
movslq -0x9c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x60cb2
movl $0x0, -0x9c(%rbp)
cmpl $0x40, -0x9c(%rbp)
jge 0x60d27
movl -0x9c(%rbp), %edx
movq 0xa995c(%rip), %rax     # 0x10a660
movslq -0x9c(%rbp), %rcx
movsbl -0x60(%rbp,%rcx), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x60cee
jmp 0x60d29
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
movslq -0x6c(%rbp), %rcx
cmpq %rcx, %rax
jae 0x60ecf
movl $0x0, -0x8c(%rbp)
movq 0xa990d(%rip), %rax     # 0x10a660
movq -0x98(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x98(%rbp)
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
orl -0x8c(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
shll $0x6, %eax
movl %eax, -0x8c(%rbp)
movq 0xa98cd(%rip), %rax     # 0x10a660
movq -0x98(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x98(%rbp)
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
orl -0x8c(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
shll $0x6, %eax
movl %eax, -0x8c(%rbp)
movq 0xa988d(%rip), %rax     # 0x10a660
movq -0x98(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x98(%rbp)
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
orl -0x8c(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
shll $0x6, %eax
movl %eax, -0x8c(%rbp)
movq 0xa984d(%rip), %rax     # 0x10a660
movq -0x98(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x98(%rbp)
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
orl -0x8c(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
sarl $0x10, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x78(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x88(%rbp)
movb %dl, (%rax,%rcx)
movl -0x8c(%rbp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x78(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x88(%rbp)
movb %dl, (%rax,%rcx)
movl -0x8c(%rbp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x78(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x88(%rbp)
movb %dl, (%rax,%rcx)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x60d31
movq -0x78(%rbp), %rax
movq -0x88(%rbp), %rcx
movb $0x0, (%rax,%rcx)
cmpq $0x0, -0x10(%rbp)
je 0x60ef3
movq -0x88(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x78(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq