Geoff, I found a bug in primes.c. I don't think, it affects the main sr2sieve version, since we do not do any bound checking there. (I think it occurs if a person is sieving beyond 2^48, range_size^2). This is probably what was slowing things down.

Attached is primes.c, look at the comments.

(You can hold off on implementing the inverse method, since we can use the factoring of X, to speed things up. Look at my code in the comments)