Binary to hex faster than xxd, part 2 of 2
<p><pre><code>    static void flush(void) {                                                                                                                 
      if (writeall(1, buf, buflen) == -1) _exit(errno);                                                                                     
      buflen = 0;                                                                                                                           
      }                                                                                                                                         
    static void wrch(const char ch) {                                                                                                         
      if (buflen &gt;= sizeof buf) flush();                                                                                                    
      buf[buflen++] = ch;                                                                                                                   
      return;                                                                                                                               
     }                                                                                                                                         
    char inbuf[128];
    int main(int argc, char **argv) {
        long long r, i;
        for (;;) {
            r = read(0, inbuf, sizeof inbuf);
            if (r == -1) _exit(errno);
            if (r == 0) break;
            for (i = 0; i &lt; r; ++i) {
                wrch(&quot;0123456789abcdef&quot;[15 &amp; (inbuf[i] &gt;&gt; 4)]);
                wrch(&quot;0123456789abcdef&quot;[15 &amp; inbuf[i]]);
            }
        }
        wrch(&#x27;\n&#x27;);
        return 0;
    }</code></pre>