typedef unsigned char ubyte;
const ubyte BASE64[] = ;

int findIndex(const ubyte val) {
    if ('A' <= val && val <= 'Z') {
        return val - 'A';
    }
    if ('a' <= val && val <= 'z') {
        return val - 'a' + 26;
    }
    if ('0' <= val && val <= '9') {
        return val - '0' + 52;
    }
    if (val == '+') {
        return 62;
    }
    if (val == '/') {
        return 63;
    }
    return -1;
}

int decode(const ubyte source[], ubyte sink[]) {
    const size_t length = strlen(source);
    const ubyte *it = source;
    const ubyte *end = source + length;
    int acc;

    if (length % 4 != 0) {
        return 1;
    }

    while (it != end) {
        const ubyte b1 = *it++;
        const ubyte b2 = *it++;
        const ubyte b3 = *it++;         
        const ubyte b4 = *it++;         

        const int i1 = findIndex(b1);
        const int i2 = findIndex(b2);

        acc = i1 << 2;                  
        acc |= i2 >> 4;                 
        *sink++ = acc;                  

        if (b3 != '=') {
            const int i3 = findIndex(b3);

            acc = (i2 & 0xF) << 4;      
            acc += i3 >> 2;             
            *sink++ = acc;              

            if (b4 != '=') {
                const int i4 = findIndex(b4);

                acc = (i3 & 0x3) << 6;  
                acc |= i4;              
                *sink++ = acc;          
            }
        }
    }

    *sink = '\0';   
    return 0;
}

int main() {
    ubyte data[] = ;
    ubyte decoded[1024];

    printf(, data);
    decode(data, decoded);
    printf(, decoded);

    return 0;
}