Pure C implementation.