This is an attempt to make a dual slope integrator.
A dual slope integrator is a ADC that compares a unknown voltage with a known reference voltage. The digital value is given by the number of clock ticks it takes to return to zero.
These are often found on modern digital multimeters.