3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getIntervalIndex(array $intervals, $needle) { $needle = (int)$needle; $len = count($intervals); $result = -1; for ($i = 0; $i < $len; $i++) { $current = $intervals[$i]; if ($current > $needle) { $result = $i - 1; break; } } return $result; } var_dump(getIntervalIndex(array(0,5,10,13), 5));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hrIqg
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'getintervalindex'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 5
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function getintervalindex:
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 = 19, Position 2 = 9
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 9
Branch analysis from position: 19
Branch analysis from position: 9
filename:       /in/hrIqg
function name:  getIntervalIndex
number of ops:  21
compiled vars:  !0 = $intervals, !1 = $needle, !2 = $len, !3 = $result, !4 = $i, !5 = $current
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        CAST                                          4  ~6      !1
          3        ASSIGN                                                   !1, ~6
    4     4        COUNT                                            ~8      !0
          5        ASSIGN                                                   !2, ~8
    5     6        ASSIGN                                                   !3, -1
    7     7        ASSIGN                                                   !4, 0
          8      > JMP                                                      ->17
    8     9    >   FETCH_DIM_R                                      ~12     !0, !4
         10        ASSIGN                                                   !5, ~12
   10    11        IS_SMALLER                                               !1, !5
         12      > JMPZ                                                     ~14, ->16
   11    13    >   SUB                                              ~15     !4, 1
         14        ASSIGN                                                   !3, ~15
   12    15      > JMP                                                      ->19
    7    16    >   PRE_INC                                                  !4
         17    >   IS_SMALLER                                               !4, !2
         18      > JMPNZ                                                    ~18, ->9
   16    19    > > RETURN                                                   !3
   17    20*     > RETURN                                                   null

End of function getintervalindex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.57 ms | 1399 KiB | 16 Q