<p><pre><code>    &#x2F;&#x2F; 1. lookup and build output word at the same time
    const uint32_t dword = lookup32[0][input[i + 0]]
                         | lookup32[0][input[i + 1]]
                         | lookup32[0][input[i + 2]]
                         | lookup32[0][input[i + 3]];
    
    &#x2F;&#x2F; 2. save 32 bits
    reinterpret_cast&lt;uint32_t*&gt;(out) = dword;
    out += 3;
</code></pre>
Do you mean lookup32[0]... | lookup32[1] ... | ..[2] | [3], instead?