C/C++ implementation