C code that iterates through permutations.