1// Assume that *out is large enough to contain the output.
2// Theoretically it should be 4/3 the length of src.
3const uint8_t *s = (const uint8_t *) src;
4uint8_t *o = (uint8_t *) out;
5
6// Use local temporaries to avoid cache thrashing:
7size_t olen = 0;
8size_t slen = srclen;
9struct base64_state st;
10st.bytes = state->bytes;
11st.carry = state->carry;
12
13// Turn three bytes into four 6-bit numbers:
14// in[0] = 00111111
15// in[1] = 00112222
16// in[2] = 00222233
17// in[3] = 00333333
18
19// Duff's device, a for() loop inside a switch() statement. Legal!
20switch (st.bytes)
21{
22 for (;;)
23 {
24 case 0:
25