+static void sanity_check_refcnt(struct scoreboard *sb)
+{
+ int baa = 0;
+ struct blame_entry *ent;
+
+ for (ent = sb->ent; ent; ent = ent->next) {
+ /* first mark the ones that haven't been checked */
+ if (0 < ent->suspect->refcnt)
+ ent->suspect->refcnt = -ent->suspect->refcnt;
+ else if (!ent->suspect->refcnt)
+ baa = 1;
+ }
+ for (ent = sb->ent; ent; ent = ent->next) {
+ /* then pick each and see if they have the the
+ * correct refcnt
+ */
+ int found;
+ struct blame_entry *e;
+ struct origin *suspect = ent->suspect;
+
+ if (0 < suspect->refcnt)
+ continue;
+ suspect->refcnt = -suspect->refcnt;
+ for (found = 0, e = sb->ent; e; e = e->next) {
+ if (e->suspect != suspect)
+ continue;
+ found++;
+ }
+ if (suspect->refcnt != found)
+ baa = 1;
+ }
+ if (baa) {
+ int opt = 0160;
+ find_alignment(sb, &opt);
+ output(sb, opt);
+ die("Baa!");
+ }
+}
+