The C code is here.