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); } 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 = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 2
Branch analysis from position: 18
Branch analysis from position: 2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 2
Branch analysis from position: 18
Branch analysis from position: 2
filename:       /in/6iSSU
function name:  (null)
number of ops:  19
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                   !0, -5
          1      > JMP                                                      ->16
   21     2    >   INIT_FCALL                                               'printf'
          3        SEND_VAL                                                 'is+%25d+even%3F+%25s.%25s'
          4        SEND_VAR                                                 !0
          5        INIT_FCALL                                               'is_even'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $2      
          8      > JMPZ                                                     $2, ->11
          9    >   QM_ASSIGN                                        ~3      'yes'
         10      > JMP                                                      ->12
         11    >   QM_ASSIGN                                        ~3      'no'
         12    >   SEND_VAL                                                 ~3
         13        SEND_VAL                                                 '%0A'
         14        DO_ICALL                                                 
   20    15        PRE_INC                                                  !0
         16    >   IS_SMALLER_OR_EQUAL                                      !0, 12
         17      > JMPNZ                                                    ~6, ->2
   22    18    > > 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/6iSSU
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>
   17    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
   18    19*       VERIFY_RETURN_TYPE                                       
         20*     > RETURN                                                   null

End of function is_even

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.84 ms | 1402 KiB | 18 Q