3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [1,2,3,4,13]; $nxt = $a[0]; $cnt = count($a); $j = 0; $ret = []; for ($i = 1; $i < $cnt; ++$i) { $pre = $nxt; $diff = $nxt; // ---- WAIT LIKE AGES FOR $a[$i] $nxt = $a[$i]; //$k = $a[$i + 1]; //$diff = $nxt - $pre; // MOV diff,nxt SUB diff,pre LATENCY: 2 //$diff = $pre - $nxt; $diff -= $nxt; $ret[$j++] = $pre; // branch if ($diff == -1) { // raising range do { ++$nxt; ++$i; } while ($a[$i] == $nxt); $ret[$j] = "$pre-" . ($nxt - 1); $nxt = $a[$i]; } elseif ($diff == 1) { // found falling range ++$i; while ($a[$i] == --$nxt) { // search end of range ++$i; } $ret[$j] = "$pre-" . ($nxt + 1); $nxt = $a[$i]; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 9
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 33
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 19
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 9
Branch analysis from position: 53
Branch analysis from position: 9
Branch analysis from position: 19
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 50
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 37
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 9
Branch analysis from position: 53
Branch analysis from position: 9
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 37
Branch analysis from position: 42
Branch analysis from position: 37
Branch analysis from position: 50
filename:       /in/tDign
function name:  (null)
number of ops:  54
compiled vars:  !0 = $a, !1 = $nxt, !2 = $cnt, !3 = $j, !4 = $ret, !5 = $i, !6 = $pre, !7 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        FETCH_DIM_R                                      ~9      !0, 0
          2        ASSIGN                                                   !1, ~9
    5     3        COUNT                                            ~11     !0
          4        ASSIGN                                                   !2, ~11
    6     5        ASSIGN                                                   !3, 0
    7     6        ASSIGN                                                   !4, <array>
    9     7        ASSIGN                                                   !5, 1
          8      > JMP                                                      ->51
   11     9    >   ASSIGN                                                   !6, !1
   12    10        ASSIGN                                                   !7, !1
   14    11        FETCH_DIM_R                                      ~18     !0, !5
         12        ASSIGN                                                   !1, ~18
   20    13        ASSIGN_OP                                     2          !7, !1
   21    14        POST_INC                                         ~21     !3
         15        ASSIGN_DIM                                               !4, ~21
         16        OP_DATA                                                  !6
   24    17        IS_EQUAL                                                 !7, -1
         18      > JMPZ                                                     ~23, ->33
   26    19    >   PRE_INC                                                  !1
   27    20        PRE_INC                                                  !5
   28    21        FETCH_DIM_R                                      ~26     !0, !5
         22        IS_EQUAL                                                 !1, ~26
         23      > JMPNZ                                                    ~27, ->19
   29    24    >   NOP                                                      
         25        FAST_CONCAT                                      ~29     !6, '-'
         26        SUB                                              ~30     !1, 1
         27        CONCAT                                           ~31     ~29, ~30
         28        ASSIGN_DIM                                               !4, !3
         29        OP_DATA                                                  ~31
   30    30        FETCH_DIM_R                                      ~32     !0, !5
         31        ASSIGN                                                   !1, ~32
         32      > JMP                                                      ->50
   31    33    >   IS_EQUAL                                                 !7, 1
         34      > JMPZ                                                     ~34, ->50
   32    35    >   PRE_INC                                                  !5
   34    36      > JMP                                                      ->38
   35    37    >   PRE_INC                                                  !5
   34    38    >   FETCH_DIM_R                                      ~37     !0, !5
         39        PRE_DEC                                          ~38     !1
         40        IS_EQUAL                                                 ~37, ~38
         41      > JMPNZ                                                    ~39, ->37
   37    42    >   NOP                                                      
         43        FAST_CONCAT                                      ~41     !6, '-'
         44        ADD                                              ~42     !1, 1
         45        CONCAT                                           ~43     ~41, ~42
         46        ASSIGN_DIM                                               !4, !3
         47        OP_DATA                                                  ~43
   38    48        FETCH_DIM_R                                      ~44     !0, !5
         49        ASSIGN                                                   !1, ~44
    9    50    >   PRE_INC                                                  !5
         51    >   IS_SMALLER                                               !5, !2
         52      > JMPNZ                                                    ~47, ->9
   41    53    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.06 ms | 1399 KiB | 13 Q