Branch Coverage

twin_primes.c
Criterion Covered Total %
branch 165 214 77.1


line true false branch
51 438 0 return (n < 3) ? 0 : twin_prime_count_range(0,n);
59 447 2 if (beg <= 3 && end >= 10000000) {
6 441 if (beg <= 3 && end >= 10000000) {
61 40 0 for (exp = 0; exp < twin_num_exponents && end >= base; exp++) {
34 6 for (exp = 0; exp < twin_num_exponents && end >= base; exp++) {
62 284 28 for (mult = 1; mult < 10 && end >= mult*base; mult++) {
278 6 for (mult = 1; mult < 10 && end >= mult*base; mult++) {
65 0 278 if (exp == twin_num_exponents-1 && mult >= twin_last_mult) break;
0 0 if (exp == twin_num_exponents-1 && mult >= twin_last_mult) break;
70 441 8 if (beg <= 3 && end >= 3) sum++;
441 0 if (beg <= 3 && end >= 3) sum++;
71 441 8 if (beg <= 5 && end >= 5) sum++;
441 0 if (beg <= 5 && end >= 5) sum++;
72 441 8 if (beg < 11) beg = 7;
73 449 0 if (beg <= end) {
78 5346 449 while ((beg % 30) != 1) {
79 3093 2253 if (is_prime(beg) && is_prime(beg+2) && beg <= end) sum++;
1325 1768 if (is_prime(beg) && is_prime(beg+2) && beg <= end) sum++;
1325 0 if (is_prime(beg) && is_prime(beg+2) && beg <= end) sum++;
82 3255 432 while ((end % 30) != 29) {
83 1039 2216 if (is_prime(end) && is_prime(end+2) && beg <= end) sum++;
192 847 if (is_prime(end) && is_prime(end+2) && beg <= end) sum++;
192 0 if (is_prime(end) && is_prime(end+2) && beg <= end) sum++;
84 17 3238 end -= 2; if (beg > end) break;
87 432 17 if (beg <= end) {
90 432 432 while (next_segment_primes(ctx, &seg_base, &seg_low, &seg_high)) {
95 53862 432 for (s = x = *sp; sp++ < spend; s = x) {
97 7752 46110 if (!(s & 0x0C)) sum++;
98 6075 47787 if (!(s & 0x30)) sum++;
99 18818 35044 if (!(s & 0x80) && !(x & 0x01)) sum++;
7011 11807 if (!(s & 0x80) && !(x & 0x01)) sum++;
101 265 167 x = is_prime(seg_high+2) ? 0x00 : 0xFF;
102 166 266 if (!(s & 0x0C)) sum++;
103 118 314 if (!(s & 0x30)) sum++;
104 263 169 if (!(s & 0x80) && !(x & 0x01)) sum++;
166 97 if (!(s & 0x80) && !(x & 0x01)) sum++;
117 438 119 if (n < 2000) return twin_prime_count(n);
127 51 68 if (n < 32000000) {
129 0 51 if (n < 4000) fm = 0.2952;
130 1 50 else if (n < 8000) fm = 0.3102;
131 0 50 else if (n < 16000) fm = 0.3090;
132 2 48 else if (n < 32000) fm = 0.3096;
133 10 38 else if (n < 64000) fm = 0.3097;
134 13 25 else if (n < 128000) fm = 0.3094;
135 0 25 else if (n < 256000) fm = 0.3099;
136 11 14 else if (n < 600000) fm = .3098 + (n-256000) * (.3056-.3098) / (600000-256000);
137 1 13 else if (n < 1000000) fm = .3062 + (n-600000) * (.3042-.3062) / (1000000-600000);
138 0 13 else if (n < 4000000) fm = .3067 + (n-1000000) * (.3041-.3067) / (4000000-1000000);
139 13 0 else if (n <16000000) fm = .3041 + (n-4000000) * (.2983-.3041) / (16000000-4000000);
155 6 48 if (n < 6) {
170 48 0 if (dend < (double)end) end = (UV) dend;
173 0 48 if (n > 58980) { /* Use twin_prime_count tables to accelerate if possible */
175 0 0 for (exp = 0; exp < twin_num_exponents && end >= base; exp++) {
0 0 for (exp = 0; exp < twin_num_exponents && end >= base; exp++) {
176 0 0 for (mult = 1; mult < 10 && n > twin_steps[step]; mult++) {
0 0 for (mult = 1; mult < 10 && n > twin_steps[step]; mult++) {
179 0 0 if (exp == twin_num_exponents-1 && mult >= twin_last_mult) break;
0 0 if (exp == twin_num_exponents-1 && mult >= twin_last_mult) break;
184 48 0 if (beg == 2) { beg = 31; n -= 5; }
189 48 48 while (n && next_segment_primes(ctx, &seg_base, &seg_low, &seg_high)) {
48 0 while (n && next_segment_primes(ctx, &seg_base, &seg_low, &seg_high)) {
192 4428 0 for (p = 0; p < bytes; p++) {
194 4428 0 if (p+1 < bytes) s |= (((UV)segment[p+1]) << 8);
195 0 0 else if (!is_prime(seg_high+2)) s |= 0xFF00;
196 853 3575 if (!(s & 0x000C) && !--n) { nth=seg_base+p*30+11; break; }
19 834 if (!(s & 0x000C) && !--n) { nth=seg_base+p*30+11; break; }
197 686 3723 if (!(s & 0x0030) && !--n) { nth=seg_base+p*30+17; break; }
13 673 if (!(s & 0x0030) && !--n) { nth=seg_base+p*30+17; break; }
198 783 3613 if (!(s & 0x0180) && !--n) { nth=seg_base+p*30+29; break; }
16 767 if (!(s & 0x0180) && !--n) { nth=seg_base+p*30+29; break; }
213 1 56 if (n < 6)
221 0 56 hi = (UV) ( (n >= 1e16) ? (1.04 * fnlog2n) :
5 49 hi = (UV) ( (n >= 1e16) ? (1.04 * fnlog2n) :
222 0 56 (n >= 1e13) ? (1.10 * fnlog2n) :
223 2 54 (n >= 1e7 ) ? (1.31 * fnlog2n) :
226 0 56 if (hi <= lo) hi = UV_MAX;
280 0 16 if (end > MPU_MAX_TWIN_PRIME) end = MPU_MAX_TWIN_PRIME;
283 0 16 New(0, L, nalloc + 1 + 3, UV);
286 0 16 if (beg <= 3 && end >= 3) L[ntwin++] = 3;
0 0 if (beg <= 3 && end >= 3) L[ntwin++] = 3;
287 0 16 if (beg <= 5 && end >= 5) L[ntwin++] = 5;
0 0 if (beg <= 5 && end >= 5) L[ntwin++] = 5;
288 12 4 if (beg < 11) beg = 7;
289 16 0 if (beg <= end) {
295 16 42 if (beg30 == 1) break;
296 13 29 else if (beg30 <= 11) beg = beg-beg30+11;
297 13 16 else if (beg30 <= 17) beg = beg-beg30+17;
298 16 0 else if (beg30 <= 29) beg = beg-beg30+29;
299 18 24 if (beg <= end && is_prime(beg) && is_prime(beg+2)) L[ntwin++] = beg;
15 3 if (beg <= end && is_prime(beg) && is_prime(beg+2)) L[ntwin++] = beg;
14 1 if (beg <= end && is_prime(beg) && is_prime(beg+2)) L[ntwin++] = beg;
300 13 29 beg = (beg30 <= 11) ? beg+6 : (beg30 <= 17) ? beg+12 : beg+2;
13 16 beg = (beg30 <= 11) ? beg+6 : (beg30 <= 17) ? beg+12 : beg+2;
303 5 11 if (beg <= end) {
307 5 5 while (next_segment_primes(ctx, &seg_base, &seg_low, &seg_high)) {
313 86 5 for (s = x = *sp; sp++ < spend; s = x) {
315 20 66 if (!(s & 0x0C)) L[ntwin++] = pos+11;
316 15 71 if (!(s & 0x30)) L[ntwin++] = pos+17;
317 37 49 if (!(s & 0x80) && !(x & 0x01)) L[ntwin++] = pos+29;
15 22 if (!(s & 0x80) && !(x & 0x01)) L[ntwin++] = pos+29;
320 1 4 x = is_prime(seg_high+2) ? 0x00 : 0xFF;
321 1 4 if (!(s & 0x0C)) L[ntwin++] = pos+11;
322 2 3 if (!(s & 0x30)) L[ntwin++] = pos+17;
323 2 3 if (!(s & 0x80) && !(x & 0x01)) L[ntwin++] = pos+29;
1 1 if (!(s & 0x80) && !(x & 0x01)) L[ntwin++] = pos+29;
327 8 0 while (ntwin > 0 && L[ntwin-1] > end) ntwin--;
3 5 while (ntwin > 0 && L[ntwin-1] > end) ntwin--;