flatten an array, since gcc fails at optimizing multidimensional arrays