3v4l.org

run code in 300+ PHP versions simultaneously
<?php function countingSort(array $arr) { $n = sizeof($arr); $p = array(); $sorted = array(); for ($i = 0; $i < $n; $i++) { $p[$i] = 0; } for ($i = 0; $i < $n; $i++) { for ($j = $i + 1; $j < $n; $j++) { if ($arr[$i] > $arr[$j]) { $p[$i]++; } else { $p[$j]++; } } } for ($i = 0; $i < $n; $i++) { $sorted[$p[$i]] = $arr[$i]; } return $sorted; } // Example: $arr = array(255,1,22,3,45,5); $csresult = countingSort($arr); print_r($csresult);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rr66C
function name:  (null)
number of ops:  9
compiled vars:  !0 = $arr, !1 = $csresult
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   ASSIGN                                                   !0, <array>
   31     1        INIT_FCALL                                               'countingsort'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   32     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function countingsort:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 7
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 14
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 34
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 34
Branch analysis from position: 41
Branch analysis from position: 34
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 17
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 14
Branch analysis from position: 32
Branch analysis from position: 14
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 17
Branch analysis from position: 29
Branch analysis from position: 17
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 17
Branch analysis from position: 29
Branch analysis from position: 17
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 7
Branch analysis from position: 12
Branch analysis from position: 7
filename:       /in/rr66C
function name:  countingSort
number of ops:  43
compiled vars:  !0 = $arr, !1 = $n, !2 = $p, !3 = $sorted, !4 = $i, !5 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        COUNT                                            ~6      !0
          2        ASSIGN                                                   !1, ~6
    5     3        ASSIGN                                                   !2, <array>
    6     4        ASSIGN                                                   !3, <array>
    8     5        ASSIGN                                                   !4, 0
          6      > JMP                                                      ->10
    9     7    >   ASSIGN_DIM                                               !2, !4
          8        OP_DATA                                                  0
    8     9        PRE_INC                                                  !4
         10    >   IS_SMALLER                                               !4, !1
         11      > JMPNZ                                                    ~13, ->7
   12    12    >   ASSIGN                                                   !4, 0
         13      > JMP                                                      ->30
   13    14    >   ADD                                              ~15     !4, 1
         15        ASSIGN                                                   !5, ~15
         16      > JMP                                                      ->27
   14    17    >   FETCH_DIM_R                                      ~17     !0, !4
         18        FETCH_DIM_R                                      ~18     !0, !5
         19        IS_SMALLER                                               ~18, ~17
         20      > JMPZ                                                     ~19, ->24
   15    21    >   FETCH_DIM_RW                                     $20     !2, !4
         22        PRE_INC                                                  $20
         23      > JMP                                                      ->26
   17    24    >   FETCH_DIM_RW                                     $22     !2, !5
         25        PRE_INC                                                  $22
   13    26    >   PRE_INC                                                  !5
         27    >   IS_SMALLER                                               !5, !1
         28      > JMPNZ                                                    ~25, ->17
   12    29    >   PRE_INC                                                  !4
         30    >   IS_SMALLER                                               !4, !1
         31      > JMPNZ                                                    ~27, ->14
   22    32    >   ASSIGN                                                   !4, 0
         33      > JMP                                                      ->39
   23    34    >   FETCH_DIM_R                                      ~29     !2, !4
         35        FETCH_DIM_R                                      ~31     !0, !4
         36        ASSIGN_DIM                                               !3, ~29
         37        OP_DATA                                                  ~31
   22    38        PRE_INC                                                  !4
         39    >   IS_SMALLER                                               !4, !1
         40      > JMPNZ                                                    ~33, ->34
   26    41    > > RETURN                                                   !3
   27    42*     > RETURN                                                   null

End of function countingsort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.42 ms | 1403 KiB | 16 Q