3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pfactor($n){ // max_n = 2^31-1 = 2147483647 $d=42; $factors = array(); $dmax = floor(sqrt($n)); $sieve = array(); $sieve = array_fill(1, $dmax,1); do{ $r = false; while ($n%$d==0){ $factors[$d]++; $n/=$d; $r = true; } if ($r){ $dmax = floor(sqrt($n)); } if ($n>1){ for ($i=$d;$i<=$dmax;$i+=$d){ $sieve[$i]=0; } do{ $d++; }while ($sieve[$d]!=1 && $d<$dmax); if ($d>$dmax){ $factors[$n]++; } } }while($n>1 && $d<=$dmax); return $factors; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mVdtX
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E > > RETURN                                                   1

Function pfactor:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 19
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 34
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 54
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 38
Branch analysis from position: 43
2 jumps found. (Code = 46) Position 1 = 47, Position 2 = 49
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 43
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 54
Branch analysis from position: 52
2 jumps found. (Code = 46) Position 1 = 56, Position 2 = 58
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 17
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 58
Branch analysis from position: 54
Branch analysis from position: 43
Branch analysis from position: 49
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 38
Branch analysis from position: 43
Branch analysis from position: 38
Branch analysis from position: 54
Branch analysis from position: 34
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 19
Branch analysis from position: 26
Branch analysis from position: 19
filename:       /in/mVdtX
function name:  pfactor
number of ops:  61
compiled vars:  !0 = $n, !1 = $d, !2 = $factors, !3 = $dmax, !4 = $sieve, !5 = $r, !6 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, 42
    5     2        ASSIGN                                                   !2, <array>
    6     3        INIT_FCALL                                               'floor'
          4        INIT_FCALL                                               'sqrt'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $9      
          7        SEND_VAR                                                 $9
          8        DO_ICALL                                         $10     
          9        ASSIGN                                                   !3, $10
    7    10        ASSIGN                                                   !4, <array>
    8    11        INIT_FCALL                                               'array_fill'
         12        SEND_VAL                                                 1
         13        SEND_VAR                                                 !3
         14        SEND_VAL                                                 1
         15        DO_ICALL                                         $13     
         16        ASSIGN                                                   !4, $13
   10    17    >   ASSIGN                                                   !5, <false>
   11    18      > JMP                                                      ->23
   12    19    >   FETCH_DIM_RW                                     $16     !2, !1
         20        PRE_INC                                                  $16
   13    21        ASSIGN_OP                                     4          !0, !1
   14    22        ASSIGN                                                   !5, <true>
   11    23    >   MOD                                              ~20     !0, !1
         24        IS_EQUAL                                                 ~20, 0
         25      > JMPNZ                                                    ~21, ->19
   16    26    > > JMPZ                                                     !5, ->34
   17    27    >   INIT_FCALL                                               'floor'
         28        INIT_FCALL                                               'sqrt'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                         $22     
         31        SEND_VAR                                                 $22
         32        DO_ICALL                                         $23     
         33        ASSIGN                                                   !3, $23
   19    34    >   IS_SMALLER                                               1, !0
         35      > JMPZ                                                     ~25, ->54
   20    36    >   ASSIGN                                                   !6, !1
         37      > JMP                                                      ->41
   21    38    >   ASSIGN_DIM                                               !4, !6
         39        OP_DATA                                                  0
   20    40        ASSIGN_OP                                     1          !6, !1
         41    >   IS_SMALLER_OR_EQUAL                                      !6, !3
         42      > JMPNZ                                                    ~29, ->38
   24    43    >   PRE_INC                                                  !1
   25    44        FETCH_DIM_R                                      ~31     !4, !1
         45        IS_NOT_EQUAL                                     ~32     ~31, 1
         46      > JMPZ_EX                                          ~32     ~32, ->49
         47    >   IS_SMALLER                                       ~33     !1, !3
         48        BOOL                                             ~32     ~33
         49    > > JMPNZ                                                    ~32, ->43
   26    50    >   IS_SMALLER                                               !3, !1
         51      > JMPZ                                                     ~34, ->54
   27    52    >   FETCH_DIM_RW                                     $35     !2, !0
         53        PRE_INC                                                  $35
   30    54    >   IS_SMALLER                                       ~37     1, !0
         55      > JMPZ_EX                                          ~37     ~37, ->58
         56    >   IS_SMALLER_OR_EQUAL                              ~38     !1, !3
         57        BOOL                                             ~37     ~38
         58    > > JMPNZ                                                    ~37, ->17
   31    59    > > RETURN                                                   !2
   32    60*     > RETURN                                                   null

End of function pfactor

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.27 ms | 1400 KiB | 19 Q