title: Empty loop is slower than a non-empty one in C
body: <p>While trying to know how long a line of C code used to execute, I noticed this weird thing :</p>
  
  <pre><code>int main (char argc, char * argv[]) {
      time_t begin, end;
      uint64_t i;
      double total_time, free_time;
      int A = 1;
      int B = 1;
  
      begin = clock();
      for (i = 0; i&lt;(1&lt;&lt;31)-1; i++);
      end = clock();
      free_time = (double)(end-begin)/CLOCKS_PER_SEC;
      printf("%f\n", free_time);
  
      begin = clock();
      for (i = 0; i&lt;(1&lt;&lt;31)-1; i++) {
          A += B%2;
      }
      end = clock();
      free_time = (double)(end-begin)/CLOCKS_PER_SEC;
      printf("%f\n", free_time);
  
      return(0);
  }
  </code></pre>
  
  <p>Which when executed displays :</p>
  
  <pre><code>5.873425
  4.826874
  </code></pre>
  
  <p>Why does the empty loop use more time than the second which has an instruction within ? Of course I've tried many variants but everytime, an empty loop takes more time than one with one single instruction within.</p>
  
  <p>Note that I have tried swapping loops order and adding some warmup code and it didn't change my problem at all.</p>
  
  <p>I'm using codeblocks as IDE with GNU gcc compiler, linux ubuntu 14.04 and have a quadcore intel i5 at 2.3GHz (I've tried running the programm on a single core, this doesn't change the result).</p>