3v4l.org

run code in 300+ PHP versions simultaneously
<?php function prim($n) { if ( $n == 1 ) return false; if ( $n == 2) return true; if ( $n % 2 == 0 ) return true; for ( $i = 3; $i <= ceil(sqrt($n)); $i+=2) { if ( $n % $i == 0 ) return true; } return false; } var_dump(prim(1)); var_dump(prim(2)); var_dump(prim(3)); var_dump(prim(4)); var_dump(prim(5)); var_dump(prim(6)); var_dump(prim(7)); var_dump(prim(8)); var_dump(prim(9)); var_dump(prim(11));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vq1ml
function name:  (null)
number of ops:  61
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'prim'
          2        SEND_VAL                                                 1
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   17     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'prim'
          8        SEND_VAL                                                 2
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   18    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'prim'
         14        SEND_VAL                                                 3
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
   19    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'prim'
         20        SEND_VAL                                                 4
         21        DO_FCALL                                      0  $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                                 
   20    24        INIT_FCALL                                               'var_dump'
         25        INIT_FCALL                                               'prim'
         26        SEND_VAL                                                 5
         27        DO_FCALL                                      0  $8      
         28        SEND_VAR                                                 $8
         29        DO_ICALL                                                 
   21    30        INIT_FCALL                                               'var_dump'
         31        INIT_FCALL                                               'prim'
         32        SEND_VAL                                                 6
         33        DO_FCALL                                      0  $10     
         34        SEND_VAR                                                 $10
         35        DO_ICALL                                                 
   22    36        INIT_FCALL                                               'var_dump'
         37        INIT_FCALL                                               'prim'
         38        SEND_VAL                                                 7
         39        DO_FCALL                                      0  $12     
         40        SEND_VAR                                                 $12
         41        DO_ICALL                                                 
   23    42        INIT_FCALL                                               'var_dump'
         43        INIT_FCALL                                               'prim'
         44        SEND_VAL                                                 8
         45        DO_FCALL                                      0  $14     
         46        SEND_VAR                                                 $14
         47        DO_ICALL                                                 
   24    48        INIT_FCALL                                               'var_dump'
         49        INIT_FCALL                                               'prim'
         50        SEND_VAL                                                 9
         51        DO_FCALL                                      0  $16     
         52        SEND_VAR                                                 $16
         53        DO_ICALL                                                 
   25    54        INIT_FCALL                                               'var_dump'
         55        INIT_FCALL                                               'prim'
         56        SEND_VAL                                                 11
         57        DO_FCALL                                      0  $18     
         58        SEND_VAR                                                 $18
         59        DO_ICALL                                                 
         60      > RETURN                                                   1

Function prim:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 13
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 13
Branch analysis from position: 26
Branch analysis from position: 13
filename:       /in/vq1ml
function name:  prim
number of ops:  28
compiled vars:  !0 = $n, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        IS_EQUAL                                                 !0, 1
          2      > JMPZ                                                     ~2, ->4
    4     3    > > RETURN                                                   <false>
    5     4    >   IS_EQUAL                                                 !0, 2
          5      > JMPZ                                                     ~3, ->7
    6     6    > > RETURN                                                   <true>
    7     7    >   MOD                                              ~4      !0, 2
          8        IS_EQUAL                                                 ~4, 0
          9      > JMPZ                                                     ~5, ->11
    8    10    > > RETURN                                                   <true>
   10    11    >   ASSIGN                                                   !1, 3
         12      > JMP                                                      ->18
   11    13    >   MOD                                              ~7      !0, !1
         14        IS_EQUAL                                                 ~7, 0
         15      > JMPZ                                                     ~8, ->17
   12    16    > > RETURN                                                   <true>
   10    17    >   ASSIGN_OP                                     1          !1, 2
         18    >   INIT_FCALL                                               'ceil'
         19        INIT_FCALL                                               'sqrt'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $10     
         22        SEND_VAR                                                 $10
         23        DO_ICALL                                         $11     
         24        IS_SMALLER_OR_EQUAL                                      !1, $11
         25      > JMPNZ                                                    ~12, ->13
   14    26    > > RETURN                                                   <false>
   15    27*     > RETURN                                                   null

End of function prim

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.59 ms | 1407 KiB | 29 Q