Branch Coverage

XS.xs
Criterion Covered Total %
branch 1788 3018 59.2


line true false branch
151 41171 13 if (sv_isobject(n)) {
152 41171 0 const char *hvname = HvNAME_get(SvSTASH(SvRV(n)));
41171 0 const char *hvname = HvNAME_get(SvSTASH(SvRV(n)));
0 41171 const char *hvname = HvNAME_get(SvSTASH(SvRV(n)));
0 0 const char *hvname = HvNAME_get(SvSTASH(SvRV(n)));
41171 0 const char *hvname = HvNAME_get(SvSTASH(SvRV(n)));
0 41171 const char *hvname = HvNAME_get(SvSTASH(SvRV(n)));
153 41171 0 if (hvname != 0) {
154 3 41168 if (strEQ(hvname, "Math::BigInt") || strEQ(hvname, "Math::BigFloat") ||
0 3 if (strEQ(hvname, "Math::BigInt") || strEQ(hvname, "Math::BigFloat") ||
0 0 if (strEQ(hvname, "Math::BigInt") || strEQ(hvname, "Math::BigFloat") ||
155 0 0 strEQ(hvname, "Math::GMPz") || strEQ(hvname, "Math::GMP") ||
0 0 strEQ(hvname, "Math::GMPz") || strEQ(hvname, "Math::GMP") ||
156 0 0 strEQ(hvname, "Math::GMPq") || strEQ(hvname, "Math::AnyNum") ||
0 0 strEQ(hvname, "Math::GMPq") || strEQ(hvname, "Math::AnyNum") ||
157 0 0 strEQ(hvname, "Math::Pari") || strEQ(hvname, "Math::BigInt::Lite"))
177 1020871 48908 if (SVNUMTEST(n)) { /* If defined as number, use it */
178 1020523 348 if (SvIsUV(n) || SvIVX(n) >= 0) return 1; /* The normal case */
993717 26806 if (SvIsUV(n) || SvIVX(n) >= 0) return 1; /* The normal case */
179 26795 11 if (negok) return -1;
182 41171 7737 if (sv_isobject(n)) {
184 0 41171 if (!isbignum) return 0;
187 48907 1 if (SvGAMAGIC(n) && !isbignum) return 0;
41171 7736 if (SvGAMAGIC(n) && !isbignum) return 0;
41171 0 if (SvGAMAGIC(n) && !isbignum) return 0;
41171 0 if (SvGAMAGIC(n) && !isbignum) return 0;
1 41171 if (SvGAMAGIC(n) && !isbignum) return 0;
188 20 48887 if (!SvOK(n)) croak("Parameter must be defined");
20 0 if (!SvOK(n)) croak("Parameter must be defined");
20 0 if (!SvOK(n)) croak("Parameter must be defined");
189 7487 41400 ptr = SvPV_nomg(n, len); /* Includes stringifying bigints */
190 48886 1 if (len == 0 || ptr == 0) croak("Parameter must be a positive integer");
0 48886 if (len == 0 || ptr == 0) croak("Parameter must be a positive integer");
191 1453 47433 if (ptr[0] == '-' && negok) {
1449 4 if (ptr[0] == '-' && negok) {
193 5 47432 } else if (ptr[0] == '+') {
196 48885 1 if (len == 0 || !isDIGIT(ptr[0]))
24 48861 if (len == 0 || !isDIGIT(ptr[0]))
198 48867 233 while (len > 0 && *ptr == '0') /* Strip all leading zeros */
239 48628 while (len > 0 && *ptr == '0') /* Strip all leading zeros */
200 36855 12006 if (len > uvmax_maxlen) /* Huge number, don't even look at it */
202 74275 11995 for (i = 0; i < len; i++) /* Ensure all characters are digits */
203 11 74264 if (!isDIGIT(ptr[i]))
205 1027 10968 if (isneg == 1) /* Negative number (ignore overflow) */
207 0 10968 ret = isneg ? -1 : 1;
208 0 10968 maxlen = isneg ? ivmax_maxlen : uvmax_maxlen;
209 0 10968 maxstr = isneg ? ivmax_str : uvmax_str;
210 10644 324 if (len < maxlen) /* Valid small integer */
212 1129 5 for (i = 0; i < maxlen; i++) { /* Check if in range */
213 83 1046 if (ptr[i] < maxstr[i]) return ret;
214 236 810 if (ptr[i] > maxstr[i]) return 0;
229 9776 28795 int use_gmp = stashflags & VCALL_GMP && _XS_get_callgmp() && _XS_get_callgmp() >= minversion;
0 9776 int use_gmp = stashflags & VCALL_GMP && _XS_get_callgmp() && _XS_get_callgmp() >= minversion;
0 0 int use_gmp = stashflags & VCALL_GMP && _XS_get_callgmp() && _XS_get_callgmp() >= minversion;
231 0 38571 if (use_gmp && hv_exists(MY_CXT.MPUGMP,name,namelen)) {
0 0 if (use_gmp && hv_exists(MY_CXT.MPUGMP,name,namelen)) {
233 0 0 if (gvp) gv = *gvp;
235 38571 0 if (!gv && (stashflags & VCALL_PP))
31070 7501 if (!gv && (stashflags & VCALL_PP))
237 38571 0 if (!gv) {
238 31070 7501 GV ** gvp = (GV**)hv_fetch(stashflags & VCALL_PP? MY_CXT.MPUPP : MY_CXT.MPUroot, name,namelen,0);
239 38571 0 if (gvp) gv = *gvp;
243 0 38571 PUSHMARK(PL_stack_sp-nargs);
305 0 1 dSP; ENTER; PUSHMARK(SP);
306 0 1 XPUSHs(r);
325 0 13 if (SvTYPE((SV*)av) != SVt_PVAV)
328 0 13 New(0, r, len, UV);
329 63 13 for (i = len-1; i >= 0; i--) {
331 0 63 if (_validate_int(aTHX_ *psvd, 1) != 1) break;
332 0 63 r[i] = my_svuv(*psvd) + carry;
333 14 49 if (r[i] >= (UV)base && i > 0) {
11 3 if (r[i] >= (UV)base && i > 0) {
340 0 13 if (i >= 0) {
351 122 0 return (negamod == 0) ? 0 : n-negamod;
365 80 27 for (i = 0; i < k; i++)
367 6 21 if (derangement && k >= 2) { /* Make derangements start deranged */
4 2 if (derangement && k >= 2) { /* Make derangements start deranged */
368 19 4 for (i = 0; i < k; i++)
369 11 8 cm[k-i-1] = (i&1) ? i : i+2;
370 3 1 if (k & 1) {
379 15534 6950 if (ix == 0) {
380 3887 11647 if (cm[0]++ < n) return 0; /* Increment last value */
381 38777 13 for (i = 1; i < k && cm[i] >= n-i; i++) ; /* Find next index to incr */
27143 11634 for (i = 1; i < k && cm[i] >= n-i; i++) ; /* Find next index to incr */
382 13 11634 if (i >= k) return 1; /* Done! */
384 38753 11634 while (i-- > 0) cm[i] = cm[i+1] + 1; /* Set the rest */
385 5086 1864 } else if (ix == 1) {
386 8730 6 for (j = 1; j < k && cm[j] > cm[j-1]; j++) ; /* Find last decrease */
3650 5080 for (j = 1; j < k && cm[j] > cm[j-1]; j++) ; /* Find last decrease */
387 6 5080 if (j >= k) return 1; /* Done! */
388 1818 5080 for (m = 0; cm[j] > cm[m]; m++) ; /* Find next greater */
390 2753 5080 for (i = j-1, m = 0; m < i; i--, m++) /* Reverse the end */
394 5000 5 for (j = 1; j < k && cm[j] > cm[j-1]; j++) ; /* Find last decrease */
2268 2732 for (j = 1; j < k && cm[j] > cm[j-1]; j++) ; /* Find last decrease */
395 5 2732 if (j >= k) return 1; /* Done! */
396 1134 2732 for (m = 0; cm[j] > cm[m]; m++) ; /* Find next greater */
398 536 2196 if (cm[j] == k-j) goto REDERANGE; /* Skip? */
399 1371 2196 for (i = j-1, m = 0; m < i; i--, m++) /* Reverse the end */
401 15261 1859 for (i = 0; i < k; i++) /* Check deranged */
402 337 14924 if (cm[k-i-1]-1 == i)
404 337 1859 if (i != k) goto REDERANGE;
427 7272 72 for (i = 0; i <= CINTS; i++) {
476 7272 72 for (i = 0; i <= CINTS; i++) {
491 0 6 if (items == 0) {
493 0 6 } else if (_XS_get_secure()) {
496 6 0 data = (unsigned char*) SvPV(seed, size);
499 0 6 if (_XS_get_callgmp() >= 42) _vcallsub("_csrand_p");
506 0 5 if (_XS_get_secure())
508 1 4 if (items == 0)
511 0 5 if (_XS_get_callgmp() >= 42) _vcallsub("_srand_p");
522 100005 7 if (ix == 0)
541 2002 4035 if (m != 0) RETVAL *= m;
550 55 1 RETVAL = newSV(n == 0 ? 1 : n);
563 2 0 RETVAL = newSV(n == 0 ? 1 : n);
602 10 0 if (MY_CXT.MPUPP != NULL) _vcallsub_with_pp("prime_memfree");
637 33 1161 histatus = (items == 1 || _validate_int(aTHX_ ST(1), 0));
32 1 histatus = (items == 1 || _validate_int(aTHX_ ST(1), 0));
638 1193 1 if (lostatus == 1 && histatus == 1) {
1193 0 if (lostatus == 1 && histatus == 1) {
640 1161 32 if (items == 1) {
642 0 1161 hi = my_svuv(svlo);
644 0 32 lo = my_svuv(svlo);
645 0 32 hi = my_svuv(ST(1));
647 1183 10 if (lo <= hi) {
648 141 1042 if (ix == 0) { count = prime_count(lo, hi); }
649 16 1026 else if (ix == 1) { count = semiprime_count(lo, hi); }
650 11 1015 else if (ix == 2) { count = twin_prime_count(lo, hi); }
651 10 1005 else if (ix == 3) { count = ramanujan_prime_count(lo, hi); }
652 2 1003 else if (ix == 4) { count = ramanujan_prime_count_approx(hi);
653 0 2 if (lo > 2)
655 1003 0 else if (ix == 5) {
657 0 1003 if (hi >= 29505444491UL && hi-lo > hi/50) {
0 0 if (hi >= 29505444491UL && hi-lo > hi/50) {
660 0 0 if (lostatus == 1 && lo > 2) {
0 0 if (lostatus == 1 && lo > 2) {
663 0 0 if (count < lo_loc) hicount--;
666 0 0 if (lostatus == 1 && hicount > 0)
0 0 if (lostatus == 1 && hicount > 0)
667 0 0 RETURN_128(hicount, count);
671 0 0 } else if (ix == 6) {
672 0 0 int fd = (items < 3) ? fileno(stdout) : my_sviv(ST(2));
0 0 int fd = (items < 3) ? fileno(stdout) : my_sviv(ST(2));
677 1193 0 if (lostatus == 1) XSRETURN_UV(count);
680 1 0 case 0: _vcallsubn(aTHX_ GIMME_V, VCALL_ROOT, "_generic_prime_count", items, 0); break;
698 10024 12000 histatus = (items == 1 || _validate_int(aTHX_ svhi, 0));
10017 1 histatus = (items == 1 || _validate_int(aTHX_ svhi, 0));
699 22017 1 if (lostatus == 1 && histatus == 1) {
22017 0 if (lostatus == 1 && histatus == 1) {
700 12000 10017 if (items == 1) {
702 0 12000 hi = my_svuv(svlo);
704 0 10017 lo = my_svuv(svlo);
705 0 10017 hi = my_svuv(svhi);
708 22011 6 if (ret) XSRETURN_UV(ret);
712 0 1 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
758 17 1211 if (ix == 4) { /* twin primes */
759 6 11 if ((low <= 3) && (high >= 3)) av_push(av, newSVuv( 3 ));
6 0 if ((low <= 3) && (high >= 3)) av_push(av, newSVuv( 3 ));
760 12 5 if ((low <= 5) && (high >= 5)) av_push(av, newSVuv( 5 ));
12 0 if ((low <= 5) && (high >= 5)) av_push(av, newSVuv( 5 ));
761 17 1194 } else if (ix == 5) { /* semiprimes */
762 6 11 if ((low <= 4) && (high >= 4)) av_push(av, newSVuv( 4 ));
6 0 if ((low <= 4) && (high >= 4)) av_push(av, newSVuv( 4 ));
763 7 10 if ((low <= 6) && (high >= 6)) av_push(av, newSVuv( 6 ));
7 0 if ((low <= 6) && (high >= 6)) av_push(av, newSVuv( 6 ));
764 15 1179 } else if (ix == 6) { /* ramanujan primes */
765 4 11 if ((low <= 2) && (high >= 2)) av_push(av, newSVuv( 2 ));
4 0 if ((low <= 2) && (high >= 2)) av_push(av, newSVuv( 2 ));
767 1070 109 if ((low <= 2) && (high >= 2)) av_push(av, newSVuv( 2 ));
1066 4 if ((low <= 2) && (high >= 2)) av_push(av, newSVuv( 2 ));
768 1080 99 if ((low <= 3) && (high >= 3)) av_push(av, newSVuv( 3 ));
1066 14 if ((low <= 3) && (high >= 3)) av_push(av, newSVuv( 3 ));
769 1083 96 if ((low <= 5) && (high >= 5)) av_push(av, newSVuv( 5 ));
1054 29 if ((low <= 5) && (high >= 5)) av_push(av, newSVuv( 5 ));
771 1109 119 if (low < 7) low = 7;
772 1185 43 if (low <= high) {
773 17 1168 if (ix == 4) high += 2;
774 1098 87 if (ix == 0) { /* Sieve with primary cache */
775 0 1098 START_DO_FOR_EACH_PRIME(low, high) {
0 1240998 START_DO_FOR_EACH_PRIME(low, high) {
0 0 START_DO_FOR_EACH_PRIME(low, high) {
0 0 START_DO_FOR_EACH_PRIME(low, high) {
465933 775065 START_DO_FOR_EACH_PRIME(low, high) {
156 486457 START_DO_FOR_EACH_PRIME(low, high) {
20680 465777 START_DO_FOR_EACH_PRIME(low, high) {
156 465777 START_DO_FOR_EACH_PRIME(low, high) {
0 1240842 START_DO_FOR_EACH_PRIME(low, high) {
942 1239900 START_DO_FOR_EACH_PRIME(low, high) {
778 11 76 } else if (ix == 1) { /* Trial */
779 547 11 for (low = next_prime(low-1);
780 547 0 low <= high && low != 0;
784 9 67 } else if (ix == 2) { /* Erat with private memory */
786 639 0 START_DO_FOR_EACH_SIEVE_PRIME( sieve, 0, low, high ) {
9 630 START_DO_FOR_EACH_SIEVE_PRIME( sieve, 0, low, high ) {
538 92 START_DO_FOR_EACH_SIEVE_PRIME( sieve, 0, low, high ) {
639 17 START_DO_FOR_EACH_SIEVE_PRIME( sieve, 0, low, high ) {
26 9 START_DO_FOR_EACH_SIEVE_PRIME( sieve, 0, low, high ) {
790 49 18 } else if (ix == 3 || ix == 4) { /* Segment */
17 32 } else if (ix == 3 || ix == 4) { /* Segment */
794 39 35 while (next_segment_primes(ctx, &seg_base, &seg_low, &seg_high)) {
795 394275 0 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
35 394240 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
394202 38 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
394275 22927 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
22962 39 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
796 308150 86052 if (ix == 3) av_push(av,newSVuv( p ));
797 8957 77095 else if (lastp+2 == p) av_push(av,newSVuv( lastp ));
802 17 15 } else if (ix == 5) { /* Semiprimes */
805 62 17 for (i = 0; i < count; i++)
808 15 0 } else if (ix == 6) { /* Ramanujan primes */
811 15 0 if (L && end >= beg)
14 1 if (L && end >= beg)
812 94 14 for (i = beg; i <= end; i++)
815 0 0 } else if (ix == 7) { /* Ramanujan primes */
818 0 0 if (L && high >= low)
0 0 if (L && high >= low)
819 0 0 for (i = 0; i <= (high-low); i++)
832 10 0 if (status == 1) {
834 0 10 UV factors[MPU_MAX_FACTORS+1], i, n = my_svuv(svn);
835 0 10 if (depth == 0) depth = 1; /* Trial factor takes 0 to means sqrt(n) */
836 0 10 if ( (n + width) < n) { /* Overflow */
838 10 0 } else if (depth <= 100) { /* trial division for each value */
839 4 6 for (i = (n<2)?2-n:0; i < width; i++)
1610 10 for (i = (n<2)?2-n:0; i < width; i++)
840 316 1294 if (trial_factor(n+i, factors, 2, depth) < 2)
841 0 316 XPUSHs(sv_2mortal(newSVuv( i )));
843 0 0 for (i = (n<2)?2-n:0; i < width; i++)
0 0 for (i = (n<2)?2-n:0; i < width; i++)
844 0 0 if (factor_one(n+i, factors, 1, 1) < 2 || factors[0] > depth)
0 0 if (factor_one(n+i, factors, 1, 1) < 2 || factors[0] > depth)
845 0 0 XPUSHs(sv_2mortal(newSVuv( i )));
848 0 10 if (status != 1) {
849 0 0 _vcallsubn(aTHX_ GIMME_V, VCALL_GMP|VCALL_PP, "sieve_range", items, 36);
861 0 41 if (items > 100) croak("sieve_prime_cluster: too many entries");
863 215 41 for (i = 1; i < nc; i++) {
864 0 215 if (!_validate_int(aTHX_ ST(1+i), 0)) croak("sieve_prime_cluster: cluster values must be standard integers");
865 0 215 cval = my_svuv(ST(1+i));
866 0 215 if (cval & 1) croak("sieve_prime_cluster: values must be even");
867 0 215 if (cval > 2147483647UL) croak("sieve_prime_cluster: values must be 31-bit");
868 0 215 if (cval <= cl[i-1]) croak("sieve_prime_cluster: values must be increasing");
874 32 9 if (lostatus == 1 && histatus == 1) {
32 0 if (lostatus == 1 && histatus == 1) {
875 0 32 UV low = my_svuv(svlo);
876 0 32 UV high = my_svuv(svhi);
878 32 0 if (list != 0) {
880 32 0 EXTEND(SP, (IV)nprimes);
1 31 EXTEND(SP, (IV)nprimes);
881 12276 32 for (i = 0; i < nprimes; i++)
886 9 32 if (!done) {
887 9 0 _vcallsubn(aTHX_ GIMME_V, VCALL_GMP|VCALL_PP, "sieve_prime_cluster", items, 34);
909 0 83 if (n == 0) XSRETURN_UV(0);
910 0 83 if (ix == 9) { /* We don't have an ecm_factor, call PP. */
911 0 0 _vcallsubn(aTHX_ GIMME_V, VCALL_PP, "ecm_factor", 1, 0);
915 2 81 arg1 = (items >= 2) ? my_svuv(ST(1)) : default_arg1[ix];
0 2 arg1 = (items >= 2) ? my_svuv(ST(1)) : default_arg1[ix];
916 0 83 arg2 = (items >= 3) ? my_svuv(ST(2)) : 0;
0 0 arg2 = (items >= 3) ? my_svuv(ST(2)) : 0;
918 0 48 while ( (n% 2) == 0 ) { n /= 2; XPUSHs(sv_2mortal(newSVuv( 2 ))); }
48 83 while ( (n% 2) == 0 ) { n /= 2; XPUSHs(sv_2mortal(newSVuv( 2 ))); }
919 0 48 while ( (n% 3) == 0 ) { n /= 3; XPUSHs(sv_2mortal(newSVuv( 3 ))); }
48 83 while ( (n% 3) == 0 ) { n /= 3; XPUSHs(sv_2mortal(newSVuv( 3 ))); }
920 0 64 while ( (n% 5) == 0 ) { n /= 5; XPUSHs(sv_2mortal(newSVuv( 5 ))); }
64 83 while ( (n% 5) == 0 ) { n /= 5; XPUSHs(sv_2mortal(newSVuv( 5 ))); }
921 43 40 if (n == 1) { /* done */ }
922 24 19 else if (is_prime(n)) { XPUSHs(sv_2mortal(newSVuv( n ))); }
0 24 else if (is_prime(n)) { XPUSHs(sv_2mortal(newSVuv( n ))); }
934 2 0 case 7: if (items < 3) arg2 = 1;
937 2 0 default: if (items < 3) arg2 = 10*arg1;
940 19 0 EXTEND(SP, nfactors);
0 19 EXTEND(SP, nfactors);
941 39 19 for (i = 0; i < nfactors; i++)
953 1 55132 if (items < 2)
956 160309 54838 for (c = 0; c < items && status == 1; c++)
160015 294 for (c = 0; c < items && status == 1; c++)
957 294 159721 if (_validate_int(aTHX_ ST(c), 0) != 1)
959 54838 294 if (status == 1) {
960 0 54838 UV n = my_svuv(svn);
962 8 54830 if (n < 4) { /* 0,1 composite; 2,3 prime */
964 82 54748 } else if (ix == 1) { /* Fermat test */
965 86 82 for (c = 1; c < items && ret == 1; c++)
86 0 for (c = 1; c < items && ret == 1; c++)
966 0 86 ret = is_pseudoprime(n, my_svuv(ST(c)));
967 109 54639 } else if (ix == 2) { /* Euler test */
968 109 109 for (c = 1; c < items && ret == 1; c++)
109 0 for (c = 1; c < items && ret == 1; c++)
969 0 109 ret = is_euler_pseudoprime(n, my_svuv(ST(c)));
970 27032 27607 } else if ((n % 2) == 0) { /* evens composite */
974 27607 27605 for (c = 1; c < items && ret == 1; ) {
27607 0 for (c = 1; c < items && ret == 1; ) {
975 80237 0 for (b = 0; b < 32 && c < items; c++)
52630 27607 for (b = 0; b < 32 && c < items; c++)
976 0 52630 bases[b++] = my_svuv(ST(c));
980 54836 0 RETURN_NPARITY(ret);
54836 0 RETURN_NPARITY(ret);
1003 20547 14 if (ix == 2 || ix == 3) {
15 20532 if (ix == 2 || ix == 3) {
1006 2 27 if (items == 0) XSRETURN_UNDEF;
1007 6 21 if (items == 1) XSRETURN(1);
1009 19 2 if (status != 0 && items > 1) {
19 0 if (status != 0 && items > 1) {
1011 0 19 ret = my_svuv(ST(0));
1012 79 19 for (i = 1; i < items; i++) {
1014 0 79 if (status == 0) break;
1015 0 79 n = my_svuv(ST(i));
1016 21 58 if (( (sign == -1 && status == 1) ||
15 6 if (( (sign == -1 && status == 1) ||
50 23 if (( (sign == -1 && status == 1) ||
31 48 if (( (sign == -1 && status == 1) ||
1017 40 10 (n >= ret && sign == status)
1025 19 2 if (status != 0) {
1029 2739 17793 } else if (ix == 4) {
1032 118616 2216 for (ret = i = 0; i < items; i++) {
1034 403 118213 if (status == 0) break;
1035 20 118193 n = my_svuv(ST(i));
1036 117260 953 if (status == 1) {
1039 120 833 if (UV_MAX-n == (UV)IV_MAX) { status = 0; break; } /* IV Overflow */
1044 2216 523 if (status != 0 && hi != 0) {
5 2211 if (status != 0 && hi != 0) {
1045 4 1 if (hi == -1 && lo > IV_MAX) XSRETURN_IV((IV)lo);
4 0 if (hi == -1 && lo > IV_MAX) XSRETURN_IV((IV)lo);
1046 0 1 else RETURN_128(hi, lo);
1049 15822 1971 } else if (ix == 5) {
1052 19785 1790 for (i = 0; i < items; i++) {
1054 13363 6422 if (status == 0) break;
1055 6413 9 n = (status == 1) ? my_svuv(ST(i)) : (UV)-my_sviv(ST(i));
0 6413 n = (status == 1) ? my_svuv(ST(i)) : (UV)-my_sviv(ST(i));
9 0 n = (status == 1) ? my_svuv(ST(i)) : (UV)-my_sviv(ST(i));
1056 6421 1 if (ret > 0 && n > UV_MAX/ret) { status = 0; break; }
669 5752 if (ret > 0 && n > UV_MAX/ret) { status = 0; break; }
1060 5 15817 if (sign == -1 && status != 0) {
5 0 if (sign == -1 && status != 0) {
1061 5 0 if (ret <= (UV)IV_MAX) XSRETURN_IV(-(IV)ret);
1066 1946 25 if (ix == 0) { ret = 0; nullv = 1; }
1068 3957 1959 for (i = 0; i < items && ret != nullv && status != 0; i++) {
3953 4 for (i = 0; i < items && ret != nullv && status != 0; i++) {
3952 1 for (i = 0; i < items && ret != nullv && status != 0; i++) {
1070 7 3945 if (status == 0)
1072 6 3939 n = status * my_svuv(ST(i)); /* n = abs(arg) */
1073 1965 1980 if (i == 0) {
1077 1950 30 if (ix == 0) {
1081 28 2 if (n <= (UV_MAX / ret) ) ret *= n;
1087 5958 14566 if (status != 0)
1090 14565 1 if ((ix == 2 || ix == 3) && !sv_isobject(ST(0))) {
1 14564 if ((ix == 2 || ix == 3) && !sv_isobject(ST(0))) {
2 0 if ((ix == 2 || ix == 3) && !sv_isobject(ST(0))) {
1095 2 0 aptr = SvPV(ST(0), alen);
1097 2 2 for (i = 1; i < items; i++) {
1098 2 0 bptr = SvPV(ST(i), blen);
1099 2 0 if (strnum_minmax(minmax, aptr, alen, bptr, blen)) {
1125 2 0 if ((!SvROK(x)) || (SvTYPE(SvRV(x)) != SVt_PVAV))
0 2 if ((!SvROK(x)) || (SvTYPE(SvRV(x)) != SVt_PVAV))
1128 1 1 if (SvROK(svm) && SvTYPE(SvRV(svm)) == SVt_PVAV) {
1 0 if (SvROK(svm) && SvTYPE(SvRV(svm)) == SVt_PVAV) {
1131 5 1 for (j = 0; j <= mlen; j++) {
1133 5 0 if (iv && SvTYPE(*iv) == SVt_IV) {
5 0 if (iv && SvTYPE(*iv) == SVt_IV) {
1134 5 0 SV **v = av_fetch(av, SvIV(*iv), 0);
1135 5 0 if (v) XPUSHs(*v);
0 5 if (v) XPUSHs(*v);
1138 1 0 } else if (_validate_int(aTHX_ svm, 0)) {
1139 0 1 UV mask = my_svuv(svm);
1140 24 1 while (mask) {
1141 13 11 if (mask & 1) {
1143 13 0 if (v) XPUSHs(*v);
0 13 if (v) XPUSHs(*v);
1149 0 0 _vcallsubn(aTHX_ GIMME_V, VCALL_PP, "vecextract", items, 0);
1162 0 25 New(0, an, 2*items, UV);
1164 47 22 for (i = 0; i < items; i++) {
1166 47 0 if (!SvROK(ST(i)) || SvTYPE(SvRV(ST(i))) != SVt_PVAV || av_len((AV*)SvRV(ST(i))) != 1)
47 0 if (!SvROK(ST(i)) || SvTYPE(SvRV(ST(i))) != SVt_PVAV || av_len((AV*)SvRV(ST(i))) != 1)
0 47 if (!SvROK(ST(i)) || SvTYPE(SvRV(ST(i))) != SVt_PVAV || av_len((AV*)SvRV(ST(i))) != 1)
1171 47 0 if (psva == 0 || psvn == 0 || _validate_int(aTHX_ *psva, 1) != 1 || !_validate_int(aTHX_ *psvn, 0)) {
47 0 if (psva == 0 || psvn == 0 || _validate_int(aTHX_ *psva, 1) != 1 || !_validate_int(aTHX_ *psvn, 0)) {
44 3 if (psva == 0 || psvn == 0 || _validate_int(aTHX_ *psva, 1) != 1 || !_validate_int(aTHX_ *psvn, 0)) {
0 44 if (psva == 0 || psvn == 0 || _validate_int(aTHX_ *psva, 1) != 1 || !_validate_int(aTHX_ *psvn, 0)) {
1175 0 44 an[i+0] = my_svuv(*psva);
1176 0 44 an[i+items] = my_svuv(*psvn);
1178 22 3 if (status)
1181 5 20 if (status == -1) XSRETURN_UNDEF;
1182 13 7 if (status) XSRETURN_UV(ret);
1185 2 5 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
2 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
2 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
2 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 1 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 1 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 1 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 1 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
0 0 OBJECTIFY_RESULT( (psvn ? *psvn : 0), ST(0));
1196 26445 199 if (ix == 1 || ix == 2) {
152 26293 if (ix == 1 || ix == 2) {
1197 0 351 if (items != 3) croak("lucasu: P, Q, k");
1198 351 0 if (_validate_int(aTHX_ ST(0), 1) && _validate_int(aTHX_ ST(1), 1) &&
1200 351 0 IV P = my_sviv(ST(0));
1201 351 0 IV Q = my_sviv(ST(1));
1202 0 351 UV k = my_svuv(ST(2));
1204 199 152 int ok = (ix == 1) ? lucasu(&ret, P, Q, k) : lucasv(&ret, P, Q, k);
1205 351 0 if (ok) XSRETURN_IV(ret);
1207 0 0 _vcallsub_with_gmpobj(0.29,(ix==1) ? "lucasu" : "lucasv");
1208 0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
0 0 OBJECTIFY_RESULT(ST(2), ST(0));
1211 0 26293 if (items != 4) croak("lucas_sequence: n, P, Q, k");
1212 26291 2 if (_validate_int(aTHX_ ST(0), 0) && _validate_int(aTHX_ ST(1), 1) &&
1213 26291 0 _validate_int(aTHX_ ST(2), 1) && _validate_int(aTHX_ ST(3), 0)) {
1214 0 26291 lucas_seq(&U, &V, &Qk,
26278 13 lucas_seq(&U, &V, &Qk,
26278 13 lucas_seq(&U, &V, &Qk,
0 26291 lucas_seq(&U, &V, &Qk,
1220 2 0 _vcallsubn(aTHX_ GIMME_V, VCALL_PP, "lucas_sequence", items, 0);
1250 465806 384 if (status == 1) {
1251 9 465797 UV n = my_svuv(svn);
1271 0 2282 case 18: ret = is_mersenne_prime(n); if (ret == -1) status = 0; break;
1275 36 348 } else if (status == -1) {
1277 26 10 if (ix == 13) {
1278 26 0 IV sn = my_sviv(svn);
1279 26 0 if (sn > -IV_MAX) ret = is_square_free(-sn);
1283 465842 348 if (status != 0) RETURN_NPARITY(ret);
465842 0 if (status != 0) RETURN_NPARITY(ret);
465842 0 if (status != 0) RETURN_NPARITY(ret);
1314 52 52 if (status == 1)
1315 0 52 RETURN_NPARITY(is_fundamental(my_svuv(svn), 0));
52 0 RETURN_NPARITY(is_fundamental(my_svuv(svn), 0));
52 0 RETURN_NPARITY(is_fundamental(my_svuv(svn), 0));
1316 50 2 if (status == -1) {
1317 50 0 IV sn = my_sviv(svn);
1318 50 0 if (sn > -IV_MAX)
1319 50 0 RETURN_NPARITY(is_fundamental(-sn, 1));
50 0 RETURN_NPARITY(is_fundamental(-sn, 1));
1331 10404 256 if (status != 0) {
1333 2 10402 UV n = my_svuv(svn);
1334 65 10339 if (status == -1) {
1335 17 48 IV sn = my_sviv(svn);
1336 2 63 if (sn <= -IV_MAX) status = 0;
1339 65 10339 if (status == 1 || (status == -1 && (k == 0 || k & 1))) {
63 2 if (status == 1 || (status == -1 && (k == 0 || k & 1))) {
4 59 if (status == 1 || (status == -1 && (k == 0 || k & 1))) {
2 2 if (status == 1 || (status == -1 && (k == 0 || k & 1))) {
1341 61 10339 if (status == -1 && k == 0) {
59 2 if (status == -1 && k == 0) {
1343 11 48 if (ret == 1) ret = 0;
1345 139 10261 if (ret && svroot != 0) {
29 110 if (ret && svroot != 0) {
1346 27 2 UV root = rootof(n, k ? k : (UV)ret);
1347 0 29 if (!SvROK(svroot)) croak("is_power: third argument not a scalar reference");
1348 11 18 if (status == 1) sv_setuv(SvRV(svroot), root);
1352 10402 2 if (status != 0) RETURN_NPARITY(ret);
10402 0 if (status != 0) RETURN_NPARITY(ret);
10402 0 if (status != 0) RETURN_NPARITY(ret);
1354 130 128 if (svroot == 0) { _vcallsub_with_gmp(0.28, "is_power"); }
1365 0 10254 if (status == -1)
1366 0 0 RETURN_NPARITY(0);
0 0 RETURN_NPARITY(0);
1367 10254 0 if (status != 0) {
1368 0 10254 n = my_svuv(svn);
1370 2818 7436 if (ret && svroot != 0) {
17 2801 if (ret && svroot != 0) {
1371 0 17 if (!SvROK(svroot))croak("is_prime_power: second argument not a scalar reference");
1374 10254 0 RETURN_NPARITY(ret);
10254 0 RETURN_NPARITY(ret);
1376 0 0 (void)_vcallsubn(aTHX_ G_SCALAR, (svroot == 0) ? (VCALL_GMP|VCALL_PP) : (VCALL_PP), "is_prime_power", items, 40);
1388 70 1 if (status == 1) {
1389 0 70 UV n = my_svuv(svn);
1390 20 50 if (ix == 0) ret = is_perrin_pseudoprime(n, k);
1393 70 1 if (status != 0) RETURN_NPARITY(ret);
70 0 if (status != 0) RETURN_NPARITY(ret);
70 0 if (status != 0) RETURN_NPARITY(ret);
1394 1 0 if (ix == 0)
1395 1 0 _vcallsub_with_gmp( (k == 0) ? 0.20 : 0.40, "is_perrin_pseudoprime");
1407 28 0 if (status == 1) {
1408 0 28 UV n = my_svuv(svn);
1411 28 0 if (status != 0) RETURN_NPARITY(ret);
28 0 if (status != 0) RETURN_NPARITY(ret);
28 0 if (status != 0) RETURN_NPARITY(ret);
1421 0 25302 if (k < 3) croak("is_polygonal: k must be >= 3");
1423 25300 2 if (status != 0) {
1425 0 25300 if (status == -1) {
1428 0 25300 n = my_svuv(svn);
1430 25300 0 result = (n == 0) || root;
460 24840 result = (n == 0) || root;
1432 25300 0 if (!overflow) {
1433 460 24840 if (result && svroot != 0) {
230 230 if (result && svroot != 0) {
1434 0 230 if (!SvROK(svroot)) croak("is_polygonal: third argument not a scalar reference");
1437 25300 0 RETURN_NPARITY(result);
25300 0 RETURN_NPARITY(result);
1440 2 0 if (items != 3) { _vcallsub_with_gmp(0.47, "is_polygonal"); }
1453 624 2 if (status != 0) {
1454 0 624 n = my_svuv(svn);
1455 21 603 if (svret != 0 && !SvROK(svret))
0 21 if (svret != 0 && !SvROK(svret))
1456 0 0 croak("%s: third argument not a scalar reference",(ix==0)?"logint":"rootint");
1457 601 23 if (ix == 0) {
1458 601 0 if (status != 1 || n <= 0) croak("logint: n must be > 0");
0 601 if (status != 1 || n <= 0) croak("logint: n must be > 0");
1459 0 601 if (k <= 1) croak("logint: base must be > 1");
1461 1 600 if (svret) sv_setuv(SvRV(svret), ipow(k,root));
1463 0 23 if (status == -1) croak("rootint: n must be >= 0");
1464 0 23 if (k <= 0) croak("rootint: k must be > 0");
1466 20 3 if (svret) sv_setuv(SvRV(svret), ipow(root,k));
1471 0 0 case 0: (void)_vcallsubn(aTHX_ G_SCALAR, (svret == 0) ? (VCALL_GMP|VCALL_PP) : (VCALL_PP), "logint", items, 47); break;
1472 2 0 case 1: (void)_vcallsubn(aTHX_ G_SCALAR, (svret == 0) ? (VCALL_GMP|VCALL_PP) : (VCALL_PP), "rootint", items, 40); break;
1484 1 7 if (bases < 0) croak("miller_rabin_random: number of bases must be positive");
1485 5 2 if (status != 0 && seed == 0) {
5 0 if (status != 0 && seed == 0) {
1486 0 5 UV n = my_svuv(svn);
1487 5 0 RETURN_NPARITY( is_mr_random(MY_CXT.randcxt, n, bases) );
5 0 RETURN_NPARITY( is_mr_random(MY_CXT.randcxt, n, bases) );
1518 12721 52 if (_validate_int(aTHX_ svn, 0)) {
1519 11 12710 UV n = my_svuv(svn);
1520 9 12712 if ( (n >= MPU_MAX_PRIME && ix == 0)
4 5 if ( (n >= MPU_MAX_PRIME && ix == 0)
1521 30 12687 || (n >= MPU_MAX_PRIME_IDX && (ix==2 || ix==3 || ix==4 || ix==5 || ix == 6))
30 0 || (n >= MPU_MAX_PRIME_IDX && (ix==2 || ix==3 || ix==4 || ix==5 || ix == 6))
29 1 || (n >= MPU_MAX_PRIME_IDX && (ix==2 || ix==3 || ix==4 || ix==5 || ix == 6))
26 3 || (n >= MPU_MAX_PRIME_IDX && (ix==2 || ix==3 || ix==4 || ix==5 || ix == 6))
26 0 || (n >= MPU_MAX_PRIME_IDX && (ix==2 || ix==3 || ix==4 || ix==5 || ix == 6))
0 26 || (n >= MPU_MAX_PRIME_IDX && (ix==2 || ix==3 || ix==4 || ix==5 || ix == 6))
1522 37 12676 || (n >= MPU_MAX_TWIN_PRIME_IDX && (ix==7 || ix==8))
37 0 || (n >= MPU_MAX_TWIN_PRIME_IDX && (ix==7 || ix==8))
0 37 || (n >= MPU_MAX_TWIN_PRIME_IDX && (ix==7 || ix==8))
1523 20 12693 || (n >= MPU_MAX_SEMI_PRIME_IDX && (ix==9 || ix==10))
20 0 || (n >= MPU_MAX_SEMI_PRIME_IDX && (ix==9 || ix==10))
0 20 || (n >= MPU_MAX_SEMI_PRIME_IDX && (ix==9 || ix==10))
1524 37 12676 || (n >= MPU_MAX_RMJN_PRIME_IDX && (ix==11 || ix==12 || ix==13 || ix==14)) ) {
37 0 || (n >= MPU_MAX_RMJN_PRIME_IDX && (ix==11 || ix==12 || ix==13 || ix==14)) ) {
37 0 || (n >= MPU_MAX_RMJN_PRIME_IDX && (ix==11 || ix==12 || ix==13 || ix==14)) ) {
37 0 || (n >= MPU_MAX_RMJN_PRIME_IDX && (ix==11 || ix==12 || ix==13 || ix==14)) ) {
0 37 || (n >= MPU_MAX_RMJN_PRIME_IDX && (ix==11 || ix==12 || ix==13 || ix==14)) ) {
1529 3759 8954 if (ix == 1 && n < 3) XSRETURN_UNDEF;
5 3754 if (ix == 1 && n < 3) XSRETURN_UNDEF;
1531 7 12701 if (n == 0 && (ix >= 2 && ix <= 10 && ix != 6)) XSRETURN_UNDEF;
6 1 if (n == 0 && (ix >= 2 && ix <= 10 && ix != 6)) XSRETURN_UNDEF;
5 1 if (n == 0 && (ix >= 2 && ix <= 10 && ix != 6)) XSRETURN_UNDEF;
4 1 if (n == 0 && (ix >= 2 && ix <= 10 && ix != 6)) XSRETURN_UNDEF;
1534 3754 0 case 1: ret = (n < 3) ? 0 : prev_prime(n); break;
1564 53 7 if ((ix == 0 || ix == 1) && _XS_get_callgmp() && PERL_REVISION >= 5 && PERL_VERSION > 8) {
2 51 if ((ix == 0 || ix == 1) && _XS_get_callgmp() && PERL_REVISION >= 5 && PERL_VERSION > 8) {
0 9 if ((ix == 0 || ix == 1) && _XS_get_callgmp() && PERL_REVISION >= 5 && PERL_VERSION > 8) {
1565 0 0 _vcallsub_with_gmpobj(0.01, ix ? "prev_prime" : "next_prime");
1566 0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
1594 0 27 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
0 0 OBJECTIFY_RESULT(svn, ST(0));
1625 294 318 if (minarg > 0 && bits < minarg)
6 288 if (minarg > 0 && bits < minarg)
1628 549 57 if (bits <= BITS_PER_WORD) {
1641 5 544 if (res || ix == 0) XSRETURN_UV(res);
2 3 if (res || ix == 0) XSRETURN_UV(res);
1655 1 59 OBJECTIFY_RESULT(ST(0), ST(0));
1 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 1 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 1 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
1660 1 0 if (_validate_int(aTHX_ svn, 0)) {
1663 0 1 UV r, F[MPU_MAX_FACTORS+1], n = my_svuv(svn);
1665 0 1 if (n < 1) croak("random_factored_integer: n must be >= 1");
1668 3 1 for (f = 0; f < nf; f++)
1669 0 3 av_push(av, newSVuv(F[flip ? nf-1-f : f]));
1670 0 1 XPUSHs(sv_2mortal(newSVuv( r )));
1671 0 1 XPUSHs(sv_2mortal(newRV_noinc( (SV*) av )));
1693 1 1000 if (digits == 0) {
1695 15 985 } else if (digits <= mantsize) {
1710 0 972 if (digits <= 0) XSRETURN_EMPTY;
1712 0 972 XPUSHs(sv_2mortal(newSVpvn(out, digits+1)));
1725 1642 0 gimme_v = GIMME_V;
1727 1526 116 it_overflow = (status == 1 && ix==3 && gimme_v == G_ARRAY && my_svuv(svn) > UV_MAX/7.5 );
105 1421 it_overflow = (status == 1 && ix==3 && gimme_v == G_ARRAY && my_svuv(svn) > UV_MAX/7.5 );
2 103 it_overflow = (status == 1 && ix==3 && gimme_v == G_ARRAY && my_svuv(svn) > UV_MAX/7.5 );
0 2 it_overflow = (status == 1 && ix==3 && gimme_v == G_ARRAY && my_svuv(svn) > UV_MAX/7.5 );
0 0 it_overflow = (status == 1 && ix==3 && gimme_v == G_ARRAY && my_svuv(svn) > UV_MAX/7.5 );
0 2 it_overflow = (status == 1 && ix==3 && gimme_v == G_ARRAY && my_svuv(svn) > UV_MAX/7.5 );
1728 1526 116 if (status == 1 && !it_overflow) {
1526 0 if (status == 1 && !it_overflow) {
1731 1 1525 UV n = my_svuv(svn);
1732 155 1371 if (gimme_v == G_SCALAR) {
1741 1371 0 } else if (gimme_v == G_ARRAY) {
1744 188 0 EXTEND(SP, nfactors);
0 188 EXTEND(SP, nfactors);
1745 607 188 for (i = 0; i < nfactors; i++)
1750 228 0 EXTEND(SP, nfactors);
0 228 EXTEND(SP, nfactors);
1751 489 228 for (i = 0; i < nfactors; i++) {
1761 953 0 EXTEND(SP, (IV)ndivisors);
0 953 EXTEND(SP, (IV)ndivisors);
1762 5255 953 for (i = 0; (UV)i < ndivisors; i++)
1770 2 0 EXTEND(SP, (IV)ntotients);
0 2 EXTEND(SP, (IV)ntotients);
1771 18 2 for (i = 0; (UV)i < ntotients; i++)
1794 2239 92 svk = (items > 1) ? ST(1) : 0;
1796 2239 92 kstatus = (items == 1 || (SvIOK(svk) && SvIV(svk) >= 0)) ? 1 : 0;
1320 919 kstatus = (items == 1 || (SvIOK(svk) && SvIV(svk) >= 0)) ? 1 : 0;
1320 0 kstatus = (items == 1 || (SvIOK(svk) && SvIV(svk) >= 0)) ? 1 : 0;
1320 0 kstatus = (items == 1 || (SvIOK(svk) && SvIV(svk) >= 0)) ? 1 : 0;
0 0 kstatus = (items == 1 || (SvIOK(svk) && SvIV(svk) >= 0)) ? 1 : 0;
1798 2324 7 if (nstatus == 1 && kstatus == 0 && SvROK(svk) && (sv_isa(svk, "Math::BigInt") || sv_isa(svk, "Math::GMP") || sv_isa(svk, "Math::GMPz")))
913 1411 if (nstatus == 1 && kstatus == 0 && SvROK(svk) && (sv_isa(svk, "Math::BigInt") || sv_isa(svk, "Math::GMP") || sv_isa(svk, "Math::GMPz")))
913 0 if (nstatus == 1 && kstatus == 0 && SvROK(svk) && (sv_isa(svk, "Math::BigInt") || sv_isa(svk, "Math::GMP") || sv_isa(svk, "Math::GMPz")))
913 0 if (nstatus == 1 && kstatus == 0 && SvROK(svk) && (sv_isa(svk, "Math::BigInt") || sv_isa(svk, "Math::GMP") || sv_isa(svk, "Math::GMPz")))
913 0 if (nstatus == 1 && kstatus == 0 && SvROK(svk) && (sv_isa(svk, "Math::BigInt") || sv_isa(svk, "Math::GMP") || sv_isa(svk, "Math::GMPz")))
0 913 if (nstatus == 1 && kstatus == 0 && SvROK(svk) && (sv_isa(svk, "Math::BigInt") || sv_isa(svk, "Math::GMP") || sv_isa(svk, "Math::GMPz")))
1800 2324 7 if (nstatus == 1 && kstatus == 1) {
1411 913 if (nstatus == 1 && kstatus == 1) {
1801 0 1411 UV n = my_svuv(svn);
1802 1320 91 UV k = (items > 1) ? my_svuv(svk) : 1;
0 1320 UV k = (items > 1) ? my_svuv(svk) : 1;
1804 1411 0 if (sigma != 0) XSRETURN_UV(sigma); /* sigma 0 means overflow */
1820 16599 2256 astatus = _validate_int(aTHX_ sva, (ix==1) ? 2 : 0);
1821 16599 2256 nstatus = _validate_int(aTHX_ svn, (ix==1) ? 2 : 0);
1822 18855 0 if (astatus != 0 && nstatus != 0) {
18851 4 if (astatus != 0 && nstatus != 0) {
1823 0 18851 UV a = my_svuv(sva);
1824 0 18851 UV n = my_svuv(svn);
1829 16562 37 case 1: if ( (astatus == 1 && (nstatus == -1 || n > a)) ||
16544 18 case 1: if ( (astatus == 1 && (nstatus == -1 || n > a)) ||
16536 8 case 1: if ( (astatus == 1 && (nstatus == -1 || n > a)) ||
37 16536 case 1: if ( (astatus == 1 && (nstatus == -1 || n > a)) ||
1830 17 20 (astatus ==-1 && (nstatus == -1 && n > a)) )
9 8 (astatus ==-1 && (nstatus == -1 && n > a)) )
1832 8 16556 if (nstatus == -1)
1834 28 16536 if (astatus == -1) {
1835 28 0 ret = binomial( -my_sviv(sva)+n-1, n );
1836 28 0 if (ret > 0 && ret <= (UV)IV_MAX)
28 0 if (ret > 0 && ret <= (UV)IV_MAX)
1837 15 13 XSRETURN_IV( (IV)ret * ((n&1) ? -1 : 1) );
1841 5232 11304 if (ret == 0)
1846 22 468 if (ret == 0 && n > 1)
22 0 if (ret == 0 && n > 1)
1849 901 1 case 3: if (a < 1 || n < 1) XSRETURN_IV(0);
1 900 case 3: if (a < 1 || n < 1) XSRETURN_IV(0);
1853 676 224 if (m == 0 || a == g) RETURN_NPARITY(m);
391 285 if (m == 0 || a == g) RETURN_NPARITY(m);
615 0 if (m == 0 || a == g) RETURN_NPARITY(m);
615 0 if (m == 0 || a == g) RETURN_NPARITY(m);
1863 456 12211 if (ret == 0 && ix == 0) XSRETURN_UNDEF; /* not defined */
4 452 if (ret == 0 && ix == 0) XSRETURN_UNDEF; /* not defined */
1892 1278 7345 if (astatus != 0 && gstatus != 0 && pstatus == 1) {
1269 9 if (astatus != 0 && gstatus != 0 && pstatus == 1) {
1232 37 if (astatus != 0 && gstatus != 0 && pstatus == 1) {
1893 120 1112 UV a, g, p = my_svuv(svp);
1894 224 1008 if (p <= 1) XSRETURN_UV(0);
1897 1008 0 a = (astatus == 1) ? my_svuv(sva) : negmod(my_sviv(sva), p);
104 904 a = (astatus == 1) ? my_svuv(sva) : negmod(my_sviv(sva), p);
0 0 a = (astatus == 1) ? my_svuv(sva) : negmod(my_sviv(sva), p);
1898 888 120 g = (gstatus == 1) ? my_svuv(svg) : negmod(my_sviv(svg), p);
64 824 g = (gstatus == 1) ? my_svuv(svg) : negmod(my_sviv(svg), p);
120 0 g = (gstatus == 1) ? my_svuv(svg) : negmod(my_sviv(svg), p);
1899 105 903 if (a >= p) a %= p;
1900 52 956 if (g >= p && ix != 4) g %= p;
39 13 if (g >= p && ix != 4) g %= p;
1903 5 15 if (ret == 0 && a > 1) retundef = 1;
3 2 if (ret == 0 && a > 1) retundef = 1;
1904 5 15 if (ret == 0 && (a == 0 || g == 0)) retundef = 1;
5 0 if (ret == 0 && (a == 0 || g == 0)) retundef = 1;
0 5 if (ret == 0 && (a == 0 || g == 0)) retundef = 1;
1909 24 37 if (g == 0) retundef = 1;
1913 0 248 default:if (a == 0) {
1917 30 218 if (gstatus == -1) {
1919 16 14 if (a == 0) retundef = 1;
1920 14 0 else g = -my_sviv(svg);
1926 43 965 if (retundef) XSRETURN_UNDEF;
1937 7391 0 OBJECTIFY_RESULT(svp, ST(items-1));
7391 0 OBJECTIFY_RESULT(svp, ST(items-1));
7391 0 OBJECTIFY_RESULT(svp, ST(items-1));
7391 0 OBJECTIFY_RESULT(svp, ST(items-1));
7391 0 OBJECTIFY_RESULT(svp, ST(items-1));
0 7391 OBJECTIFY_RESULT(svp, ST(items-1));
0 0 OBJECTIFY_RESULT(svp, ST(items-1));
7391 0 OBJECTIFY_RESULT(svp, ST(items-1));
0 7391 OBJECTIFY_RESULT(svp, ST(items-1));
7391 0 OBJECTIFY_RESULT(svp, ST(items-1));
7391 0 OBJECTIFY_RESULT(svp, ST(items-1));
0 0 OBJECTIFY_RESULT(svp, ST(items-1));
0 0 OBJECTIFY_RESULT(svp, ST(items-1));
0 0 OBJECTIFY_RESULT(svp, ST(items-1));
0 0 OBJECTIFY_RESULT(svp, ST(items-1));
0 0 OBJECTIFY_RESULT(svp, ST(items-1));
0 0 OBJECTIFY_RESULT(svp, ST(items-1));
0 0 OBJECTIFY_RESULT(svp, ST(items-1));
1952 229 4 if (astatus != 0 && bstatus != 0) {
227 2 if (astatus != 0 && bstatus != 0) {
1953 171 56 if (ix == 0) {
1955 159 12 abpositive = astatus == 1 && bstatus == 1;
151 8 abpositive = astatus == 1 && bstatus == 1;
1958 20 0 && (SvIOK(sva) && !SvIsUV(sva))
19 1 && (SvIOK(sva) && !SvIsUV(sva))
1959 20 151 && (SvIOK(svb) && !SvIsUV(svb));
19 0 && (SvIOK(svb) && !SvIsUV(svb));
18 1 && (SvIOK(svb) && !SvIsUV(svb));
1960 20 151 if (abpositive || abnegative) {
18 2 if (abpositive || abnegative) {
1961 3 166 UV a = my_svuv(sva);
1962 2 167 UV b = my_svuv(svb);
1963 151 18 int k = (abpositive) ? kronecker_uu(a,b) : kronecker_ss(a,b);
1964 169 0 RETURN_NPARITY(k);
169 0 RETURN_NPARITY(k);
1966 5 51 } else if (ix == 1) {
1967 1 4 UV n = (astatus == -1) ? (UV)(-(my_sviv(sva))) : my_svuv(sva);
1 0 UV n = (astatus == -1) ? (UV)(-(my_sviv(sva))) : my_svuv(sva);
0 4 UV n = (astatus == -1) ? (UV)(-(my_sviv(sva))) : my_svuv(sva);
1968 0 5 UV k = (bstatus == -1) ? (UV)(-(my_sviv(svb))) : my_svuv(svb);
0 0 UV k = (bstatus == -1) ? (UV)(-(my_sviv(svb))) : my_svuv(svb);
0 5 UV k = (bstatus == -1) ? (UV)(-(my_sviv(svb))) : my_svuv(svb);
1970 5 0 RETURN_NPARITY( valuation(n, k) );
5 0 RETURN_NPARITY( valuation(n, k) );
1971 12 39 } else if (ix == 2) {
1973 10 2 n = (bstatus != -1) ? my_svuv(svb) : (UV)(-(my_sviv(svb)));
2 8 n = (bstatus != -1) ? my_svuv(svb) : (UV)(-(my_sviv(svb)));
2 0 n = (bstatus != -1) ? my_svuv(svb) : (UV)(-(my_sviv(svb)));
1974 10 2 if (n > 0) {
1975 8 2 a = (astatus == 1) ? my_svuv(sva) : negmod(my_sviv(sva), n);
0 8 a = (astatus == 1) ? my_svuv(sva) : negmod(my_sviv(sva), n);
2 0 a = (astatus == 1) ? my_svuv(sva) : negmod(my_sviv(sva), n);
1976 9 1 if (a > 0) {
1977 1 8 if (n == 1) XSRETURN_UV(0);
1981 4 7 if (ret == 0) XSRETURN_UNDEF;
1983 12 27 } else if (ix == 3) {
1985 12 0 n = (bstatus != -1) ? my_svuv(svb) : (UV)(-(my_sviv(svb)));
0 12 n = (bstatus != -1) ? my_svuv(svb) : (UV)(-(my_sviv(svb)));
0 0 n = (bstatus != -1) ? my_svuv(svb) : (UV)(-(my_sviv(svb)));
1986 10 2 a = (n == 0) ? 0 : (astatus != -1) ? my_svuv(sva) % n : negmod(my_sviv(sva), n);
10 0 a = (n == 0) ? 0 : (astatus != -1) ? my_svuv(sva) % n : negmod(my_sviv(sva), n);
0 10 a = (n == 0) ? 0 : (astatus != -1) ? my_svuv(sva) % n : negmod(my_sviv(sva), n);
0 0 a = (n == 0) ? 0 : (astatus != -1) ? my_svuv(sva) % n : negmod(my_sviv(sva), n);
1987 5 7 if (is_prob_prime(n)) {
1988 0 5 if (!sqrtmod(&s, a, n)) XSRETURN_UNDEF;
1990 2 5 if (!sqrtmod_composite(&s, a, n)) XSRETURN_UNDEF;
1995 26 1 n = (bstatus != -1) ? my_svuv(svb) : (UV)(-(my_sviv(svb)));
2 24 n = (bstatus != -1) ? my_svuv(svb) : (UV)(-(my_sviv(svb)));
1 0 n = (bstatus != -1) ? my_svuv(svb) : (UV)(-(my_sviv(svb)));
1996 26 1 a = (n == 0) ? 0 : (astatus != -1) ? my_svuv(sva) % n : negmod(my_sviv(sva), n);
26 0 a = (n == 0) ? 0 : (astatus != -1) ? my_svuv(sva) % n : negmod(my_sviv(sva), n);
0 26 a = (n == 0) ? 0 : (astatus != -1) ? my_svuv(sva) % n : negmod(my_sviv(sva), n);
0 0 a = (n == 0) ? 0 : (astatus != -1) ? my_svuv(sva) % n : negmod(my_sviv(sva), n);
1997 27 0 RETURN_NPARITY( is_primitive_root(a,n,0) );
27 0 RETURN_NPARITY( is_primitive_root(a,n,0) );
2018 10 4 if ( (astatus == 1 && SvIsUV(sva)) || (astatus == -1 && !SvIOK(sva)) )
9 1 if ( (astatus == 1 && SvIsUV(sva)) || (astatus == -1 && !SvIOK(sva)) )
3 10 if ( (astatus == 1 && SvIsUV(sva)) || (astatus == -1 && !SvIOK(sva)) )
0 3 if ( (astatus == 1 && SvIsUV(sva)) || (astatus == -1 && !SvIOK(sva)) )
2020 10 4 if ( (bstatus == 1 && SvIsUV(svb)) || (bstatus == -1 && !SvIOK(svb)) )
10 0 if ( (bstatus == 1 && SvIsUV(svb)) || (bstatus == -1 && !SvIOK(svb)) )
3 11 if ( (bstatus == 1 && SvIsUV(svb)) || (bstatus == -1 && !SvIOK(svb)) )
0 3 if ( (bstatus == 1 && SvIsUV(svb)) || (bstatus == -1 && !SvIOK(svb)) )
2022 12 2 if (astatus != 0 && bstatus != 0) {
12 0 if (astatus != 0 && bstatus != 0) {
2024 12 0 IV a = my_sviv(sva);
2025 12 0 IV b = my_sviv(svb);
2027 0 12 XPUSHs(sv_2mortal(newSViv( u )));
2028 0 12 XPUSHs(sv_2mortal(newSViv( v )));
2029 0 12 XPUSHs(sv_2mortal(newSViv( d )));
2031 2 0 _vcallsubn(aTHX_ GIMME_V, VCALL_PP, "gcdext", items, 0);
2038 1288 255 if (type != 1 && type != 2 && type != 3)
253 1035 if (type != 1 && type != 2 && type != 3)
1 252 if (type != 1 && type != 2 && type != 3)
2040 63 1479 if (n == m)
2042 1476 3 else if (n == 0 || m == 0 || m > n)
1416 60 else if (n == 0 || m == 0 || m > n)
61 1355 else if (n == 0 || m == 0 || m > n)
2044 190 1165 else if (type == 3) {
2046 185 5 if (s != 0) XSRETURN_UV(s);
2047 973 192 } else if (type == 2) {
2049 509 464 if (s != 0) XSRETURN_IV(s);
2050 192 0 } else if (type == 1) {
2052 145 47 if (s != 0) XSRETURN_IV(s);
2055 27 489 OBJECTIFY_RESULT(ST(0), ST(0));
27 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 27 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 27 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
2068 44 20 nv = SvNV(x);
2089 36 28155 histatus = (svhi == 0 || _validate_int(aTHX_ svhi, 1));
35 1 histatus = (svhi == 0 || _validate_int(aTHX_ svhi, 1));
2090 28155 36 if (svhi == 0 && lostatus != 0) {
28144 11 if (svhi == 0 && lostatus != 0) {
2092 74 28070 if (ix == 0) {
2093 73 1 UV ret = (lostatus == -1) ? 0 : totient(my_svuv(svlo));
0 73 UV ret = (lostatus == -1) ? 0 : totient(my_svuv(svlo));
2096 20 28050 UV n = (lostatus == -1) ? (UV)(-(my_sviv(svlo))) : my_svuv(svlo);
20 0 UV n = (lostatus == -1) ? (UV)(-(my_sviv(svlo))) : my_svuv(svlo);
0 28050 UV n = (lostatus == -1) ? (UV)(-(my_sviv(svlo))) : my_svuv(svlo);
2097 28070 0 RETURN_NPARITY(moebius(n));
28070 0 RETURN_NPARITY(moebius(n));
2099 36 11 } else if (items == 2 && lostatus == 1 && histatus == 1) {
33 3 } else if (items == 2 && lostatus == 1 && histatus == 1) {
32 1 } else if (items == 2 && lostatus == 1 && histatus == 1) {
2101 0 32 UV lo = my_svuv(svlo);
2102 0 32 UV hi = my_svuv(svhi);
2103 31 1 if (lo <= hi) {
2105 31 0 EXTEND(SP, (IV)count);
3 28 EXTEND(SP, (IV)count);
2106 8 23 if (ix == 0) {
2107 1 7 UV arrlo = (lo < 100) ? 0 : lo;
2109 286 8 for (i = 0; i < count; i++)
2115 27886 23 for (i = 0; i < count; i++)
2116 27886 0 PUSH_NPARITY(mu[i]);
27886 0 PUSH_NPARITY(mu[i]);
2122 15 0 U32 gimme_v = GIMME_V;
2124 12 3 if (ix == 1 && lostatus == 1 && histatus == 1) flags |= VCALL_GMP;
0 12 if (ix == 1 && lostatus == 1 && histatus == 1) flags |= VCALL_GMP;
0 0 if (ix == 1 && lostatus == 1 && histatus == 1) flags |= VCALL_GMP;
2125 3 12 switch (ix) {
2152 2580 7 if (status != 0) {
2153 2 2578 UV r, n = my_svuv(svn);
2158 2 58 int nfactors = factor(my_svuv(svn), factors);
2159 30 30 RETURN_NPARITY( (nfactors & 1) ? -1 : 1 ); }
60 0 RETURN_NPARITY( (nfactors & 1) ? -1 : 1 ); }
60 0 RETURN_NPARITY( (nfactors & 1) ? -1 : 1 ); }
2164 678 302 if (r != 0) XSRETURN_UV(r);
2167 20 1 case 7: XSRETURN_UV( (status == -1) ? 1 : exp_mangoldt(n) ); break;
2168 2 23 case 8: if (status == -1) n = -(IV)n;
2170 5 20 if (r == 0 && n != 1) XSRETURN_UNDEF; /* No root */
4 1 if (r == 0 && n != 1) XSRETURN_UNDEF; /* No root */
2172 1 6 case 9: if (status == -1) n = -(IV)n;
2174 96 1 case 10: XSRETURN_IV( (status == -1) ? 0 : hclassno(n) ); break;
2175 993 0 case 11: RETURN_NPARITY( (status == -1) ? 0 : pillai_v(n) ); break;
993 0 case 11: RETURN_NPARITY( (status == -1) ? 0 : pillai_v(n) ); break;
943 50 case 11: RETURN_NPARITY( (status == -1) ? 0 : pillai_v(n) ); break;
2177 10 0 default: { IV tau = (status == 1) ? ramanujan_tau(n) : 0;
2178 5 5 if (tau != 0 || status == -1 || n == 0)
5 0 if (tau != 0 || status == -1 || n == 0)
1 4 if (tau != 0 || status == -1 || n == 0)
2194 0 2 case 9: if (_XS_get_callgmp() >= 47) { /* Very fast */
2197 2 0 char* ptr; STRLEN len; ptr = SvPV(svn, len);
2214 1 5 if (n == 0)
2216 5 0 if (n < 32 && _validate_int(aTHX_ svk, 1) == 1) {
5 0 if (n < 32 && _validate_int(aTHX_ svk, 1) == 1) {
2217 0 5 k = my_svuv(svk);
2218 5 0 if (num_to_perm(k, n, S)) {
2220 5 0 EXTEND(SP, (IV)n);
0 5 EXTEND(SP, (IV)n);
2221 45 5 for (i = 0; i < (int)n; i++)
2222 45 0 PUSH_NPARITY( S[i] );
45 0 PUSH_NPARITY( S[i] );
2226 0 0 _vcallsubn(aTHX_ GIMME_V, VCALL_PP|VCALL_GMP, "numtoperm", items, 47);
2236 6 0 if ((!SvROK(svp)) || (SvTYPE(SvRV(svp)) != SVt_PVAV))
0 6 if ((!SvROK(svp)) || (SvTYPE(SvRV(svp)) != SVt_PVAV))
2240 6 0 if (plen < 32) {
2242 68 6 for (i = 0; i <= plen; i++) {
2244 68 0 if (iv == 0 || _validate_int(aTHX_ *iv, 1) != 1) break;
68 0 if (iv == 0 || _validate_int(aTHX_ *iv, 1) != 1) break;
2245 0 68 val = my_svuv(*iv);
2246 68 0 if (val > (UV)plen || A[val] != 0) break;
68 0 if (val > (UV)plen || A[val] != 0) break;
2250 6 0 if (i > plen && perm_to_num(plen+1, V, &num))
4 2 if (i > plen && perm_to_num(plen+1, V, &num))
2254 1 1 OBJECTIFY_RESULT(ST(0), ST(0));
1 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 1 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 1 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
0 0 OBJECTIFY_RESULT(ST(0), ST(0));
2263 3 1 if (items == 1) k = n;
2264 0 4 if (k > n) k = n;
2265 1 3 if (k == 0) XSRETURN_EMPTY;
2266 0 3 New(0, S, k, UV);
2268 3 0 EXTEND(SP, (IV)k);
0 3 EXTEND(SP, (IV)k);
2269 105 3 for (i = 0; i < k; i++) {
2270 105 0 if (n < 2*CINTS) PUSH_NPARITY(S[i]);
105 0 if (n < 2*CINTS) PUSH_NPARITY(S[i]);
105 0 if (n < 2*CINTS) PUSH_NPARITY(S[i]);
2282 1 2 if (items == 0)
2284 99 2 for (i = 0, randcxt = MY_CXT.randcxt; i < items-1; i++) {
2297 0 1007 base = (ibase == 255) ? 10 : ibase;
2298 1007 0 if (base < 2 || base > 36) croak("sumdigits: invalid base %"UVuf, base);
0 1007 if (base < 2 || base > 36) croak("sumdigits: invalid base %"UVuf, base);
2301 1007 0 if (base == 10 && SVNUMTEST(svn) && (SvIsUV(svn) || SvIVX(svn) >= 0)) {
1001 6 if (base == 10 && SVNUMTEST(svn) && (SvIsUV(svn) || SvIVX(svn) >= 0)) {
1001 0 if (base == 10 && SVNUMTEST(svn) && (SvIsUV(svn) || SvIVX(svn) >= 0)) {
1001 0 if (base == 10 && SVNUMTEST(svn) && (SvIsUV(svn) || SvIVX(svn) >= 0)) {
2302 0 1001 UV n, t = my_svuv(svn);
2303 2893 1001 while ((n=t)) {
2309 3 3 s = SvPV(svn, len);
2311 6 0 if (ibase == 255 && len > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'b')){
6 0 if (ibase == 255 && len > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'b')){
1 5 if (ibase == 255 && len > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'b')){
0 1 if (ibase == 255 && len > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'b')){
0 0 if (ibase == 255 && len > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'b')){
2312 1 0 base = (s[1] == 'x') ? 16 : 2;
2316 38634 6 for (i = 0; i < len; i++) {
2319 38631 3 if (c >= '0' && c <= '9') { d = c - '0'; }
38629 2 if (c >= '0' && c <= '9') { d = c - '0'; }
2320 1 4 else if (c >= 'a' && c <= 'z') { d = c - 'a' + 10; }
1 0 else if (c >= 'a' && c <= 'z') { d = c - 'a' + 10; }
2321 1 3 else if (c >= 'A' && c <= 'Z') { d = c - 'A' + 10; }
1 0 else if (c >= 'A' && c <= 'Z') { d = c - 'A' + 10; }
2322 38634 0 if (d < base)
2336 0 38 if (base < 2) croak("invalid base: %d", base);
2338 22 16 if (ix == 0 || ix == 1) {
3 19 if (ix == 0 || ix == 1) {
2340 17 2 n = (status == 0) ? 0 : status * my_svuv(svn);
0 17 n = (status == 0) ? 0 : status * my_svuv(svn);
2343 16 22 if (ix == 0 && status != 0 && length < 128) {
14 2 if (ix == 0 && status != 0 && length < 128) {
14 0 if (ix == 0 && status != 0 && length < 128) {
2346 14 0 if (len >= 0) {
2348 14 0 EXTEND(SP, len);
0 14 EXTEND(SP, len);
2349 89 14 for (i = 0; i < len; i++)
2350 89 0 PUSH_NPARITY( digits[len-i-1] );
89 0 PUSH_NPARITY( digits[len-i-1] );
2355 3 21 if (ix == 1 && status != 0 && length < 128) {
3 0 if (ix == 1 && status != 0 && length < 128) {
3 0 if (ix == 1 && status != 0 && length < 128) {
2358 3 0 if (len >= 0) {
2359 0 3 XPUSHs(sv_2mortal(newSVpv(s, len)));
2364 19 2 if ((ix == 0 || ix == 1) && base == 10 && length < 0) {
0 19 if ((ix == 0 || ix == 1) && base == 10 && length < 0) {
1 1 if ((ix == 0 || ix == 1) && base == 10 && length < 0) {
1 0 if ((ix == 0 || ix == 1) && base == 10 && length < 0) {
2366 1 0 str = SvPV(svn, len);
2367 0 1 if (ix == 1) {
2368 0 0 XPUSHs(sv_2mortal(newSVpv(str, len)));
2371 0 1 if (len == 1 && str[0] == '0') XSRETURN(0);
0 0 if (len == 1 && str[0] == '0') XSRETURN(0);
2374 1 0 EXTEND(SP, (IV)len);
0 1 EXTEND(SP, (IV)len);
2375 45 1 for (i = 0; i < (int)len; i++)
2376 45 0 PUSH_NPARITY(str[i]-'0');
45 0 PUSH_NPARITY(str[i]-'0');
2380 19 1 if (ix == 2) { /* fromdigits */
2381 6 13 if (!SvROK(svn)) { /* string */
2382 6 0 if (from_digit_string(&n, SvPV_nolen(svn), base)) {
5 1 if (from_digit_string(&n, SvPV_nolen(svn), base)) {
2385 13 0 } else if (!_is_sv_bigint(aTHX_ svn)) { /* array ref of digits */
2388 13 0 if (from_digit_to_UV(&n, r, len, base)) {
2391 0 0 } else if (from_digit_to_str(&str, r, len, base)){
2393 0 0 XPUSHs( sv_to_bigint(aTHX_ sv_2mortal(newSVpv(str,0))) );
2401 1 0 case 0: _vcallsubn(aTHX_ GIMME_V, VCALL_GMP|VCALL_PP, "todigits", items, 41); break;
2421 1924 96 if (_validate_int(aTHX_ svn, 0)) {
2422 78 1846 if (SvROK(svn)) { /* Convert small Math::BigInt object into scalar */
2423 0 78 UV n = my_svuv(svn);
2430 3 1921 if (items > 1 && ((sv1 = ST(1)), SvOK(sv1))) {
0 3 if (items > 1 && ((sv1 = ST(1)), SvOK(sv1))) {
0 0 if (items > 1 && ((sv1 = ST(1)), SvOK(sv1))) {
0 0 if (items > 1 && ((sv1 = ST(1)), SvOK(sv1))) {
3 0 if (items > 1 && ((sv1 = ST(1)), SvOK(sv1))) {
2431 0 3 UV n = my_svuv(svn);
2432 0 3 UV min = my_svuv(sv1);
2433 0 3 if (n < min)
2435 0 3 if (items > 2 && ((sv2 = ST(2)), SvOK(sv2))) {
0 0 if (items > 2 && ((sv2 = ST(2)), SvOK(sv2))) {
0 0 if (items > 2 && ((sv2 = ST(2)), SvOK(sv2))) {
0 0 if (items > 2 && ((sv2 = ST(2)), SvOK(sv2))) {
0 0 if (items > 2 && ((sv2 = ST(2)), SvOK(sv2))) {
2436 0 0 UV max = my_svuv(sv2);
2437 0 0 if (n > max)
2439 0 0 MPUassert( items <= 3, "_validate_num takes at most 3 parameters");
2453 0 90 if (MY_CXT.forcount == 0) croak("lastfor called outside a loop");
2496 0 73 if (cv == Nullcv)
2499 68 0 if (!_validate_int(aTHX_ svbeg, 0) || (items >= 3 && !_validate_int(aTHX_ svend,0))) {
31 37 if (!_validate_int(aTHX_ svbeg, 0) || (items >= 3 && !_validate_int(aTHX_ svend,0))) {
0 28 if (!_validate_int(aTHX_ svbeg, 0) || (items >= 3 && !_validate_int(aTHX_ svend,0))) {
2504 37 28 if (items < 3) {
2506 0 37 end = my_svuv(svbeg);
2508 0 28 beg = my_svuv(svbeg);
2509 0 28 end = my_svuv(svend);
2517 123 64 while (beg < 6) {
2518 85 38 beg = (beg <= 2) ? 2 : (beg <= 3) ? 3 : 5;
41 44 beg = (beg <= 2) ? 2 : (beg <= 3) ? 3 : 5;
2519 116 7 if (beg <= end) {
2521 0 116 PUSHMARK(SP);
2523 1 115 CHECK_FORCOUNT;
2525 84 38 beg += 1 + (beg > 2);
2528 65 0 if (!CvISXSUB(cv) && beg <= end) {
58 7 if (!CvISXSUB(cv) && beg <= end) {
2531 0 58 PUSH_MULTICALL(cv);
0 58 PUSH_MULTICALL(cv);
2532 0 58 if (
2534 0 0 (beg >= UVCONST( 100000000000000) && end-beg < 100000) ||
0 58 (beg >= UVCONST( 100000000000000) && end-beg < 100000) ||
2535 0 0 (beg >= UVCONST( 10000000000000) && end-beg < 40000) ||
0 58 (beg >= UVCONST( 10000000000000) && end-beg < 40000) ||
2536 0 0 (beg >= UVCONST( 1000000000000) && end-beg < 17000) ||
31 27 (beg >= UVCONST( 1000000000000) && end-beg < 17000) ||
2539 141 30 for (beg = next_prime(beg-1); beg <= end && beg != 0; beg = next_prime(beg)) {
141 0 for (beg = next_prime(beg-1); beg <= end && beg != 0; beg = next_prime(beg)) {
2540 1 140 CHECK_FORCOUNT;
2546 27 2 while (next_segment_primes(ctx, &seg_base, &seg_low, &seg_high)) {
2547 0 27 int crossuv = (seg_high > IV_MAX) && !SvIsUV(svarg);
0 0 int crossuv = (seg_high > IV_MAX) && !SvIsUV(svarg);
2548 1266 0 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
2 1264 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
1261 3 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
1266 17 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
133 27 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
2549 114 1147 CHECK_FORCOUNT;
2551 165 982 if (SvTYPE(svarg) != SVt_IV) { sv_setuv(svarg, p); }
2552 0 982 else if (crossuv && p > IV_MAX) { sv_setuv(svarg, p); crossuv=0; }
0 0 else if (crossuv && p > IV_MAX) { sv_setuv(svarg, p); crossuv=0; }
2556 25 2 CHECK_FORCOUNT;
2561 58 0 POP_MULTICALL;
0 58 POP_MULTICALL;
2565 0 7 if (beg <= end) { /* NO-MULTICALL segment sieve */
2567 0 0 while (next_segment_primes(ctx, &seg_base, &seg_low, &seg_high)) {
2568 0 0 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
0 0 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
0 0 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
0 0 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
0 0 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
2569 0 0 CHECK_FORCOUNT;
2571 0 0 PUSHMARK(SP);
2574 0 0 CHECK_FORCOUNT;
2579 0 65 END_FORCOUNT;
2599 0 59 if (cv == Nullcv)
2602 59 0 if (!_validate_int(aTHX_ svbeg, 0) || (items >= 3 && !_validate_int(aTHX_ svend,0))) {
2 57 if (!_validate_int(aTHX_ svbeg, 0) || (items >= 3 && !_validate_int(aTHX_ svend,0))) {
0 2 if (!_validate_int(aTHX_ svbeg, 0) || (items >= 3 && !_validate_int(aTHX_ svend,0))) {
2603 0 0 _vcallsubn(aTHX_ G_VOID|G_DISCARD, VCALL_ROOT,
2609 57 2 if (items < 3) {
2610 31 26 beg = ix ? 4 : 9;
2611 0 57 end = my_svuv(svbeg);
2613 0 2 beg = my_svuv(svbeg);
2614 0 2 end = my_svuv(svend);
2622 59 0 if (!CvISXSUB(cv) && end >= beg) {
57 2 if (!CvISXSUB(cv) && end >= beg) {
2628 0 57 PUSH_MULTICALL(cv);
0 57 PUSH_MULTICALL(cv);
2629 57 0 if (beg >= MPU_MAX_PRIME ||
0 57 if (beg >= MPU_MAX_PRIME ||
2631 0 0 (beg >= UVCONST( 100000000000000) && end-beg < 120000) ||
0 57 (beg >= UVCONST( 100000000000000) && end-beg < 120000) ||
2632 0 0 (beg >= UVCONST( 10000000000000) && end-beg < 50000) ||
0 57 (beg >= UVCONST( 10000000000000) && end-beg < 50000) ||
2633 0 0 (beg >= UVCONST( 1000000000000) && end-beg < 20000) ||
55 2 (beg >= UVCONST( 1000000000000) && end-beg < 20000) ||
2636 27 28 beg = (beg <= 4) ? 3 : beg-1;
2638 3928 5 while (beg++ < end) {
2639 907 3021 if (beg == nextprime)
2641 2058 963 else if (FORCOMPTEST(ix,beg)) {
2058 0 else if (FORCOMPTEST(ix,beg)) {
753 1305 else if (FORCOMPTEST(ix,beg)) {
2645 50 3878 CHECK_FORCOUNT;
2648 1 1 if (!ix) {
2649 0 1 if (beg < 8) beg = 8;
2650 1 0 } else if (beg <= 4) { /* sieve starts at 7, so handle this here */
2658 2 0 nextprime = (end >= MPU_MAX_PRIME) ? MPU_MAX_PRIME : next_prime(end);
2660 2 2 while (next_segment_primes(ctx, &seg_base, &seg_low, &seg_high)) {
2661 0 2 int crossuv = (seg_high > IV_MAX) && !SvIsUV(svarg);
0 0 int crossuv = (seg_high > IV_MAX) && !SvIsUV(svarg);
2662 8729 0 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
2 8727 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
8726 1 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
8729 352 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
354 2 START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_base, seg_low, seg_high )
2664 1 8725 if (cbeg < beg)
2665 1 0 cbeg = beg - (ix == 0 && (beg % 2));
1 0 cbeg = beg - (ix == 0 && (beg % 2));
2667 2 8724 cend = prevprime-1; if (cend > end) cend = end;
2669 6466 2260 cinc = 1 + (ix==0);
2670 29528 6766 for (c = cbeg + (ix==0); c <= cend; c += cinc) {
2671 1960 27568 CHECK_FORCOUNT;
2672 0 27568 if (SvTYPE(svarg) != SVt_IV) { sv_setuv(svarg,c); }
2673 0 27568 else if (crossuv && c > IV_MAX) { sv_setuv(svarg,c); crossuv=0;}
0 0 else if (crossuv && c > IV_MAX) { sv_setuv(svarg,c); crossuv=0;}
2680 0 2 if (end > nextprime) /* Complete the case where end > max_prime */
2681 0 0 while (nextprime++ < end)
2682 0 0 if (FORCOMPTEST(ix,nextprime)) {
0 0 if (FORCOMPTEST(ix,nextprime)) {
0 0 if (FORCOMPTEST(ix,nextprime)) {
2683 0 0 CHECK_FORCOUNT;
2689 57 0 POP_MULTICALL;
0 57 POP_MULTICALL;
2693 0 2 if (beg <= end) {
2694 0 0 beg = (beg <= 4) ? 3 : beg-1;
2695 0 0 while (beg++ < end) {
2696 0 0 if (FORCOMPTEST(ix,beg) && !is_prob_prime(beg)) {
0 0 if (FORCOMPTEST(ix,beg) && !is_prob_prime(beg)) {
0 0 if (FORCOMPTEST(ix,beg) && !is_prob_prime(beg)) {
0 0 if (FORCOMPTEST(ix,beg) && !is_prob_prime(beg)) {
2698 0 0 PUSHMARK(SP);
2700 0 0 CHECK_FORCOUNT;
2705 0 59 END_FORCOUNT;
2720 0 2 if (cv == Nullcv)
2723 2 0 if (!_validate_int(aTHX_ svbeg, 0) || (items >= 3 && !_validate_int(aTHX_ svend,0))) {
1 1 if (!_validate_int(aTHX_ svbeg, 0) || (items >= 3 && !_validate_int(aTHX_ svend,0))) {
0 1 if (!_validate_int(aTHX_ svbeg, 0) || (items >= 3 && !_validate_int(aTHX_ svend,0))) {
2728 1 1 if (items < 3) {
2730 0 1 end = my_svuv(svbeg);
2732 0 1 beg = my_svuv(svbeg);
2733 0 1 end = my_svuv(svend);
2735 0 2 if (beg < 4) beg = 4;
2736 0 2 if (end > MPU_MAX_SEMI_PRIME) end = MPU_MAX_SEMI_PRIME;
2743 2 0 if (!CvISXSUB(cv) && end >= beg) {
2 0 if (!CvISXSUB(cv) && end >= beg) {
2747 0 2 PUSH_MULTICALL(cv);
0 2 PUSH_MULTICALL(cv);
2748 2 0 if (beg >= MPU_MAX_SEMI_PRIME ||
0 2 if (beg >= MPU_MAX_SEMI_PRIME ||
2750 0 0 (beg >= UVCONST(10000000000000000000) && end-beg < 1400000) ||
0 2 (beg >= UVCONST(10000000000000000000) && end-beg < 1400000) ||
2751 0 0 (beg >= UVCONST( 1000000000000000000) && end-beg < 950000) ||
0 2 (beg >= UVCONST( 1000000000000000000) && end-beg < 950000) ||
2752 0 0 (beg >= UVCONST( 100000000000000000) && end-beg < 440000) ||
0 2 (beg >= UVCONST( 100000000000000000) && end-beg < 440000) ||
2753 0 0 (beg >= UVCONST( 10000000000000000) && end-beg < 240000) ||
0 2 (beg >= UVCONST( 10000000000000000) && end-beg < 240000) ||
2754 0 0 (beg >= UVCONST( 1000000000000000) && end-beg < 65000) ||
0 2 (beg >= UVCONST( 1000000000000000) && end-beg < 65000) ||
2755 0 0 (beg >= UVCONST( 100000000000000) && end-beg < 29000) ||
0 2 (beg >= UVCONST( 100000000000000) && end-beg < 29000) ||
2756 0 0 (beg >= UVCONST( 10000000000000) && end-beg < 11000) ||
0 2 (beg >= UVCONST( 10000000000000) && end-beg < 11000) ||
2757 0 0 (beg >= UVCONST( 1000000000000) && end-beg < 5000) ||
1 1 (beg >= UVCONST( 1000000000000) && end-beg < 5000) ||
2760 1 0 beg = (beg <= 4) ? 3 : beg-1;
2761 21 1 while (beg++ < end) {
2762 3 18 if (is_semiprime(beg)) {
2766 0 21 CHECK_FORCOUNT;
2769 1 1 while (beg < end) {
2772 0 1 if ((seg_end - seg_beg) > 50000000) seg_end = seg_beg + 50000000 - 1;
2774 299 1 for (c = 0; c < count; c++) {
2777 0 299 CHECK_FORCOUNT;
2781 0 1 CHECK_FORCOUNT;
2785 2 0 POP_MULTICALL;
0 2 POP_MULTICALL;
2789 0 0 if (beg <= end) {
2790 0 0 beg = (beg <= 4) ? 3 : beg-1;
2791 0 0 while (beg++ < end) {
2792 0 0 if (is_semiprime(beg)) {
2794 0 0 PUSHMARK(SP);
2796 0 0 CHECK_FORCOUNT;
2801 0 2 END_FORCOUNT;
2817 0 71 if (cv == Nullcv)
2820 0 71 if (!_validate_int(aTHX_ svn, 0)) {
2825 0 71 n = my_svuv(svn);
2833 71 0 if (!CvISXSUB(cv)) {
2836 0 71 PUSH_MULTICALL(cv);
0 71 PUSH_MULTICALL(cv);
2837 272 64 for (i = 0; i < ndivisors; i++) {
2840 7 265 CHECK_FORCOUNT;
2843 71 0 POP_MULTICALL;
0 71 POP_MULTICALL;
2848 0 0 for (i = 0; i < ndivisors; i++) {
2850 0 0 PUSHMARK(SP);
2852 0 0 CHECK_FORCOUNT;
2857 0 71 END_FORCOUNT;
2875 0 34 if (cv == Nullcv)
2877 0 34 if (!_validate_int(aTHX_ svn, 0)) {
2881 0 34 n = my_svuv(svn);
2882 0 34 if (n > (UV_MAX-2)) croak("forpart argument overflow");
2884 0 34 New(0, svals, n+1, SV*);
2885 673 34 for (i = 0; i <= n; i++) {
2891 16 18 if (svh != 0) {
2894 16 0 if (!SvROK(svh) || SvTYPE(SvRV(svh)) != SVt_PVHV)
0 16 if (!SvROK(svh) || SvTYPE(SvRV(svh)) != SVt_PVHV)
2897 8 8 if ((svp = hv_fetchs(rhash, "n", 0)) != NULL)
2898 0 8 { nmin = my_svuv(*svp); nmax = nmin; }
2899 9 7 if ((svp = hv_fetchs(rhash, "amin", 0)) != NULL) amin = my_svuv(*svp);
0 9 if ((svp = hv_fetchs(rhash, "amin", 0)) != NULL) amin = my_svuv(*svp);
2900 5 11 if ((svp = hv_fetchs(rhash, "amax", 0)) != NULL) amax = my_svuv(*svp);
0 5 if ((svp = hv_fetchs(rhash, "amax", 0)) != NULL) amax = my_svuv(*svp);
2901 2 14 if ((svp = hv_fetchs(rhash, "nmin", 0)) != NULL) nmin = my_svuv(*svp);
0 2 if ((svp = hv_fetchs(rhash, "nmin", 0)) != NULL) nmin = my_svuv(*svp);
2902 2 14 if ((svp = hv_fetchs(rhash, "nmax", 0)) != NULL) nmax = my_svuv(*svp);
0 2 if ((svp = hv_fetchs(rhash, "nmax", 0)) != NULL) nmax = my_svuv(*svp);
2903 3 13 if ((svp = hv_fetchs(rhash, "prime",0)) != NULL) primeq=my_svuv(*svp);
0 3 if ((svp = hv_fetchs(rhash, "prime",0)) != NULL) primeq=my_svuv(*svp);
2905 0 16 if (amin < 1) amin = 1;
2906 0 16 if (amax > n) amax = n;
2907 0 16 if (nmin < 1) nmin = 1;
2908 0 16 if (nmax > n) nmax = n;
2909 15 1 if (primeq != 0 && primeq != -1) primeq = 2; /* -1, 0, or 2 */
2 13 if (primeq != 0 && primeq != -1) primeq = 2; /* -1, 0, or 2 */
2912 2 32 if (primeq == 2) {
2914 1 1 UV next = amin <= 2 ? 2 : next_prime(amin-1);
2915 0 2 if (amin < next) amin = next;
2916 0 2 if (amax > prev) amax = prev;
2919 2 32 if (n==0 && nmin <= 1) {
2 0 if (n==0 && nmin <= 1) {
2920 0 2 { PUSHMARK(SP);
2925 32 2 if (n >= nmin && nmin <= nmax && amin <= amax && nmax > 0 && amax > 0)
32 0 if (n >= nmin && nmin <= nmax && amin <= amax && nmax > 0 && amax > 0)
31 1 if (n >= nmin && nmin <= nmax && amin <= amax && nmax > 0 && amax > 0)
31 0 if (n >= nmin && nmin <= nmax && amin <= amax && nmax > 0 && amax > 0)
31 0 if (n >= nmin && nmin <= nmax && amin <= amax && nmax > 0 && amax > 0)
2928 0 31 New(0, a, n+1, UV);
2933 15843 17 while (k != 0) {
2937 15786 57 r = (ix == 0) ? x : 1;
2938 20374 15843 while (r <= y) {
2946 4548 15843 while (k+1 > nmax) { /* Skip range if over max size */
2951 3617 12226 if (k+1 < nmin) { /* Skip if not over min size */
2952 9 3608 if (a[0] >= n-nmin+1 && a[k] > 1) break; /* early exit check */
9 0 if (a[0] >= n-nmin+1 && a[k] > 1) break; /* early exit check */
2957 9389 2837 if (amin > 1 || amax < n) {
615 8774 if (amin > 1 || amax < n) {
2959 3 3449 if (a[0] > amax) break;
2961 3428 21 if (ix == 0) { /* value restrictions for partitions */
2962 578 2850 if (a[k] > amax) continue;
2965 51 7 for (i = 0; i <= k; i++)
2966 44 7 if (a[i] < amin || a[i] > amax)
37 7 if (a[i] < amin || a[i] > amax)
2968 14 7 if (i <= k) continue;
2971 2602 9029 if (primeq != -1) {
2972 2510 1189 for (i = 0; i <= k; i++) if (is_prime(a[i]) != primeq) break;
3699 92 for (i = 0; i <= k; i++) if (is_prime(a[i]) != primeq) break;
2973 2510 92 if (i <= k) continue;
2976 0 9121 PUSHMARK(SP); EXTEND(SP, (IV)k);
9121 0 PUSHMARK(SP); EXTEND(SP, (IV)k);
0 9121 PUSHMARK(SP); EXTEND(SP, (IV)k);
2977 75999 9121 for (i = 0; i <= k; i++) { PUSHs(svals[a[i]]); }
2979 2 9119 CHECK_FORCOUNT;
2982 0 31 END_FORCOUNT;
2984 673 34 for (i = 0; i <= n; i++)
3005 0 24 if (cv == Nullcv)
3007 13 11 if (ix > 0 && svk != 0)
0 13 if (ix > 0 && svk != 0)
3010 24 0 if (!_validate_int(aTHX_ svn, 0) || (svk != 0 && !_validate_int(aTHX_ svk, 0))) {
8 16 if (!_validate_int(aTHX_ svn, 0) || (svk != 0 && !_validate_int(aTHX_ svk, 0))) {
0 8 if (!_validate_int(aTHX_ svn, 0) || (svk != 0 && !_validate_int(aTHX_ svk, 0))) {
3011 0 0 _vcallsub_with_pp( (ix == 0) ? "forcomb"
0 0 _vcallsub_with_pp( (ix == 0) ? "forcomb"
3017 0 24 n = my_svuv(svn);
3018 16 8 if (svk == 0) {
3019 13 3 begk = (ix == 0) ? 0 : n;
3022 0 8 begk = endk = my_svuv(svk);
3023 1 7 if (begk > n)
3027 0 23 New(0, svals, n, SV*);
3028 92 23 for (i = 0; i < n; i++) {
3032 0 23 New(0, cm, endk+1, UV);
3036 23 0 if (!CvISXSUB(cv)) {
3041 0 23 PUSH_MULTICALL(cv);
0 23 PUSH_MULTICALL(cv);
3042 27 20 for (k = begk; k <= endk; k++) {
3045 1865 20622 if (ix < 2 || k != 1) {
1864 1 if (ix < 2 || k != 1) {
3049 281154 22486 for (j = k-1; j >= 0; j--)
3053 3 22484 CHECK_FORCOUNT;
3054 24 22460 if (_comb_iterate(cm, k, n, ix)) break;
3056 3 24 CHECK_FORCOUNT;
3059 23 0 POP_MULTICALL;
0 23 POP_MULTICALL;
3063 0 0 for (k = begk; k <= endk; k++) {
3066 0 0 if (ix < 2 || k != 1) {
0 0 if (ix < 2 || k != 1) {
3067 0 0 PUSHMARK(SP); EXTEND(SP, ((IV)k));
0 0 PUSHMARK(SP); EXTEND(SP, ((IV)k));
0 0 PUSHMARK(SP); EXTEND(SP, ((IV)k));
3068 0 0 for (i = 0; i < k; i++) { PUSHs(svals[ cm[k-i-1]-1 ]); }
3071 0 0 CHECK_FORCOUNT;
3072 0 0 if (_comb_iterate(cm, k, n, ix)) break;
3074 0 0 CHECK_FORCOUNT;
3079 92 23 for (i = 0; i < n; i++)
3082 0 23 END_FORCOUNT;
3098 0 9 if (cv == Nullcv) croak("Not a subroutine reference");
3101 1 8 if (narrays < 1) return;
3103 17 5 for (i = 1; i <= narrays; i++) {
3104 0 17 SvGETMAGIC(ST(i));
0 0 SvGETMAGIC(ST(i));
3105 16 1 if ((!SvROK(ST(i))) || (SvTYPE(SvRV(ST(i))) != SVt_PVAV))
0 16 if ((!SvROK(ST(i))) || (SvTYPE(SvRV(ST(i))) != SVt_PVAV))
3107 2 14 if (av_len((AV *)SvRV(ST(i))) < 0)
3111 0 5 Newz(0, arcnt, narrays, IV);
3112 0 5 New(0, arlen, narrays, IV);
3113 0 5 New(0, arptr, narrays, AV*);
3114 0 5 New(0, arout, narrays, SV*);
3115 12 5 for (i = 0; i < narrays; i++) {
3123 5 0 if (!CvISXSUB(cv)) {
3128 0 5 PUSH_MULTICALL(cv);
0 5 PUSH_MULTICALL(cv);
3132 44 22 for (i = narrays-1; i >= 0; i--) /* Faster to fill backwards */
3135 0 22 CHECK_FORCOUNT;
3136 32 5 for (i = narrays-1; i >= 0; i--) {
3137 15 17 if (++arcnt[i] >= arlen[i]) arcnt[i] = 0;
3139 17 15 if (arcnt[i] > 0) break;
3141 17 5 } while (i >= 0);
3143 5 0 POP_MULTICALL;
0 5 POP_MULTICALL;
3148 0 0 PUSHMARK(SP); EXTEND(SP, narrays);
0 0 PUSHMARK(SP); EXTEND(SP, narrays);
0 0 PUSHMARK(SP); EXTEND(SP, narrays);
3149 0 0 for (i = 0; i < narrays; i++) { PUSHs(arout[i]); }
3151 0 0 CHECK_FORCOUNT;
3152 0 0 for (i = narrays-1; i >= 0; i--) {
3153 0 0 if (++arcnt[i] >= arlen[i]) arcnt[i] = 0;
3155 0 0 if (arcnt[i] > 0) break;
3157 0 0 } while (i >= 0);
3162 0 5 END_FORCOUNT;
3182 0 5 if (cv == Nullcv)
3185 5 0 if (!_validate_int(aTHX_ svbeg, 0) || (items >= 3 && !_validate_int(aTHX_ svend,0))) {
1 4 if (!_validate_int(aTHX_ svbeg, 0) || (items >= 3 && !_validate_int(aTHX_ svend,0))) {
0 1 if (!_validate_int(aTHX_ svbeg, 0) || (items >= 3 && !_validate_int(aTHX_ svend,0))) {
3186 0 0 _vcallsubn(aTHX_ G_VOID|G_DISCARD, VCALL_ROOT, (ix == 0) ? "_generic_forfactored" : "_generic_forsquarefree", items, 0);
3190 4 1 if (items < 3) {
3192 0 4 end = my_svuv(svbeg);
3194 0 1 beg = my_svuv(svbeg);
3195 0 1 end = my_svuv(svend);
3197 0 5 if (beg > end) return;
3199 47 5 for (maxfactors = 0, n = end >> 1; n; n >>= 1)
3201 47 5 for (i = 0; i < maxfactors; i++) {
3210 4 1 if (beg <= 1) {
3211 0 4 PUSHMARK(SP);
3218 5 0 if (!CvISXSUB(cv)) {
3223 0 5 PUSH_MULTICALL(cv);
0 5 PUSH_MULTICALL(cv);
3224 1207 5 for (n = 0; n < end-beg+1; n++) {
3225 0 1207 CHECK_FORCOUNT;
3227 777 430 if (nfactors > 0) {
3232 1605 777 for (i = nfactors-1; i >= 0; i--) {
3243 5 0 POP_MULTICALL;
0 5 POP_MULTICALL;
3247 0 0 for (n = 0; n < end-beg+1; n++) {
3248 0 0 CHECK_FORCOUNT;
3250 0 0 if (nfactors > 0) {
3251 0 0 PUSHMARK(SP); EXTEND(SP, nfactors);
0 0 PUSHMARK(SP); EXTEND(SP, nfactors);
0 0 PUSHMARK(SP); EXTEND(SP, nfactors);
3254 0 0 for (i = 0; i < nfactors; i++) {
3265 47 5 for (i = 0; i < maxfactors; i++)
3267 0 5 END_FORCOUNT;
3281 0 4 if (cv == Nullcv) croak("Not a subroutine reference");
3282 1 3 if (items <= 1) XSRETURN_UNDEF;
3289 3 0 SvSetMagicSV(ret, args[1]);
0 3 SvSetMagicSV(ret, args[1]);
3291 3 0 if (!CvISXSUB(cv)) {
3294 0 3 PUSH_MULTICALL(cv);
0 3 PUSH_MULTICALL(cv);
3295 4 3 for (i = 2; i < items; i++) {
3298 4 0 SvSetMagicSV(ret, *PL_stack_sp);
0 4 SvSetMagicSV(ret, *PL_stack_sp);
3301 3 0 POP_MULTICALL;
0 3 POP_MULTICALL;
3306 0 0 for (i = 2; i < items; i++) {
3309 0 0 PUSHMARK(SP);
3311 0 0 SvSetMagicSV(ret, *PL_stack_sp);
0 0 SvSetMagicSV(ret, *PL_stack_sp);
3337 0 27 if (cv == Nullcv) croak("Not a subroutine reference");
3341 27 0 if (!CvISXSUB(cv)) {
3345 0 27 PUSH_MULTICALL(cv);
0 27 PUSH_MULTICALL(cv);
3346 5040 17 for (index = 1; index < items; index++) {
3349 5040 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 5040 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 5040 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
5032 8 if (SvTRUEx(*PL_stack_sp) ^ invert)
5032 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
5032 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
5016 16 if (SvTRUEx(*PL_stack_sp) ^ invert)
5016 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
5016 16 if (SvTRUEx(*PL_stack_sp) ^ invert)
8 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
8 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
8 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 8 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 8 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
10 5030 if (SvTRUEx(*PL_stack_sp) ^ invert)
3353 27 0 POP_MULTICALL;
0 27 POP_MULTICALL;
3358 0 0 for (index = 1; index < items; index++) {
3361 0 0 PUSHMARK(SP);
3363 0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
0 0 if (SvTRUEx(*PL_stack_sp) ^ invert)
3368 5 22 if (ix == 4) {
3369 2 3 if (index == items)
3374 5 17 if (ix == 6) {
3375 2 3 if (index == items)
3380 4 13 if (index != items) /* We exited the loop early */
3383 11 6 if (ret_true) XSRETURN_YES;