3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_sorted($array) { $n = count($array); for ($a=0; $a<$n-1; $a++) { for ($b=$a+1; $b<$n; $b++) { if ($array[$a] > $array[$b]) { return false; } } } return true; } $array = array(INF, array(), (object)array()); sort($array); var_dump(is_sorted($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PNbAV
function name:  (null)
number of ops:  15
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_ARRAY                                       ~1      INF
          1        ADD_ARRAY_ELEMENT                                ~1      <array>
          2        CAST                                          8  ~2      <array>
          3        ADD_ARRAY_ELEMENT                                ~1      ~2
          4        ASSIGN                                                   !0, ~1
   18     5        INIT_FCALL                                               'sort'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                                 
   20     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'is_sorted'
         10        SEND_VAR                                                 !0
         11        DO_FCALL                                      0  $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function is_sorted:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 5
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 8
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 5
Branch analysis from position: 20
Branch analysis from position: 5
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 8
Branch analysis from position: 16
Branch analysis from position: 8
filename:       /in/PNbAV
function name:  is_sorted
number of ops:  22
compiled vars:  !0 = $array, !1 = $n, !2 = $a, !3 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        COUNT                                            ~4      !0
          2        ASSIGN                                                   !1, ~4
    6     3        ASSIGN                                                   !2, 0
          4      > JMP                                                      ->17
    7     5    >   ADD                                              ~7      !2, 1
          6        ASSIGN                                                   !3, ~7
          7      > JMP                                                      ->14
    8     8    >   FETCH_DIM_R                                      ~9      !0, !2
          9        FETCH_DIM_R                                      ~10     !0, !3
         10        IS_SMALLER                                               ~10, ~9
         11      > JMPZ                                                     ~11, ->13
    9    12    > > RETURN                                                   <false>
    7    13    >   PRE_INC                                                  !3
         14    >   IS_SMALLER                                               !3, !1
         15      > JMPNZ                                                    ~13, ->8
    6    16    >   PRE_INC                                                  !2
         17    >   SUB                                              ~15     !1, 1
         18        IS_SMALLER                                               !2, ~15
         19      > JMPNZ                                                    ~16, ->5
   13    20    > > RETURN                                                   <true>
   14    21*     > RETURN                                                   null

End of function is_sorted

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.9 ms | 1403 KiB | 18 Q