3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generatePrimesA($n) { $primes = [2]; for ($i = 3; $i < $n; $i += 2) { foreach ($primes as $prime) { if ($i % $prime == 0) { continue 2; } } $primes[] = $i; } return $primes; } function generatePrimesB($n) { $primes = [2]; for ($i = 3; $i < $n; $i += 2) { foreach ($primes as $prime) { if ($i % $prime == 0) { continue 2; } } $primes[] = $i; } return $primes; } var_dump(array_diff(generatePrimesA(1000), generatePrimesB(1000)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ftv2p
function name:  (null)
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'array_diff'
          2        INIT_FCALL                                               'generateprimesa'
          3        SEND_VAL                                                 1000
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        INIT_FCALL                                               'generateprimesb'
          7        SEND_VAL                                                 1000
          8        DO_FCALL                                      0  $1      
          9        SEND_VAR                                                 $1
         10        DO_ICALL                                         $2      
         11        SEND_VAR                                                 $2
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function generateprimesa:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 4
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 4
Branch analysis from position: 18
Branch analysis from position: 4
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 4
Branch analysis from position: 18
Branch analysis from position: 4
Branch analysis from position: 12
filename:       /in/Ftv2p
function name:  generatePrimesA
number of ops:  20
compiled vars:  !0 = $n, !1 = $primes, !2 = $i, !3 = $prime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, 3
          3      > JMP                                                      ->16
    7     4    > > FE_RESET_R                                       $6      !1, ->12
          5    > > FE_FETCH_R                                               $6, !3, ->12
    8     6    >   MOD                                              ~7      !2, !3
          7        IS_EQUAL                                                 ~7, 0
          8      > JMPZ                                                     ~8, ->11
    9     9    >   FE_FREE                                                  $6
         10      > JMP                                                      ->15
    7    11    > > JMP                                                      ->5
         12    >   FE_FREE                                                  $6
   12    13        ASSIGN_DIM                                               !1
         14        OP_DATA                                                  !2
    6    15    >   ASSIGN_OP                                     1          !2, 2
         16    >   IS_SMALLER                                               !2, !0
         17      > JMPNZ                                                    ~11, ->4
   15    18    > > RETURN                                                   !1
   16    19*     > RETURN                                                   null

End of function generateprimesa

Function generateprimesb:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 4
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 4
Branch analysis from position: 18
Branch analysis from position: 4
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 4
Branch analysis from position: 18
Branch analysis from position: 4
Branch analysis from position: 12
filename:       /in/Ftv2p
function name:  generatePrimesB
number of ops:  20
compiled vars:  !0 = $n, !1 = $primes, !2 = $i, !3 = $prime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        ASSIGN                                                   !1, <array>
   21     2        ASSIGN                                                   !2, 3
          3      > JMP                                                      ->16
   22     4    > > FE_RESET_R                                       $6      !1, ->12
          5    > > FE_FETCH_R                                               $6, !3, ->12
   23     6    >   MOD                                              ~7      !2, !3
          7        IS_EQUAL                                                 ~7, 0
          8      > JMPZ                                                     ~8, ->11
   24     9    >   FE_FREE                                                  $6
         10      > JMP                                                      ->15
   22    11    > > JMP                                                      ->5
         12    >   FE_FREE                                                  $6
   27    13        ASSIGN_DIM                                               !1
         14        OP_DATA                                                  !2
   21    15    >   ASSIGN_OP                                     1          !2, 2
         16    >   IS_SMALLER                                               !2, !0
         17      > JMPNZ                                                    ~11, ->4
   30    18    > > RETURN                                                   !1
   31    19*     > RETURN                                                   null

End of function generateprimesb

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.32 ms | 1394 KiB | 19 Q