// File: /workspace/github_c_makefile_star2_O2/inflex[P]ripMIME/libmime-decoders.c
// Function: MDECODE_decode_short64
int MDECODE_decode_short64( char *short64 )
{
    int i;
    int realm_size = strlen( short64 );
    int stopcount = 0; /* How many stop (=) characters we've read in */
    int c; /* a single char as retrieved using MDECODE_get_char() */
    int char_count = 0; /* How many chars have been received */
    char output[3]; /* The 4->3 byte output array */
    char input[4]; /* The 4->3 byte input array */
    char *outstring = short64;

    char_count = 0;
    while (char_count < realm_size)
    {
        /* Initialise the decode buffer */
        input[0] = input[1] = input[2] = input[3] = 0;

        /* snatch 4 characters from the input */
        for (i = 0; i < 4; i++) {
            /* get a char from the filestream */
            c = *short64;
            short64++;
            /* assuming we've gotten this far, then we increment the char_count */
            char_count++;
            /* if we detect the "stopchar" then we better increment the STOP counter */
            if (c == '=') {
                stopcount++;
            }
            /* test for and discard invalid chars */
            if (b64[c] == 0x80) {
                i--;
                continue;
            }
            /* do the conversion from encoded -> decoded */
            input[i] = (char)b64[c];

        } /* for */

        /* now that our 4-char buffer is full, we can do some fancy bit-shifting and get the required 3-chars of 8-bit data */
        output[0] = (input[0] << 2) | (input[1] >> 4);
        output[1] = (input[1] << 4) | (input[2] >> 2);
        output[2] = (input[2] << 6) | input[3];

        /* determine how many chars to write write and check for errors if our input char count was 4 then we did receive a propper 4:3 Base64 block, hence write it */
        if (i == 4) {
            for (i = 0; i < (3 -stopcount); i++){
                *outstring = output[i];
                outstring++;
            } /* copy our data across */
        } /* if 4 chars were inputted */
    } /* while more chars to proccess */

    *outstring = '\0';  // Set the last char to NULL
    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
callq 0x2110
xorl %ecx, %ecx
leaq 0xa556(%rip), %rdx      # 0x169f0
pushq $0x3
popq %rsi
xorl %edi, %edi
xorl %r9d, %r9d
movq %rbx, %r8
cmpl %eax, %r9d
jge 0xc557
andl $0x0, 0x8(%rsp)
xorl %r10d, %r10d
cmpl $0x3, %r10d
ja 0xc4e9
movsbq (%rbx), %r11
xorl %ebp, %ebp
cmpq $0x3d, %r11
sete %bpl
incq %rbx
incl %r9d
addl %ebp, %edi
movb (%r11,%rdx), %r11b
cmpb $-0x80, %r11b
je 0xc4b6
movl %r10d, %r14d
movb %r11b, 0x8(%rsp,%r14)
incl %r10d
jmp 0xc4b6
movb 0x8(%rsp), %r10b
movb 0x9(%rsp), %r11b
shlb $0x2, %r10b
movl %r11d, %ebp
sarb $0x4, %bpl
orb %r10b, %bpl
movb %bpl, 0xd(%rsp)
shlb $0x4, %r11b
movb 0xa(%rsp), %r10b
movl %r10d, %ebp
sarb $0x2, %bpl
orb %r11b, %bpl
shlb $0x6, %r10b
orb 0xb(%rsp), %r10b
movb %bpl, 0xe(%rsp)
movb %r10b, 0xf(%rsp)
movl %esi, %r10d
subl %edi, %r10d
testl %r10d, %r10d
cmovlel %ecx, %r10d
xorl %r11d, %r11d
cmpq %r11, %r10
je 0xc54f
movb 0xd(%rsp,%r11), %bpl
movb %bpl, (%r8,%r11)
incq %r11
jmp 0xc53c
addq %r11, %r8
jmp 0xc4a5
movb $0x0, (%r8)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq