#include "game_types.h"

/* Sub_08008530 @ 0x08008530 (real 138B) -- scan for word15==2 entry, chain-walk for scan base. Mirrors src/matched/Sub_08008530.c. */
/* Scans 32 entries (260-byte stride from a+516) for a flagged entry whose
   word 15 is 2, then walks its +140 chain for the scan base (dual-entry
   re-verify). Returns 1 on reaching it, else 0. The seed arrives live;
   modeled as a second arg. */
int Sub_08008530(int *a, int *seed)
{
    int *e = a + 129;
    int i;
    (void)seed;
    for (i = 0; i < 32; i++, e = (int *)((char *)e + 260)) {
        if ((e[0] != 0 || e[1] != 0) && e[15] == 2) {
            int *p = e;
            for (;;) {
                p = *(int **)((char *)p + 140);
                if (p == 0)
                    return 0;
                if (p == a + 129)
                    return 1;
            }
        }
    }
    return 0;
}
