3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('N', 1000000); $h = array_fill(0, N, 0); function pushDown($pos, $n) { global $h; while (2 * $pos + 1 < $n) { $j = 2 * $pos + 1; if ($j + 1 < $n && $h[$j + 1] > $h[$j]) $j++; if ($h[$pos] >= $h[$j]) break; $t = $h[$pos]; $h[$pos] = $h[$j]; $h[$j] = $t; $pos = $j; } } function main() { global $h; $start = round(microtime(true) * 1000); for ($i = 0; $i < N; $i++) { $h[$i] = $i; } for ($i = (int) (N / 2); $i >= 0; $i--) { pushDown($i, N); } $n = N; while ($n > 1) { $n--; $t = $h[0]; $h[0] = $h[$n]; $h[$n] = $t; pushDown(0, $n); } foreach ($h as $i => $v) { if ($i !== $v) { echo "Sorting failed at index $i!\n"; return; } } $finish = round(microtime(true) * 1000); $delta = $finish - $start; echo "Done in $delta\n"; } main();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZEJ60
function name:  (null)
number of ops:  14
compiled vars:  !0 = $h
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'N'
          2        SEND_VAL                                                 1000000
          3        DO_ICALL                                                 
    5     4        INIT_FCALL                                               'array_fill'
          5        SEND_VAL                                                 0
          6        FETCH_CONSTANT                                   ~2      'N'
          7        SEND_VAL                                                 ~2
          8        SEND_VAL                                                 0
          9        DO_ICALL                                         $3      
         10        ASSIGN                                                   !0, $3
   58    11        INIT_FCALL                                               'main'
         12        DO_FCALL                                      0          
         13      > RETURN                                                   1

Function pushdown:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 4
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 4
Branch analysis from position: 34
Branch analysis from position: 4
Branch analysis from position: 17
Branch analysis from position: 15
filename:       /in/ZEJ60
function name:  pushDown
number of ops:  35
compiled vars:  !0 = $pos, !1 = $n, !2 = $h, !3 = $j, !4 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        BIND_GLOBAL                                              !2, 'h'
   10     3      > JMP                                                      ->30
   11     4    >   MUL                                              ~5      !0, 2
          5        ADD                                              ~6      ~5, 1
          6        ASSIGN                                                   !3, ~6
   12     7        ADD                                              ~8      !3, 1
          8        IS_SMALLER                                       ~9      ~8, !1
          9      > JMPZ_EX                                          ~9      ~9, ->15
         10    >   ADD                                              ~10     !3, 1
         11        FETCH_DIM_R                                      ~11     !2, ~10
         12        FETCH_DIM_R                                      ~12     !2, !3
         13        IS_SMALLER                                       ~13     ~12, ~11
         14        BOOL                                             ~9      ~13
         15    > > JMPZ                                                     ~9, ->17
   13    16    >   PRE_INC                                                  !3
   14    17    >   FETCH_DIM_R                                      ~15     !2, !0
         18        FETCH_DIM_R                                      ~16     !2, !3
         19        IS_SMALLER_OR_EQUAL                                      ~16, ~15
         20      > JMPZ                                                     ~17, ->22
   15    21    > > JMP                                                      ->34
   16    22    >   FETCH_DIM_R                                      ~18     !2, !0
         23        ASSIGN                                                   !4, ~18
   17    24        FETCH_DIM_R                                      ~21     !2, !3
         25        ASSIGN_DIM                                               !2, !0
         26        OP_DATA                                                  ~21
   18    27        ASSIGN_DIM                                               !2, !3
         28        OP_DATA                                                  !4
   19    29        ASSIGN                                                   !0, !3
   10    30    >   MUL                                              ~24     !0, 2
         31        ADD                                              ~25     ~24, 1
         32        IS_SMALLER                                               ~25, !1
         33      > JMPNZ                                                    ~26, ->4
   21    34    > > RETURN                                                   null

End of function pushdown

