Bogo engine, reimplemented in C for portability.