generalized instruction counting