Common C main implementation.

Closes #14.