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

End of function merge_sort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.15 ms | 1403 KiB | 18 Q