Convert galois.cpp to C