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); --$nxt; $ret[$j] = "$pre-$nxt";// . ($nxt - 1); } 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 = 49
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 9
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 31
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 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 9
Branch analysis from position: 51
Branch analysis from position: 9
Branch analysis from position: 19
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 48
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 35
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 9
Branch analysis from position: 51
Branch analysis from position: 9
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 35
Branch analysis from position: 40
Branch analysis from position: 35
Branch analysis from position: 48
filename:       /in/LIAFc
function name:  (null)
number of ops:  52
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                                                      ->49
   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, ->31
   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    >   PRE_DEC                                                  !1
   30    25        ROPE_INIT                                     3  ~31     !6
         26        ROPE_ADD                                      1  ~31     ~31, '-'
         27        ROPE_END                                      2  ~30     ~31, !1
         28        ASSIGN_DIM                                               !4, !3
         29        OP_DATA                                                  ~30
         30      > JMP                                                      ->48
   31    31    >   IS_EQUAL                                                 !7, 1
         32      > JMPZ                                                     ~33, ->48
   32    33    >   PRE_INC                                                  !5
   34    34      > JMP                                                      ->36
   35    35    >   PRE_INC                                                  !5
   34    36    >   FETCH_DIM_R                                      ~36     !0, !5
         37        PRE_DEC                                          ~37     !1
         38        IS_EQUAL                                                 ~36, ~37
         39      > JMPNZ                                                    ~38, ->35
   37    40    >   NOP                                                      
         41        FAST_CONCAT                                      ~40     !6, '-'
         42        ADD                                              ~41     !1, 1
         43        CONCAT                                           ~42     ~40, ~41
         44        ASSIGN_DIM                                               !4, !3
         45        OP_DATA                                                  ~42
   38    46        FETCH_DIM_R                                      ~43     !0, !5
         47        ASSIGN                                                   !1, ~43
    9    48    >   PRE_INC                                                  !5
         49    >   IS_SMALLER                                               !5, !2
         50      > JMPNZ                                                    ~46, ->9
   41    51    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.62 ms | 1399 KiB | 13 Q