3v4l.org

run code in 300+ PHP versions simultaneously
<?php function &permuteUnique($items) { sort($items); $size = count($items); $return = array(); while (true) { $return[] = $items; $invAt = $size - 2; for (;;$invAt--) { if ($invAt < 0) { break 2; } if ($items[$invAt] < $items[$invAt + 1]) { break; } } $swap1Num = $items[$invAt]; $inv2At = $size - 1; while ($swap1Num >= $items[$inv2At]) { $inv2At--; } $items[$invAt] = $items[$inv2At]; $items[$inv2At] = $swap1Num; $reverse1 = $invAt + 1; $reverse2 = $size - 1; while ($reverse1 < $reverse2) { $temp = $items[$reverse1]; $items[$reverse1] = $items[$reverse2]; $items[$reverse2] = $temp; $reverse1++; $reverse2--; } } return $return; } var_dump(permuteUnique(array(1,2,3,4,5))) ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fZ8a4
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'permuteunique'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   39     6      > RETURN                                                   1

Function permuteunique:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 55, Position 2 = 8
Branch analysis from position: 55
Return found
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 13
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 29
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 43
Branch analysis from position: 54
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 43
Branch analysis from position: 54
Branch analysis from position: 43
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 29
Branch analysis from position: 33
Branch analysis from position: 29
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 13
Branch analysis from position: 24
Branch analysis from position: 13
filename:       /in/fZ8a4
function name:  permuteUnique
number of ops:  57
compiled vars:  !0 = $items, !1 = $size, !2 = $return, !3 = $invAt, !4 = $swap1Num, !5 = $inv2At, !6 = $reverse1, !7 = $reverse2, !8 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'sort'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
    4     4        COUNT                                            ~10     !0
          5        ASSIGN                                                   !1, ~10
    5     6        ASSIGN                                                   !2, <array>
    6     7      > JMP                                                      ->54
    7     8    >   ASSIGN_DIM                                               !2
          9        OP_DATA                                                  !0
    8    10        SUB                                              ~14     !1, 2
         11        ASSIGN                                                   !3, ~14
    9    12      > JMP                                                      ->23
   10    13    >   IS_SMALLER                                               !3, 0
         14      > JMPZ                                                     ~16, ->16
   11    15    > > JMP                                                      ->55
   13    16    >   FETCH_DIM_R                                      ~17     !0, !3
         17        ADD                                              ~18     !3, 1
         18        FETCH_DIM_R                                      ~19     !0, ~18
         19        IS_SMALLER                                               ~17, ~19
         20      > JMPZ                                                     ~20, ->22
   14    21    > > JMP                                                      ->24
    9    22    >   PRE_DEC                                                  !3
         23    > > JMPNZ                                                    <true>, ->13
   17    24    >   FETCH_DIM_R                                      ~22     !0, !3
         25        ASSIGN                                                   !4, ~22
   18    26        SUB                                              ~24     !1, 1
         27        ASSIGN                                                   !5, ~24
   19    28      > JMP                                                      ->30
   20    29    >   PRE_DEC                                                  !5
   19    30    >   FETCH_DIM_R                                      ~27     !0, !5
         31        IS_SMALLER_OR_EQUAL                                      ~27, !4
         32      > JMPNZ                                                    ~28, ->29
   22    33    >   FETCH_DIM_R                                      ~30     !0, !5
         34        ASSIGN_DIM                                               !0, !3
         35        OP_DATA                                                  ~30
   23    36        ASSIGN_DIM                                               !0, !5
         37        OP_DATA                                                  !4
   24    38        ADD                                              ~32     !3, 1
         39        ASSIGN                                                   !6, ~32
   25    40        SUB                                              ~34     !1, 1
         41        ASSIGN                                                   !7, ~34
   26    42      > JMP                                                      ->52
   27    43    >   FETCH_DIM_R                                      ~36     !0, !6
         44        ASSIGN                                                   !8, ~36
   28    45        FETCH_DIM_R                                      ~39     !0, !7
         46        ASSIGN_DIM                                               !0, !6
         47        OP_DATA                                                  ~39
   29    48        ASSIGN_DIM                                               !0, !7
         49        OP_DATA                                                  !8
   30    50        PRE_INC                                                  !6
   31    51        PRE_DEC                                                  !7
   26    52    >   IS_SMALLER                                               !6, !7
         53      > JMPNZ                                                    ~43, ->43
    6    54    > > JMPNZ                                                    <true>, ->8
   34    55    > > RETURN_BY_REF                                            !2
   35    56*     > RETURN_BY_REF                                            null

End of function permuteunique

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.9 ms | 1403 KiB | 18 Q