3v4l.org

run code in 300+ PHP versions simultaneously
<?php $list = 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(); var_dump($left); var_dump($right); 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($list)); //var_dump(array_slice($data, 0, 4));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NZipQ
function name:  (null)
number of ops:  8
compiled vars:  !0 = $list
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   31     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                                                 
   33     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 = 54
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 37
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 43
Branch analysis from position: 40
2 jumps found. (Code = 46) Position 1 = 46, Position 2 = 49
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 53
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 37
Branch analysis from position: 57
Branch analysis from position: 37
Branch analysis from position: 53
Branch analysis from position: 49
Branch analysis from position: 43
filename:       /in/NZipQ
function name:  merge_sort
number of ops:  59
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        INIT_FCALL                                               'var_dump'
         30        SEND_VAR                                                 !2
         31        DO_ICALL                                                 
   18    32        INIT_FCALL                                               'var_dump'
         33        SEND_VAR                                                 !3
         34        DO_ICALL                                                 
   20    35        ASSIGN                                                   !5, 0
         36      > JMP                                                      ->54
   21    37    >   COUNT                                            ~23     !2
         38        IS_SMALLER                                               !5, ~23
         39      > JMPZ                                                     ~24, ->43
   22    40    >   FETCH_DIM_R                                      ~26     !2, !5
         41        ASSIGN_DIM                                               !4, !5
         42        OP_DATA                                                  ~26
   24    43    >   COUNT                                            ~27     !2
         44        IS_SMALLER_OR_EQUAL                              ~28     ~27, !5
         45      > JMPZ_EX                                          ~28     ~28, ->49
         46    >   COUNT                                            ~29     !3
         47        IS_SMALLER                                       ~30     !5, ~29
         48        BOOL                                             ~28     ~30
         49    > > JMPZ                                                     ~28, ->53
   25    50    >   FETCH_DIM_R                                      ~32     !3, !5
         51        ASSIGN_DIM                                               !4, !5
         52        OP_DATA                                                  ~32
   20    53    >   PRE_INC                                                  !5
         54    >   COUNT                                            ~34     !0
         55        IS_SMALLER                                               !5, ~34
         56      > JMPNZ                                                    ~35, ->37
   28    57    > > RETURN                                                   !4
   29    58*     > RETURN                                                   null

End of function merge_sort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.24 ms | 1403 KiB | 18 Q