3v4l.org

run code in 300+ PHP versions simultaneously
<?php function minMax(array $arr, int $left, int $right, &$minVal, &$maxVal) { if ($left === $right) { $minVal = $arr[$left]; $maxVal = $arr[$left]; } elseif (($right - $left) === 1) { $minVal = ($arr[$left] <= $arr[$right]) ? $arr[$left] : $arr[$right]; $maxVal = ($arr[$left] <= $arr[$right]) ? $arr[$right] : $arr[$left]; } else { $mid = (int)(($left + $right) / 2); minMax($arr, $left, $mid, $minVal, $maxVal); $minVal2 = null; $maxVal2 = null; minMax($arr, $mid + 1, $right, $minVal2, $maxVal2); $minVal = ($minVal2 < $minVal) ? $minVal2 : $minVal; $maxVal = ($maxVal2 > $maxVal) ? $maxVal2 : $maxVal; } } $arr = [3, 1, 5, 2, 9, 7]; $left = 0; $right = count($arr) - 1; $minVal = null; $maxVal = null; minMax($arr, $left, $right, $minVal, $maxVal); echo $minVal, "\n"; echo $maxVal, "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tJGH8
function name:  (null)
number of ops:  19
compiled vars:  !0 = $arr, !1 = $left, !2 = $right, !3 = $minVal, !4 = $maxVal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                   !0, <array>
   21     1        ASSIGN                                                   !1, 0
   22     2        COUNT                                            ~7      !0
          3        SUB                                              ~8      ~7, 1
          4        ASSIGN                                                   !2, ~8
   23     5        ASSIGN                                                   !3, null
   24     6        ASSIGN                                                   !4, null
   25     7        INIT_FCALL                                               'minmax'
          8        SEND_VAR                                                 !0
          9        SEND_VAR                                                 !1
         10        SEND_VAR                                                 !2
         11        SEND_REF                                                 !3
         12        SEND_REF                                                 !4
         13        DO_FCALL                                      0          
   27    14        ECHO                                                     !3
         15        ECHO                                                     '%0A'
   28    16        ECHO                                                     !4
         17        ECHO                                                     '%0A'
         18      > RETURN                                                   1

Function minmax:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 36
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 32
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 32
Branch analysis from position: 29
Branch analysis from position: 32
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 61
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 67
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 67
Branch analysis from position: 65
Branch analysis from position: 67
filename:       /in/tJGH8
function name:  minMax
number of ops:  70
compiled vars:  !0 = $arr, !1 = $left, !2 = $right, !3 = $minVal, !4 = $maxVal, !5 = $mid, !6 = $minVal2, !7 = $maxVal2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
    3     5        IS_IDENTICAL                                             !1, !2
          6      > JMPZ                                                     ~8, ->12
    4     7    >   FETCH_DIM_R                                      ~9      !0, !1
          8        ASSIGN                                                   !3, ~9
    5     9        FETCH_DIM_R                                      ~11     !0, !1
         10        ASSIGN                                                   !4, ~11
    3    11      > JMP                                                      ->69
    6    12    >   SUB                                              ~13     !2, !1
         13        IS_IDENTICAL                                             ~13, 1
         14      > JMPZ                                                     ~14, ->36
    7    15    >   FETCH_DIM_R                                      ~15     !0, !1
         16        FETCH_DIM_R                                      ~16     !0, !2
         17        IS_SMALLER_OR_EQUAL                                      ~15, ~16
         18      > JMPZ                                                     ~17, ->22
         19    >   FETCH_DIM_R                                      ~18     !0, !1
         20        QM_ASSIGN                                        ~19     ~18
         21      > JMP                                                      ->24
         22    >   FETCH_DIM_R                                      ~20     !0, !2
         23        QM_ASSIGN                                        ~19     ~20
         24    >   ASSIGN                                                   !3, ~19
    8    25        FETCH_DIM_R                                      ~22     !0, !1
         26        FETCH_DIM_R                                      ~23     !0, !2
         27        IS_SMALLER_OR_EQUAL                                      ~22, ~23
         28      > JMPZ                                                     ~24, ->32
         29    >   FETCH_DIM_R                                      ~25     !0, !2
         30        QM_ASSIGN                                        ~26     ~25
         31      > JMP                                                      ->34
         32    >   FETCH_DIM_R                                      ~27     !0, !1
         33        QM_ASSIGN                                        ~26     ~27
         34    >   ASSIGN                                                   !4, ~26
    6    35      > JMP                                                      ->69
   10    36    >   ADD                                              ~29     !1, !2
         37        DIV                                              ~30     ~29, 2
         38        CAST                                          4  ~31     ~30
         39        ASSIGN                                                   !5, ~31
   11    40        INIT_FCALL_BY_NAME                                       'minMax'
         41        SEND_VAR_EX                                              !0
         42        SEND_VAR_EX                                              !1
         43        SEND_VAR_EX                                              !5
         44        SEND_VAR_EX                                              !3
         45        SEND_VAR_EX                                              !4
         46        DO_FCALL                                      0          
   12    47        ASSIGN                                                   !6, null
   13    48        ASSIGN                                                   !7, null
   14    49        INIT_FCALL_BY_NAME                                       'minMax'
         50        SEND_VAR_EX                                              !0
         51        ADD                                              ~36     !5, 1
         52        SEND_VAL_EX                                              ~36
         53        SEND_VAR_EX                                              !2
         54        SEND_VAR_EX                                              !6
         55        SEND_VAR_EX                                              !7
         56        DO_FCALL                                      0          
   15    57        IS_SMALLER                                               !6, !3
         58      > JMPZ                                                     ~38, ->61
         59    >   QM_ASSIGN                                        ~39     !6
         60      > JMP                                                      ->62
         61    >   QM_ASSIGN                                        ~39     !3
         62    >   ASSIGN                                                   !3, ~39
   16    63        IS_SMALLER                                               !4, !7
         64      > JMPZ                                                     ~41, ->67
         65    >   QM_ASSIGN                                        ~42     !7
         66      > JMP                                                      ->68
         67    >   QM_ASSIGN                                        ~42     !4
         68    >   ASSIGN                                                   !4, ~42
   18    69    > > RETURN                                                   null

End of function minmax

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.79 ms | 1020 KiB | 14 Q