Get the weirdnesses into the data where you can manipulate them easily, and the regularity into the code because regular code is a lot easier to work with
If you're as clever as you can be when you write it, how will you ever debug it?
Controlling complexity is the essence of computer programming.
Believe the terrain, not the map
C is a razor-sharp tool, with which one can create an elegant and efficient program or a bloody mess.
Don't document bad code - rewrite it.