3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [8, 3, 5, 2, 9]; for ($i = 1; $i < $n; $i++) { $key = $arr[$i]; $j = $i - 1; // Move elements greater than key one position ahead while ($j >= 0 && $arr[$j] > $key) { $arr[$j + 1] = $arr[$j]; $j--; } // Insert key at correct position $arr[$j + 1] = $key; } print_r($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 3
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 8
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 3
Branch analysis from position: 25
Branch analysis from position: 3
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
Branch analysis from position: 18
Branch analysis from position: 18
filename:       /in/8fQT3
function name:  (null)
number of ops:  29
compiled vars:  !0 = $arr, !1 = $i, !2 = $key, !3 = $j, !4 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, 1
          2      > JMP                                                      ->23
    6     3    >   FETCH_DIM_R                                      ~7      !0, !1
          4        ASSIGN                                                   !2, ~7
    7     5        SUB                                              ~9      !1, 1
          6        ASSIGN                                                   !3, ~9
   10     7      > JMP                                                      ->13
   11     8    >   ADD                                              ~11     !3, 1
          9        FETCH_DIM_R                                      ~13     !0, !3
         10        ASSIGN_DIM                                               !0, ~11
         11        OP_DATA                                                  ~13
   12    12        PRE_DEC                                                  !3
   10    13    >   IS_SMALLER_OR_EQUAL                              ~15     0, !3
         14      > JMPZ_EX                                          ~15     ~15, ->18
         15    >   FETCH_DIM_R                                      ~16     !0, !3
         16        IS_SMALLER                                       ~17     !2, ~16
         17        BOOL                                             ~15     ~17
         18    > > JMPNZ                                                    ~15, ->8
   16    19    >   ADD                                              ~18     !3, 1
         20        ASSIGN_DIM                                               !0, ~18
         21        OP_DATA                                                  !2
    5    22        PRE_INC                                                  !1
         23    >   IS_SMALLER                                               !1, !4
         24      > JMPNZ                                                    ~21, ->3
   19    25    >   INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.11 ms | 1014 KiB | 14 Q