3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_even(int $n): bool { if ($n < 0) { $n = abs($n); } if ($n === 0) { return true; } if ($n === 1) { return false; } return is_even($n - 1); } var_dump(is_even(-5)); die(); for($i = -5; $i <= 12; $i++) { printf('is %d even? %s.%s', $i, is_even($i) ? 'yes': 'no', "\n"); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/U9Nos
function name:  (null)
number of ops:  26
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'is_even'
          2        SEND_VAL                                                 -5
          3        DO_FCALL                                      0  $1      
          4        SEND_VAR                                                 $1
          5        DO_ICALL                                                 
   24     6      > EXIT                                                     
   26     7*       ASSIGN                                                   !0, -5
          8*       JMP                                                      ->23
   27     9*       INIT_FCALL                                               'printf'
         10*       SEND_VAL                                                 'is+%25d+even%3F+%25s.%25s'
         11*       SEND_VAR                                                 !0
         12*       INIT_FCALL                                               'is_even'
         13*       SEND_VAR                                                 !0
         14*       DO_FCALL                                      0  $4      
         15*       JMPZ                                                     $4, ->18
         16*       QM_ASSIGN                                        ~5      'yes'
         17*       JMP                                                      ->19
         18*       QM_ASSIGN                                        ~5      'no'
         19*       SEND_VAL                                                 ~5
         20*       SEND_VAL                                                 '%0A'
         21*       DO_ICALL                                                 
   26    22*       PRE_INC                                                  !0
         23*       IS_SMALLER_OR_EQUAL                                      !0, 12
         24*       JMPNZ                                                    ~8, ->9
   28    25*     > RETURN                                                   1

Function is_even:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/U9Nos
function name:  is_even
number of ops:  21
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        IS_SMALLER                                               !0, 0
          2      > JMPZ                                                     ~1, ->7
    6     3    >   INIT_FCALL                                               'abs'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !0, $2
    9     7    >   IS_IDENTICAL                                             !0, 0
          8      > JMPZ                                                     ~4, ->10
   10     9    > > RETURN                                                   <true>
   13    10    >   IS_IDENTICAL                                             !0, 1
         11      > JMPZ                                                     ~5, ->13
   14    12    > > RETURN                                                   <false>
   19    13    >   INIT_FCALL_BY_NAME                                       'is_even'
         14        SUB                                              ~6      !0, 1
         15        SEND_VAL_EX                                              ~6
         16        DO_FCALL                                      0  $7      
         17        VERIFY_RETURN_TYPE                                       $7
         18      > RETURN                                                   $7
   20    19*       VERIFY_RETURN_TYPE                                       
         20*     > RETURN                                                   null

End of function is_even

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.31 ms | 1394 KiB | 21 Q