Tetrahedron method in C