Ported compute_distance2electron to C