count transitions in low-level code