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/XGOS7
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 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 31
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 37
Branch analysis from position: 34
2 jumps found. (Code = 46) Position 1 = 40, Position 2 = 43
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 47
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 31
Branch analysis from position: 51
Branch analysis from position: 31
Branch analysis from position: 47
Branch analysis from position: 43
Branch analysis from position: 37
filename:       /in/XGOS7
function name:  merge_sort
number of ops:  53
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      
    7     1        COUNT                                            ~6      !0
          2        IS_SMALLER_OR_EQUAL                                      ~6, 1
          3      > JMPZ                                                     ~7, ->5
    9     4    > > RETURN                                                   !0
   12     5    >   COUNT                                            ~8      !0
          6        DIV                                              ~9      ~8, 2
          7        ASSIGN                                                   !1, ~9
   13     8        INIT_FCALL_BY_NAME                                       'merge_sort'
          9        INIT_FCALL                                               'array_slice'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 0
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $11     
         14        SEND_VAR_NO_REF_EX                                       $11
         15        DO_FCALL                                      0  $12     
         16        ASSIGN                                                   !2, $12
   14    17        INIT_FCALL_BY_NAME                                       'merge_sort'
         18        INIT_FCALL                                               'array_slice'
         19        SEND_VAR                                                 !0
         20        ADD                                              ~14     !1, 1
         21        SEND_VAL                                                 ~14
         22        COUNT                                            ~15     !0
         23        SEND_VAL                                                 ~15
         24        DO_ICALL                                         $16     
         25        SEND_VAR_NO_REF_EX                                       $16
         26        DO_FCALL                                      0  $17     
         27        ASSIGN                                                   !3, $17
   15    28        ASSIGN                                                   !4, <array>
   17    29        ASSIGN                                                   !5, 0
         30      > JMP                                                      ->48
   18    31    >   COUNT                                            ~21     !2
         32        IS_SMALLER                                               !5, ~21
         33      > JMPZ                                                     ~22, ->37
   19    34    >   FETCH_DIM_R                                      ~24     !2, !5
         35        ASSIGN_DIM                                               !4, !5
         36        OP_DATA                                                  ~24
   21    37    >   COUNT                                            ~25     !2
         38        IS_SMALLER_OR_EQUAL                              ~26     ~25, !5
         39      > JMPZ_EX                                          ~26     ~26, ->43
         40    >   COUNT                                            ~27     !3
         41        IS_SMALLER                                       ~28     !5, ~27
         42        BOOL                                             ~26     ~28
         43    > > JMPZ                                                     ~26, ->47
   22    44    >   FETCH_DIM_R                                      ~30     !3, !5
         45        ASSIGN_DIM                                               !4, !5
         46        OP_DATA                                                  ~30
   17    47    >   PRE_INC                                                  !5
         48    >   COUNT                                            ~32     !0
         49        IS_SMALLER                                               !5, ~32
         50      > JMPNZ                                                    ~33, ->31
   25    51    > > RETURN                                                   !4
   26    52*     > RETURN                                                   null

End of function merge_sort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.79 ms | 948 KiB | 19 Q