Ported compute_distance2line to C