3v4l.org

run code in 300+ PHP versions simultaneously
<?php function count_and_find($arr) { sort($arr); $missing = array(); $index = 0; $count = count($arr); while ($num = array_shift($arr)) { do { if ($index < $num) { $missing[] = $index; $index++; } } while ($index < $num); } return array('missing' => $missing, 'total' => $count); } var_dump(count_and_find(array(1,6,2,9,3,0,5,7,4)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rrVvM
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'count_and_find'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function count_and_find:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 9
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 9
Branch analysis from position: 16
Branch analysis from position: 9
Branch analysis from position: 14
filename:       /in/rrVvM
function name:  count_and_find
number of ops:  25
compiled vars:  !0 = $arr, !1 = $missing, !2 = $index, !3 = $count, !4 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'sort'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
    5     4        ASSIGN                                                   !1, <array>
    6     5        ASSIGN                                                   !2, 0
    7     6        COUNT                                            ~8      !0
          7        ASSIGN                                                   !3, ~8
    8     8      > JMP                                                      ->16
   10     9    >   IS_SMALLER                                               !2, !4
         10      > JMPZ                                                     ~10, ->14
   11    11    >   ASSIGN_DIM                                               !1
         12        OP_DATA                                                  !2
   12    13        PRE_INC                                                  !2
   14    14    >   IS_SMALLER                                               !2, !4
         15      > JMPNZ                                                    ~13, ->9
    8    16    >   INIT_FCALL                                               'array_shift'
         17        SEND_REF                                                 !0
         18        DO_ICALL                                         $14     
         19        ASSIGN                                           ~15     !4, $14
         20      > JMPNZ                                                    ~15, ->9
   18    21    >   INIT_ARRAY                                       ~16     !1, 'missing'
         22        ADD_ARRAY_ELEMENT                                ~16     !3, 'total'
         23      > RETURN                                                   ~16
   19    24*     > RETURN                                                   null

End of function count_and_find

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.47 ms | 1399 KiB | 20 Q