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

End of function merge_sort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.37 ms | 1403 KiB | 18 Q