C implementation of the MV-matching algorithm