title: What is the loop inversion technique?
body: <p>I was going through a document which talks about <a href="http://en.wikipedia.org/wiki/Just-in-time_compilation">just-in-time compiler</a> (JIT) optimization techniques for Java. One of them was "loop inversion". And the document says:</p>
  
  <blockquote>
    <p>You replace a regular <code>while</code> loop with a <code>do-while</code> loop. And the
    <code>do-while</code> loop is set within an <code>if</code> clause. This replacement leads to two fewer jumps.</p>
  </blockquote>
  
  <p>How does loop inversion work and how does it optimize our code path?</p>
  
  <p><strong>N.B.:</strong> <em>It would be great if somebody can explain with an example of Java code and how JIT optimizes it to native code and why is it optimal in modern processors.</em></p>