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))); print_r(array_merge($left, $right)); } merge_sort($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uBjZa
function name:  (null)
number of ops:  5
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'merge_sort'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
          4      > 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 = 62) Position 1 = -2
filename:       /in/uBjZa
function name:  merge_sort
number of ops:  35
compiled vars:  !0 = $list, !1 = $middle, !2 = $left, !3 = $right
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        COUNT                                            ~4      !0
          2        IS_SMALLER_OR_EQUAL                                      ~4, 1
          3      > JMPZ                                                     ~5, ->5
    7     4    > > RETURN                                                   !0
   10     5    >   COUNT                                            ~6      !0
          6        DIV                                              ~7      ~6, 2
          7        ASSIGN                                                   !1, ~7
   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                                         $9      
         14        SEND_VAR_NO_REF_EX                                       $9
         15        DO_FCALL                                      0  $10     
         16        ASSIGN                                                   !2, $10
   12    17        INIT_FCALL_BY_NAME                                       'merge_sort'
         18        INIT_FCALL                                               'array_slice'
         19        SEND_VAR                                                 !0
         20        SEND_VAR                                                 !1
         21        COUNT                                            ~12     !0
         22        SEND_VAL                                                 ~12
         23        DO_ICALL                                         $13     
         24        SEND_VAR_NO_REF_EX                                       $13
         25        DO_FCALL                                      0  $14     
         26        ASSIGN                                                   !3, $14
   14    27        INIT_FCALL                                               'print_r'
         28        INIT_FCALL                                               'array_merge'
         29        SEND_VAR                                                 !2
         30        SEND_VAR                                                 !3
         31        DO_ICALL                                         $16     
         32        SEND_VAR                                                 $16
         33        DO_ICALL                                                 
   16    34      > RETURN                                                   null

End of function merge_sort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.96 ms | 1394 KiB | 20 Q