Function main:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 11
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 22
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 33
Branch analysis from position: 47
2 jumps found. (Code = 77) Position 1 = 48, Position 2 = 59
Branch analysis from position: 48
2 jumps found. (Code = 78) Position 1 = 49, Position 2 = 59
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 58
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 33
Branch analysis from position: 47
Branch analysis from position: 33
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 22
Branch analysis from position: 30
Branch analysis from position: 22
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 11
Branch analysis from position: 17
Branch analysis from position: 11
filename:       /in/ZEJ60
function name:  main
number of ops:  75
compiled vars:  !0 = $h, !1 = $start, !2 = $i, !3 = $n, !4 = $t, !5 = $v, !6 = $finish, !7 = $delta
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   BIND_GLOBAL                                              !0, 'h'
   26     1        INIT_FCALL                                               'round'
          2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $8      
          5        MUL                                              ~9      $8, 1000
          6        SEND_VAL                                                 ~9
          7        DO_ICALL                                         $10     
          8        ASSIGN                                                   !1, $10
   28     9        ASSIGN                                                   !2, 0
         10      > JMP                                                      ->14
   29    11    >   ASSIGN_DIM                                               !0, !2
         12        OP_DATA                                                  !2
   28    13        PRE_INC                                                  !2
         14    >   FETCH_CONSTANT                                   ~15     'N'
         15        IS_SMALLER                                               !2, ~15
         16      > JMPNZ                                                    ~16, ->11
   32    17    >   FETCH_CONSTANT                                   ~17     'N'
         18        DIV                                              ~18     ~17, 2
         19        CAST                                          4  ~19     ~18
         20        ASSIGN                                                   !2, ~19
         21      > JMP                                                      ->28
   33    22    >   INIT_FCALL                                               'pushdown'
         23        SEND_VAR                                                 !2
         24        FETCH_CONSTANT                                   ~21     'N'
         25        SEND_VAL                                                 ~21
         26        DO_FCALL                                      0          
   32    27        PRE_DEC                                                  !2
         28    >   IS_SMALLER_OR_EQUAL                                      0, !2
         29      > JMPNZ                                                    ~24, ->22
   36    30    >   FETCH_CONSTANT                                   ~25     'N'
         31        ASSIGN                                                   !3, ~25
   37    32      > JMP                                                      ->45
   38    33    >   PRE_DEC                                                  !3
   39    34        FETCH_DIM_R                                      ~28     !0, 0
         35        ASSIGN                                                   !4, ~28
   40    36        FETCH_DIM_R                                      ~31     !0, !3
         37        ASSIGN_DIM                                               !0, 0
         38        OP_DATA                                                  ~31
   41    39        ASSIGN_DIM                                               !0, !3
         40        OP_DATA                                                  !4
   42    41        INIT_FCALL                                               'pushdown'
         42        SEND_VAL                                                 0
         43        SEND_VAR                                                 !3
         44        DO_FCALL                                      0          
   37    45    >   IS_SMALLER                                               1, !3
         46      > JMPNZ                                                    ~34, ->33
   45    47    > > FE_RESET_R                                       $35     !0, ->59
         48    > > FE_FETCH_R                                       ~36     $35, !5, ->59
         49    >   ASSIGN                                                   !2, ~36
   46    50        IS_NOT_IDENTICAL                                         !2, !5
         51      > JMPZ                                                     ~38, ->58
   47    52    >   ROPE_INIT                                     3  ~40     'Sorting+failed+at+index+'
         53        ROPE_ADD                                      1  ~40     ~40, !2
         54        ROPE_END                                      2  ~39     ~40, '%21%0A'
         55        ECHO                                                     ~39
   48    56        FE_FREE                                                  $35
         57      > RETURN                                                   null
   45    58    > > JMP                                                      ->48
         59    >   FE_FREE                                                  $35
   52    60        INIT_FCALL                                               'round'
         61        INIT_FCALL                                               'microtime'
         62        SEND_VAL                                                 <true>
         63        DO_ICALL                                         $42     
         64        MUL                                              ~43     $42, 1000
         65        SEND_VAL                                                 ~43
         66        DO_ICALL                                         $44     
         67        ASSIGN                                                   !6, $44
   53    68        SUB                                              ~46     !6, !1
         69        ASSIGN                                                   !7, ~46
   55    70        ROPE_INIT                                     3  ~49     'Done+in+'
         71        ROPE_ADD                                      1  ~49     ~49, !7
         72        ROPE_END                                      2  ~48     ~49, '%0A'
         73        ECHO                                                     ~48
   56    74      > RETURN                                                   null

End of function main

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.56 ms | 1411 KiB | 24 Q