3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0]; $max = 0; for ($i = 0, $l = ceil(count($arr)) / 2; $i < $l; $i++) { if ($arr[$i] > $max) { $max = $arr[$i]; } } for ($l = count($arr); $i < $l; $i++) { if ($arr[$i] > $max) { $max = $arr[$i++]; break; } } echo "$max in $i iterations";
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 = 18, Position 2 = 10
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 21
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 21
Branch analysis from position: 31
Branch analysis from position: 21
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 10
Branch analysis from position: 18
Branch analysis from position: 10
Branch analysis from position: 15
filename:       /in/9s0Kf
function name:  (null)
number of ops:  37
compiled vars:  !0 = $arr, !1 = $max, !2 = $i, !3 = $l
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, 0
    7     2        ASSIGN                                                   !2, 0
          3        INIT_FCALL                                               'ceil'
          4        COUNT                                            ~7      !0
          5        SEND_VAL                                                 ~7
          6        DO_ICALL                                         $8      
          7        DIV                                              ~9      $8, 2
          8        ASSIGN                                                   !3, ~9
          9      > JMP                                                      ->16
    8    10    >   FETCH_DIM_R                                      ~11     !0, !2
         11        IS_SMALLER                                               !1, ~11
         12      > JMPZ                                                     ~12, ->15
    9    13    >   FETCH_DIM_R                                      ~13     !0, !2
         14        ASSIGN                                                   !1, ~13
    7    15    >   PRE_INC                                                  !2
         16    >   IS_SMALLER                                               !2, !3
         17      > JMPNZ                                                    ~16, ->10
   13    18    >   COUNT                                            ~17     !0
         19        ASSIGN                                                   !3, ~17
         20      > JMP                                                      ->29
   14    21    >   FETCH_DIM_R                                      ~19     !0, !2
         22        IS_SMALLER                                               !1, ~19
         23      > JMPZ                                                     ~20, ->28
   15    24    >   POST_INC                                         ~21     !2
         25        FETCH_DIM_R                                      ~22     !0, ~21
         26        ASSIGN                                                   !1, ~22
   16    27      > JMP                                                      ->31
   13    28    >   PRE_INC                                                  !2
         29    >   IS_SMALLER                                               !2, !3
         30      > JMPNZ                                                    ~25, ->21
   20    31    >   ROPE_INIT                                     4  ~27     !1
         32        ROPE_ADD                                      1  ~27     ~27, '+in+'
         33        ROPE_ADD                                      2  ~27     ~27, !2
         34        ROPE_END                                      3  ~26     ~27, '+iterations'
         35        ECHO                                                     ~26
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.71 ms | 1400 KiB | 15 Q