Use correct int data types to avoid 32/64 bit issues

Hopefully fixes the p5_av_top_index openBSD issue reported by carlin++