Sorting a stack of pancakes in C. Only flipping allowed