Just a simple Liang-Barsky line clipping algorithm implemented in C