3v4l.org

run code in 300+ PHP versions simultaneously
<?php function xrange($start, $limit, $step = 1) { if ($start < $limit) { if ($step <= 0) { throw new LogicException('Step must be +ve'); } for ($i = $start; $i <= $limit; $i += $step) { yield $i; } } else { if ($step >= 0) { throw new LogicException('Step must be -ve'); } for ($i = $start; $i >= $limit; $i += $step) { yield $i; } } } $sum = 0.0; foreach(xrange(1, 1e+6) as $i){ $sum += $i; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/8I9r0
function name:  (null)
number of ops:  11
compiled vars:  !0 = $sum, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, 0
   24     1        INIT_FCALL                                               'xrange'
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 1.0e+6
          4        DO_FCALL                                      0  $3      
          5      > FE_RESET_R                                       $4      $3, ->9
          6    > > FE_FETCH_R                                               $4, !1, ->9
   25     7    >   ASSIGN_OP                                     1          !0, !1
   24     8      > JMP                                                      ->6
          9    >   FE_FREE                                                  $4
   26    10      > RETURN                                                   1

Function xrange:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 19
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 14
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 14
Branch analysis from position: 18
Branch analysis from position: 14
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 27
Branch analysis from position: 31
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 27
Branch analysis from position: 31
Branch analysis from position: 27
filename:       /in/8I9r0
function name:  xrange
number of ops:  32
compiled vars:  !0 = $start, !1 = $limit, !2 = $step, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      1
          3        GENERATOR_CREATE                                         
    4     4        IS_SMALLER                                               !0, !1
          5      > JMPZ                                                     ~4, ->19
    5     6    >   IS_SMALLER_OR_EQUAL                                      !2, 0
          7      > JMPZ                                                     ~5, ->12
    6     8    >   NEW                                              $6      'LogicException'
          9        SEND_VAL_EX                                              'Step+must+be+%2Bve'
         10        DO_FCALL                                      0          
         11      > THROW                                         0          $6
    9    12    >   ASSIGN                                                   !3, !0
         13      > JMP                                                      ->16
   10    14    >   YIELD                                                    !3
    9    15        ASSIGN_OP                                     1          !3, !2
         16    >   IS_SMALLER_OR_EQUAL                                      !3, !1
         17      > JMPNZ                                                    ~11, ->14
    4    18    > > JMP                                                      ->31
   13    19    >   IS_SMALLER_OR_EQUAL                                      0, !2
         20      > JMPZ                                                     ~12, ->25
   14    21    >   NEW                                              $13     'LogicException'
         22        SEND_VAL_EX                                              'Step+must+be+-ve'
         23        DO_FCALL                                      0          
         24      > THROW                                         0          $13
   17    25    >   ASSIGN                                                   !3, !0
         26      > JMP                                                      ->29
   18    27    >   YIELD                                                    !3
   17    28        ASSIGN_OP                                     1          !3, !2
         29    >   IS_SMALLER_OR_EQUAL                                      !1, !3
         30      > JMPNZ                                                    ~18, ->27
   21    31    > > GENERATOR_RETURN                                         

End of function xrange

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
271.46 ms | 1016 KiB | 14 Q