Constructing an odd-even mergesort sorting network
In general your code is quite hard to comprehend due to the bracing style and the single letter variable names. A bit more spaces and more meaningful names would do quite a bit for readability (I've kept your 2-indent spacing) and also remove the need for most of the comments:

#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;

int log2ceil(int value)
{
  int i;
  int cmp = 1;
  for (i = 0; cmp &lt; value; i++)
  {
    cmp &lt;&lt;= 1;
  }
  return i;
}

void sort(int length)
{
  int groups = log2ceil(length);
  for (int group = 0; group &lt; groups; group++)
  {
    int blocks = 1 &lt;&lt; (groups - group - 1);
    for (int block = 0; block &lt; blocks; block++)
    {
      for (int stage = 0; stage &lt;= group; stage++)
      {
        int distance = 1 &lt;&lt; (group - stage);
        int startPoint = (stage == 0) ? 0 : distance;
        for (int j = startPoint; j + distance &lt; (2 &lt;&lt; group); j += 2 * distance)
        {
          for (int i = 0; i &lt; distance; i++)            // shift startpoints
          {
            int x = (block * (length / blocks)) + j + i;
            int y = x + distance;
            printf("%2i cmp %2i\n", x, y);
          }
        }
      }
    }
  }
}

int main(char* argv, int args)
{
  const int COUNT = 8;
  sort(COUNT);
}