3v4l.org

run code in 300+ PHP versions simultaneously
<?php function repeatInt(int $value, int $min, int $max) { $num = $max - $min + 1; $culc_value = $value < 2 ? ($num - 1) * ($min - $value) : $value + $min; return $culc_value % $num + $min; } echo 'Test 2 to 5' . PHP_EOL; echo '---------------------------------' . PHP_EOL; foreach (range(-10, 10) as $i) { echo $i . ' → ' . repeatInt($i, 2, 5) . PHP_EOL; } echo PHP_EOL; echo 'Test 3 to 8' . PHP_EOL; echo '---------------------------------' . PHP_EOL; foreach (range(-10, 10) as $i) { echo $i . ' → ' . repeatInt($i, 3, 8) . PHP_EOL; } echo PHP_EOL; echo 'Test -4 to -2' . PHP_EOL; echo '---------------------------------' . PHP_EOL; foreach (range(-10, 10) as $i) { echo $i . ' → ' . repeatInt($i, -4, -2) . PHP_EOL; } echo PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 38
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 38
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 38
2 jumps found. (Code = 77) Position 1 = 47, Position 2 = 58
Branch analysis from position: 47
2 jumps found. (Code = 78) Position 1 = 48, Position 2 = 58
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
Branch analysis from position: 38
Branch analysis from position: 18
filename:       /in/820tF
function name:  (null)
number of ops:  61
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ECHO                                                     'Test+2+to+5%0A'
   10     1        ECHO                                                     '---------------------------------%0A'
   11     2        INIT_FCALL                                               'range'
          3        SEND_VAL                                                 -10
          4        SEND_VAL                                                 10
          5        DO_ICALL                                         $1      
          6      > FE_RESET_R                                       $2      $1, ->18
          7    > > FE_FETCH_R                                               $2, !0, ->18
   13     8    >   CONCAT                                           ~3      !0, '+%E2%86%92+'
          9        INIT_FCALL                                               'repeatint'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 2
         12        SEND_VAL                                                 5
         13        DO_FCALL                                      0  $4      
         14        CONCAT                                           ~5      ~3, $4
         15        CONCAT                                           ~6      ~5, '%0A'
         16        ECHO                                                     ~6
   11    17      > JMP                                                      ->7
         18    >   FE_FREE                                                  $2
   15    19        ECHO                                                     '%0A'
   17    20        ECHO                                                     'Test+3+to+8%0A'
   18    21        ECHO                                                     '---------------------------------%0A'
   19    22        INIT_FCALL                                               'range'
         23        SEND_VAL                                                 -10
         24        SEND_VAL                                                 10
         25        DO_ICALL                                         $7      
         26      > FE_RESET_R                                       $8      $7, ->38
         27    > > FE_FETCH_R                                               $8, !0, ->38
   21    28    >   CONCAT                                           ~9      !0, '+%E2%86%92+'
         29        INIT_FCALL                                               'repeatint'
         30        SEND_VAR                                                 !0
         31        SEND_VAL                                                 3
         32        SEND_VAL                                                 8
         33        DO_FCALL                                      0  $10     
         34        CONCAT                                           ~11     ~9, $10
         35        CONCAT                                           ~12     ~11, '%0A'
         36        ECHO                                                     ~12
   19    37      > JMP                                                      ->27
         38    >   FE_FREE                                                  $8
   23    39        ECHO                                                     '%0A'
   25    40        ECHO                                                     'Test+-4+to+-2%0A'
   26    41        ECHO                                                     '---------------------------------%0A'
   27    42        INIT_FCALL                                               'range'
         43        SEND_VAL                                                 -10
         44        SEND_VAL                                                 10
         45        DO_ICALL                                         $13     
         46      > FE_RESET_R                                       $14     $13, ->58
         47    > > FE_FETCH_R                                               $14, !0, ->58
   29    48    >   CONCAT                                           ~15     !0, '+%E2%86%92+'
         49        INIT_FCALL                                               'repeatint'
         50        SEND_VAR                                                 !0
         51        SEND_VAL                                                 -4
         52        SEND_VAL                                                 -2
         53        DO_FCALL                                      0  $16     
         54        CONCAT                                           ~17     ~15, $16
         55        CONCAT                                           ~18     ~17, '%0A'
         56        ECHO                                                     ~18
   27    57      > JMP                                                      ->47
         58    >   FE_FREE                                                  $14
   31    59        ECHO                                                     '%0A'
   32    60      > RETURN                                                   1

Function repeatint:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/820tF
function name:  repeatInt
number of ops:  20
compiled vars:  !0 = $value, !1 = $min, !2 = $max, !3 = $num, !4 = $culc_value
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
    5     6        IS_SMALLER                                               !0, 2
          7      > JMPZ                                                     ~8, ->13
          8    >   SUB                                              ~9      !3, 1
          9        SUB                                              ~10     !1, !0
         10        MUL                                              ~11     ~9, ~10
         11        QM_ASSIGN                                        ~12     ~11
         12      > JMP                                                      ->15
         13    >   ADD                                              ~13     !0, !1
         14        QM_ASSIGN                                        ~12     ~13
         15    >   ASSIGN                                                   !4, ~12
    6    16        MOD                                              ~15     !4, !3
         17        ADD                                              ~16     ~15, !1
         18      > RETURN                                                   ~16
    7    19*     > RETURN                                                   null

End of function repeatint

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.65 ms | 1398 KiB | 18 Q