title: Tool for simplifying/optimizing logic?
body: <p>Usually I would let the compiler do it's magic of optimizing complicated logical expressions, however, in this case the compiler I have to use is not very good at this (basically all it can do is to replaced things like /64 with bit-shifts and %512 with bitwise-and).</p>
  
  <p>Is there any tool available that can analyze and provide optimized versions of expressions, (i.e. the same way good optimizing compilers do)?</p>
  
  <p>e.g. I would like to optimize the following:</p>
  
  <pre><code>int w = 2 - z/2;
  
  int y0 = y + (((v % 512) / 64) / 4) * 8           + ((v / 512) / mb)*16;
  int x0 = x + (((v % 512) / 64) % 4) * 8 * (w - 1) + ((v / 512) % mb)*8 * w;
  
  int i = x0 * (w ^ 3) * 2 + y0 * mb * 16 * 2 + (2*z - 3) * (z/2);
  </code></pre>