3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sample(int $val, int $min, int $max) { $listLength = $max - $min + 1; $key = (($val % $listLength)) % $listLength; if ($key < 0) { $key = $listLength + ($key % $listLength); } return $min + $key; } // ?????? foreach (range(-10, 5) as $i) echo $i .'='. sample($i, 2, 5) . PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/Btcip
function name:  (null)
number of ops:  18
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 -10
          2        SEND_VAL                                                 5
          3        DO_ICALL                                         $1      
          4      > FE_RESET_R                                       $2      $1, ->16
          5    > > FE_FETCH_R                                               $2, !0, ->16
          6    >   CONCAT                                           ~3      !0, '%3D'
          7        INIT_FCALL                                               'sample'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 2
         10        SEND_VAL                                                 5
         11        DO_FCALL                                      0  $4      
         12        CONCAT                                           ~5      ~3, $4
         13        CONCAT                                           ~6      ~5, '%0A'
         14        ECHO                                                     ~6
         15      > JMP                                                      ->5
         16    >   FE_FREE                                                  $2
   17    17      > RETURN                                                   1

Function sample:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/Btcip
function name:  sample
number of ops:  17
compiled vars:  !0 = $val, !1 = $min, !2 = $max, !3 = $listLength, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        SUB                                              ~5      !2, !1
          4        ADD                                              ~6      ~5, 1
          5        ASSIGN                                                   !3, ~6
    6     6        MOD                                              ~8      !0, !3
          7        MOD                                              ~9      ~8, !3
          8        ASSIGN                                                   !4, ~9
    8     9        IS_SMALLER                                               !4, 0
         10      > JMPZ                                                     ~11, ->14
    9    11    >   MOD                                              ~12     !4, !3
         12        ADD                                              ~13     !3, ~12
         13        ASSIGN                                                   !4, ~13
   12    14    >   ADD                                              ~15     !1, !4
         15      > RETURN                                                   ~15
   13    16*     > RETURN                                                   null

End of function sample

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.12 ms | 1403 KiB | 16 Q