3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [1, 22, 56, 53, 34, 51, 77]; function _find($arr, $search, $left, $right) { if ($left > $right) return false; $pivot = rand($left, $right); return $arr[$pivot] == $search ? true : _find($arr, $search, $left, $pivot-1) || _find($arr, $search, $pivot+1, $right); } $found = _find($arr, 53, 0, count($arr)-1); var_dump($found);exit;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/FFFZp
function name:  (null)
number of ops:  15
compiled vars:  !0 = $arr, !1 = $found
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   14     1        INIT_FCALL                                               '_find'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 53
          4        SEND_VAL                                                 0
          5        COUNT                                            ~3      !0
          6        SUB                                              ~4      ~3, 1
          7        SEND_VAL                                                 ~4
          8        DO_FCALL                                      0  $5      
          9        ASSIGN                                                   !1, $5
   15    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
         13      > EXIT                                                     
         14*     > RETURN                                                   1

Function _find:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 47) Position 1 = 25, Position 2 = 33
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/FFFZp
function name:  _find
number of ops:  36
compiled vars:  !0 = $arr, !1 = $search, !2 = $left, !3 = $right, !4 = $pivot
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    5     4        IS_SMALLER                                               !3, !2
          5      > JMPZ                                                     ~5, ->7
    6     6    > > RETURN                                                   <false>
    8     7    >   INIT_FCALL                                               'rand'
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !4, $6
    9    12        FETCH_DIM_R                                      ~8      !0, !4
         13        IS_EQUAL                                                 !1, ~8
         14      > JMPZ                                                     ~9, ->17
   10    15    >   QM_ASSIGN                                        ~10     <true>
         16      > JMP                                                      ->34
   11    17    >   INIT_FCALL_BY_NAME                                       '_find'
         18        SEND_VAR_EX                                              !0
         19        SEND_VAR_EX                                              !1
         20        SEND_VAR_EX                                              !2
         21        SUB                                              ~11     !4, 1
         22        SEND_VAL_EX                                              ~11
         23        DO_FCALL                                      0  $12     
         24      > JMPNZ_EX                                         ~13     $12, ->33
         25    >   INIT_FCALL_BY_NAME                                       '_find'
         26        SEND_VAR_EX                                              !0
         27        SEND_VAR_EX                                              !1
         28        ADD                                              ~14     !4, 1
         29        SEND_VAL_EX                                              ~14
         30        SEND_VAR_EX                                              !3
         31        DO_FCALL                                      0  $15     
         32        BOOL                                             ~13     $15
         33    >   QM_ASSIGN                                        ~10     ~13
         34    > > RETURN                                                   ~10
   13    35*     > RETURN                                                   null

End of function _find

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.05 ms | 1407 KiB | 18 Q