C program to calculate an adjusted D-statistic of segregation

This web page contains the c program to calculate adjusted
D statistics (adjusted to account for small numbers in some
categories).
The usual interpretation of the D-statistic
is how many people would have to change categories
(e.g., change occupations, census tracts, etc.) in order to
have equal distributions (e.g., of men and women) across
categories.
The adjusted D-statistic is how many people
would have to change categories so that the two distribution
differered by no more than chance.