Branch Coverage

sieve.c
Criterion Covered Total %
branch 269 340 79.1


line true false branch
21 11 1859 if ( (startp > UVCONST( 100000000000000) && range < 40000) ||
0 11 if ( (startp > UVCONST( 100000000000000) && range < 40000) ||
0 1859 if ( (startp > UVCONST( 100000000000000) && range < 40000) ||
22 0 0 (startp > UVCONST( 1000000000000000) && range < 150000) ||
0 1859 (startp > UVCONST( 1000000000000000) && range < 150000) ||
23 0 0 (startp > UVCONST( 10000000000000000) && range < 600000) ||
0 1859 (startp > UVCONST( 10000000000000000) && range < 600000) ||
24 0 0 (startp > UVCONST( 100000000000000000) && range < 2500000) ||
0 1859 (startp > UVCONST( 100000000000000000) && range < 2500000) ||
25 0 0 (startp > UVCONST( 1000000000000000000) && range < 10000000) ||
0 1859 (startp > UVCONST( 1000000000000000000) && range < 10000000) ||
26 0 0 (startp > UVCONST(10000000000000000000) && range < 40000000) )
123 1092 159 if (to < from)
125 0 1251 if (dst != src)
127 647 1251 while (from < to) {
128 159 488 size_t bytes = (2*from > to) ? to-from : from;
138 2016 0 MPUassert( (mem != 0) && (endd >= startd), "sieve_prefill bad arguments");
0 2016 MPUassert( (mem != 0) && (endd >= startd), "sieve_prefill bad arguments");
140 819 1197 if (startd != 0) {
143 765 54 if (tailbytes > nbytes) tailbytes = nbytes;
148 1251 765 if (nbytes > 0) {
151 1197 54 if (startd == 0) mem[0] = 0x01; /* Correct first byte */
200 15881 4220904 if (startp == 0) {
205 4218061 2843 if (p2 < startp) {
221 4098422 145518 if (w->offset >= bytes) {
228 1596 8822 CROSS_INDEX( 0, 0,1,2,3,4,5,6,7, 0,0,0,0,0,0,0,1, 1); break;
2920 8440 CROSS_INDEX( 0, 0,1,2,3,4,5,6,7, 0,0,0,0,0,0,0,1, 1); break;
2357 8158 CROSS_INDEX( 0, 0,1,2,3,4,5,6,7, 0,0,0,0,0,0,0,1, 1); break;
1514 8000 CROSS_INDEX( 0, 0,1,2,3,4,5,6,7, 0,0,0,0,0,0,0,1, 1); break;
2383 7626 CROSS_INDEX( 0, 0,1,2,3,4,5,6,7, 0,0,0,0,0,0,0,1, 1); break;
1622 7424 CROSS_INDEX( 0, 0,1,2,3,4,5,6,7, 0,0,0,0,0,0,0,1, 1); break;
2163 7327 CROSS_INDEX( 0, 0,1,2,3,4,5,6,7, 0,0,0,0,0,0,0,1, 1); break;
3010 6990 CROSS_INDEX( 0, 0,1,2,3,4,5,6,7, 0,0,0,0,0,0,0,1, 1); break;
523637 6990 CROSS_INDEX( 0, 0,1,2,3,4,5,6,7, 0,0,0,0,0,0,0,1, 1); break;
229 1588 7096 CROSS_INDEX( 8, 1,5,4,0,7,3,2,6, 1,1,1,0,1,1,1,1, 7); break;
2999 8709 CROSS_INDEX( 8, 1,5,4,0,7,3,2,6, 1,1,1,0,1,1,1,1, 7); break;
2601 8151 CROSS_INDEX( 8, 1,5,4,0,7,3,2,6, 1,1,1,0,1,1,1,1, 7); break;
1464 8080 CROSS_INDEX( 8, 1,5,4,0,7,3,2,6, 1,1,1,0,1,1,1,1, 7); break;
2224 8067 CROSS_INDEX( 8, 1,5,4,0,7,3,2,6, 1,1,1,0,1,1,1,1, 7); break;
1571 7938 CROSS_INDEX( 8, 1,5,4,0,7,3,2,6, 1,1,1,0,1,1,1,1, 7); break;
2445 7649 CROSS_INDEX( 8, 1,5,4,0,7,3,2,6, 1,1,1,0,1,1,1,1, 7); break;
2999 7292 CROSS_INDEX( 8, 1,5,4,0,7,3,2,6, 1,1,1,0,1,1,1,1, 7); break;
552471 7292 CROSS_INDEX( 8, 1,5,4,0,7,3,2,6, 1,1,1,0,1,1,1,1, 7); break;
230 1509 7280 CROSS_INDEX(16, 2,4,0,6,1,7,3,5, 2,2,0,2,0,2,2,1, 11); break;
3165 6812 CROSS_INDEX(16, 2,4,0,6,1,7,3,5, 2,2,0,2,0,2,2,1, 11); break;
2507 8301 CROSS_INDEX(16, 2,4,0,6,1,7,3,5, 2,2,0,2,0,2,2,1, 11); break;
1576 8086 CROSS_INDEX(16, 2,4,0,6,1,7,3,5, 2,2,0,2,0,2,2,1, 11); break;
2566 7633 CROSS_INDEX(16, 2,4,0,6,1,7,3,5, 2,2,0,2,0,2,2,1, 11); break;
1390 7684 CROSS_INDEX(16, 2,4,0,6,1,7,3,5, 2,2,0,2,0,2,2,1, 11); break;
2322 7416 CROSS_INDEX(16, 2,4,0,6,1,7,3,5, 2,2,0,2,0,2,2,1, 11); break;
2725 7336 CROSS_INDEX(16, 2,4,0,6,1,7,3,5, 2,2,0,2,0,2,2,1, 11); break;
523583 7336 CROSS_INDEX(16, 2,4,0,6,1,7,3,5, 2,2,0,2,0,2,2,1, 11); break;
231 1651 7005 CROSS_INDEX(24, 3,0,6,5,2,1,7,4, 3,1,1,2,1,1,3,1, 13); break;
2997 6581 CROSS_INDEX(24, 3,0,6,5,2,1,7,4, 3,1,1,2,1,1,3,1, 13); break;
2295 6331 CROSS_INDEX(24, 3,0,6,5,2,1,7,4, 3,1,1,2,1,1,3,1, 13); break;
1604 8029 CROSS_INDEX(24, 3,0,6,5,2,1,7,4, 3,1,1,2,1,1,3,1, 13); break;
2246 7831 CROSS_INDEX(24, 3,0,6,5,2,1,7,4, 3,1,1,2,1,1,3,1, 13); break;
1566 7706 CROSS_INDEX(24, 3,0,6,5,2,1,7,4, 3,1,1,2,1,1,3,1, 13); break;
2307 7605 CROSS_INDEX(24, 3,0,6,5,2,1,7,4, 3,1,1,2,1,1,3,1, 13); break;
3077 7188 CROSS_INDEX(24, 3,0,6,5,2,1,7,4, 3,1,1,2,1,1,3,1, 13); break;
504871 7188 CROSS_INDEX(24, 3,0,6,5,2,1,7,4, 3,1,1,2,1,1,3,1, 13); break;
232 1743 8036 CROSS_INDEX(32, 4,7,1,2,5,6,0,3, 3,3,1,2,1,3,3,1, 17); break;
3189 7554 CROSS_INDEX(32, 4,7,1,2,5,6,0,3, 3,3,1,2,1,3,3,1, 17); break;
2485 7261 CROSS_INDEX(32, 4,7,1,2,5,6,0,3, 3,3,1,2,1,3,3,1, 17); break;
1677 7003 CROSS_INDEX(32, 4,7,1,2,5,6,0,3, 3,3,1,2,1,3,3,1, 17); break;
2373 9945 CROSS_INDEX(32, 4,7,1,2,5,6,0,3, 3,3,1,2,1,3,3,1, 17); break;
1622 9821 CROSS_INDEX(32, 4,7,1,2,5,6,0,3, 3,3,1,2,1,3,3,1, 17); break;
2788 9148 CROSS_INDEX(32, 4,7,1,2,5,6,0,3, 3,3,1,2,1,3,3,1, 17); break;
3384 8311 CROSS_INDEX(32, 4,7,1,2,5,6,0,3, 3,3,1,2,1,3,3,1, 17); break;
770670 8311 CROSS_INDEX(32, 4,7,1,2,5,6,0,3, 3,3,1,2,1,3,3,1, 17); break;
233 1495 7520 CROSS_INDEX(40, 5,3,7,1,6,0,4,2, 4,2,2,2,2,2,4,1, 19); break;
2872 7227 CROSS_INDEX(40, 5,3,7,1,6,0,4,2, 4,2,2,2,2,2,4,1, 19); break;
2515 6762 CROSS_INDEX(40, 5,3,7,1,6,0,4,2, 4,2,2,2,2,2,4,1, 19); break;
1645 6492 CROSS_INDEX(40, 5,3,7,1,6,0,4,2, 4,2,2,2,2,2,4,1, 19); break;
2356 6278 CROSS_INDEX(40, 5,3,7,1,6,0,4,2, 4,2,2,2,2,2,4,1, 19); break;
1712 8691 CROSS_INDEX(40, 5,3,7,1,6,0,4,2, 4,2,2,2,2,2,4,1, 19); break;
2527 8278 CROSS_INDEX(40, 5,3,7,1,6,0,4,2, 4,2,2,2,2,2,4,1, 19); break;
3204 7671 CROSS_INDEX(40, 5,3,7,1,6,0,4,2, 4,2,2,2,2,2,4,1, 19); break;
636848 7671 CROSS_INDEX(40, 5,3,7,1,6,0,4,2, 4,2,2,2,2,2,4,1, 19); break;
234 1551 7899 CROSS_INDEX(48, 6,2,3,7,0,4,5,1, 5,3,1,4,1,3,5,1, 23); break;
3279 7301 CROSS_INDEX(48, 6,2,3,7,0,4,5,1, 5,3,1,4,1,3,5,1, 23); break;
2492 6830 CROSS_INDEX(48, 6,2,3,7,0,4,5,1, 5,3,1,4,1,3,5,1, 23); break;
1596 6655 CROSS_INDEX(48, 6,2,3,7,0,4,5,1, 5,3,1,4,1,3,5,1, 23); break;
2591 6358 CROSS_INDEX(48, 6,2,3,7,0,4,5,1, 5,3,1,4,1,3,5,1, 23); break;
1664 6188 CROSS_INDEX(48, 6,2,3,7,0,4,5,1, 5,3,1,4,1,3,5,1, 23); break;
2394 8692 CROSS_INDEX(48, 6,2,3,7,0,4,5,1, 5,3,1,4,1,3,5,1, 23); break;
3314 8057 CROSS_INDEX(48, 6,2,3,7,0,4,5,1, 5,3,1,4,1,3,5,1, 23); break;
686340 8057 CROSS_INDEX(48, 6,2,3,7,0,4,5,1, 5,3,1,4,1,3,5,1, 23); break;
235 1560 7539 CROSS_INDEX(56, 7,6,5,4,3,2,1,0, 6,4,2,4,2,4,6,1, 29); break;
3382 6894 CROSS_INDEX(56, 7,6,5,4,3,2,1,0, 6,4,2,4,2,4,6,1, 29); break;
2377 6590 CROSS_INDEX(56, 7,6,5,4,3,2,1,0, 6,4,2,4,2,4,6,1, 29); break;
1561 6505 CROSS_INDEX(56, 7,6,5,4,3,2,1,0, 6,4,2,4,2,4,6,1, 29); break;
2383 6225 CROSS_INDEX(56, 7,6,5,4,3,2,1,0, 6,4,2,4,2,4,6,1, 29); break;
1535 6052 CROSS_INDEX(56, 7,6,5,4,3,2,1,0, 6,4,2,4,2,4,6,1, 29); break;
2333 5757 CROSS_INDEX(56, 7,6,5,4,3,2,1,0, 6,4,2,4,2,4,6,1, 29); break;
2960 7665 CROSS_INDEX(56, 7,6,5,4,3,2,1,0, 6,4,2,4,2,4,6,1, 29); break;
602085 7665 CROSS_INDEX(56, 7,6,5,4,3,2,1,0, 6,4,2,4,2,4,6,1, 29); break;
256 11746 119 for ( ; prime <= limit; prime = next_prime_in_sieve(mem,prime,end)) {
269 269 0 UV endp = (endd >= (UV_MAX/30)) ? UV_MAX-2 : 30*endd+29;
270 269 0 MPUassert( (mem != 0) && (endd >= startd) && (endp >= startp),
269 0 MPUassert( (mem != 0) && (endd >= startd) && (endp >= startp),
0 269 MPUassert( (mem != 0) && (endd >= startd) && (endp >= startp),
275 246 23 if (sieve_size >= endp) {
285 0 23 if (limit > max_sieve_prime) limit = max_sieve_prime;
287 0 23 if (do_partial_sieve(startp, endp))
288 0 0 slimit >>= ((startp < (UV)1e16) ? 8 : 10);
290 0 23 if (slimit > sieve_size) {
295 77228 0 START_DO_FOR_EACH_SIEVE_PRIME(sieve, 0, start_base_prime, slimit) {
23 77205 START_DO_FOR_EACH_SIEVE_PRIME(sieve, 0, start_base_prime, slimit) {
77136 69 START_DO_FOR_EACH_SIEVE_PRIME(sieve, 0, start_base_prime, slimit) {
77228 3685 START_DO_FOR_EACH_SIEVE_PRIME(sieve, 0, start_base_prime, slimit) {
3708 23 START_DO_FOR_EACH_SIEVE_PRIME(sieve, 0, start_base_prime, slimit) {
301 0 23 if (limit > slimit) { /* We've sieved out most composites, but not all. */
302 0 0 START_DO_FOR_EACH_SIEVE_PRIME(mem, 0, 0, endp-startp) {
0 0 START_DO_FOR_EACH_SIEVE_PRIME(mem, 0, 0, endp-startp) {
0 0 START_DO_FOR_EACH_SIEVE_PRIME(mem, 0, 0, endp-startp) {
0 0 START_DO_FOR_EACH_SIEVE_PRIME(mem, 0, 0, endp-startp) {
0 0 START_DO_FOR_EACH_SIEVE_PRIME(mem, 0, 0, endp-startp) {
303 0 0 if (!BPSW(startp + p)) /* If the candidate is not prime, */
315 1874 0 UV endp = (endd >= (UV_MAX/30)) ? UV_MAX-2 : 30*endd+29;
316 1874 0 MPUassert( (mem != 0) && (endd >= startd) && (endp >= startp),
1874 0 MPUassert( (mem != 0) && (endd >= startd) && (endp >= startp),
0 1874 MPUassert( (mem != 0) && (endd >= startd) && (endp >= startp),
323 12645 239 while (i < wsize && warray[i].prime < start_base_prime)
11010 1635 while (i < wsize && warray[i].prime < start_base_prime)
327 0 1874 if (limit > max_sieve_prime) limit = max_sieve_prime;
329 4156682 250 while (i < wsize && warray[i].prime <= limit) {
4155058 1624 while (i < wsize && warray[i].prime <= limit) {
330 4147903 7155 if (warray[i].index >= 64)
335 11 1863 if (limit > warray[wsize-1].prime && warray[wsize-1].prime < max_sieve_prime) {
11 0 if (limit > warray[wsize-1].prime && warray[wsize-1].prime < max_sieve_prime) {
336 6882 0 START_DO_FOR_EACH_SIEVE_PRIME(mem, 0, 0, endp-startp) {
11 6871 START_DO_FOR_EACH_SIEVE_PRIME(mem, 0, 0, endp-startp) {
6871 0 START_DO_FOR_EACH_SIEVE_PRIME(mem, 0, 0, endp-startp) {
6882 594 START_DO_FOR_EACH_SIEVE_PRIME(mem, 0, 0, endp-startp) {
605 11 START_DO_FOR_EACH_SIEVE_PRIME(mem, 0, 0, endp-startp) {
337 2789 4082 if (!BPSW(startp + p)) /* If the candidate is not prime, */
382 0 1847 MPUassert( high >= low, "start_segment_primes bad arguments");
388 1847 0 ctx->endp = (ctx->hid >= (UV_MAX/30)) ? UV_MAX-2 : 30*ctx->hid+29;
392 26 1821 if (high > 1e10 && range > 32*1024-16) {
0 26 if (high > 1e10 && range > 32*1024-16) {
396 0 0 if (size < 128*1024) size = 128*1024;
399 0 0 size = (div <= 1) ? range : (range+div-1)/div;
408 0 1847 if (_XS_get_verbose() >= 2)
424 11 1836 if (do_partial_sieve(low, high))
425 5 6 limit >>= ((low < (UV)1e16) ? 8 : 10);
426 1847 0 if (limit <= maxsieve) {
431 0 1847 if (_XS_get_verbose() >= 4)
433 0 1847 New(0, warray, nprimes, wheel_t);
434 0 1847 START_DO_FOR_EACH_PRIME(0,limit) {
5541 4156654 START_DO_FOR_EACH_PRIME(0,limit) {
3694 1847 START_DO_FOR_EACH_PRIME(0,limit) {
1847 1847 START_DO_FOR_EACH_PRIME(0,limit) {
1818265 2338389 START_DO_FOR_EACH_PRIME(0,limit) {
516 1972636 START_DO_FOR_EACH_PRIME(0,limit) {
154887 1817749 START_DO_FOR_EACH_PRIME(0,limit) {
516 1817749 START_DO_FOR_EACH_PRIME(0,limit) {
0 4156138 START_DO_FOR_EACH_PRIME(0,limit) {
1331 4160348 START_DO_FOR_EACH_PRIME(0,limit) {
435 0 4160348 if (wsize >= nprimes) croak("segment bad upper count");
453 1774 1874 if (ctx->lod > ctx->hid) return 0;
457 1847 27 : (ctx->lod + ctx->segment_size - 1);
460 1847 27 *high = (seghigh_d == ctx->hid) ? ctx->high : (seghigh_d*30 + 29);
463 0 1874 MPUassert( seghigh_d >= ctx->lod, "next_segment_primes: highd < lowd");
464 0 1874 MPUassert( range_d <= ctx->segment_size, "next_segment_primes: range > segment size");
466 1874 0 if (ctx->warray != 0)
480 0 1847 MPUassert(ctx != 0, "end_segment_primes given a null pointer");
481 1847 0 if (ctx->segment != 0) {
485 0 1847 if (ctx->base != 0) {
489 1847 0 if (ctx->warray != 0) {