title: Loop Optimization in C
body: <p>I have been tasked with optimizing a particular for loop in C. Here is the loop:</p>
  
  <pre><code>#define ARRAY_SIZE 10000
  #define N_TIMES    600000
  
  for (i = 0; i &lt; N_TIMES; i++)
  {
      int j;
  
      for (j = 0; j &lt; ARRAY_SIZE; j++)
      {
          sum += array[j];
      }
  }
  </code></pre>
  
  <p>I'm supposed to use loop unrolling, loop splitting, and pointers in order to speed it up, but every time I try to implement something, the program doesn't return. Here's what I've tried so far:</p>
  
  <pre><code>for (i = 0; i &lt; N_TIMES; i++) 
  {
      int j,k;
  
      for (j = 0; j &lt; ARRAY_SIZE; j++) 
      {    
          for (k = 0; k &lt; 100; k += 2) 
          {
              sum += array[k];
              sum += array[k + 1];
          }
      } 
  }
  </code></pre>
  
  <p>I don't understand why the program doesn't even return now. Any help would be appreciated.</p>