3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array(8,4,1,9,5,7,3,2,6,0); function merge_sort($list){ var_dump($list); if(count($list) <= 1) { return $list; } $middle = count($list)/2; $left = merge_sort(array_slice($list, 0, $middle)); $right = merge_sort(array_slice($list, $middle+1, count($list))); $data = array(); for($x = 0;$x < count($list); $x++){ if($x < count($left)){ $data[$x] = $left[$x]; } if($x >= count($left) && $x < count($right)){ $data[$x] = $right[$x]; } } return $data; } var_dump(merge_sort($data));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3K52p
function name:  (null)
number of ops:  8
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   28     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'merge_sort'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function merge_sort:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 34
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 40
Branch analysis from position: 37
2 jumps found. (Code = 46) Position 1 = 43, Position 2 = 46
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 50
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 34
Branch analysis from position: 54
Branch analysis from position: 34
Branch analysis from position: 50
Branch analysis from position: 46
Branch analysis from position: 40
filename:       /in/3K52p
function name:  merge_sort
number of ops:  56
compiled vars:  !0 = $list, !1 = $middle, !2 = $left, !3 = $right, !4 = $data, !5 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
    7     4        COUNT                                            ~7      !0
          5        IS_SMALLER_OR_EQUAL                                      ~7, 1
          6      > JMPZ                                                     ~8, ->8
    9     7    > > RETURN                                                   !0
   12     8    >   COUNT                                            ~9      !0
          9        DIV                                              ~10     ~9, 2
         10        ASSIGN                                                   !1, ~10
   13    11        INIT_FCALL_BY_NAME                                       'merge_sort'
         12        INIT_FCALL                                               'array_slice'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 0
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $12     
         17        SEND_VAR_NO_REF_EX                                       $12
         18        DO_FCALL                                      0  $13     
         19        ASSIGN                                                   !2, $13
   14    20        INIT_FCALL_BY_NAME                                       'merge_sort'
         21        INIT_FCALL                                               'array_slice'
         22        SEND_VAR                                                 !0
         23        ADD                                              ~15     !1, 1
         24        SEND_VAL                                                 ~15
         25        COUNT                                            ~16     !0
         26        SEND_VAL                                                 ~16
         27        DO_ICALL                                         $17     
         28        SEND_VAR_NO_REF_EX                                       $17
         29        DO_FCALL                                      0  $18     
         30        ASSIGN                                                   !3, $18
   15    31        ASSIGN                                                   !4, <array>
   17    32        ASSIGN                                                   !5, 0
         33      > JMP                                                      ->51
   18    34    >   COUNT                                            ~22     !2
         35        IS_SMALLER                                               !5, ~22
         36      > JMPZ                                                     ~23, ->40
   19    37    >   FETCH_DIM_R                                      ~25     !2, !5
         38        ASSIGN_DIM                                               !4, !5
         39        OP_DATA                                                  ~25
   21    40    >   COUNT                                            ~26     !2
         41        IS_SMALLER_OR_EQUAL                              ~27     ~26, !5
         42      > JMPZ_EX                                          ~27     ~27, ->46
         43    >   COUNT                                            ~28     !3
         44        IS_SMALLER                                       ~29     !5, ~28
         45        BOOL                                             ~27     ~29
         46    > > JMPZ                                                     ~27, ->50
   22    47    >   FETCH_DIM_R                                      ~31     !3, !5
         48        ASSIGN_DIM                                               !4, !5
         49        OP_DATA                                                  ~31
   17    50    >   PRE_INC                                                  !5
         51    >   COUNT                                            ~33     !0
         52        IS_SMALLER                                               !5, ~33
         53      > JMPNZ                                                    ~34, ->34
   25    54    > > RETURN                                                   !4
   26    55*     > RETURN                                                   null

End of function merge_sort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.72 ms | 1403 KiB | 18 Q