3v4l.org

run code in 300+ PHP versions simultaneously
<?php for ($i = 0; $i < 16; $i++) { var_dump(method($i) . "\t" . method1($i) . "\t" . pow(2, $i-1)); } function method($n) { if ($n <= 0) return 0; if ($n == 1) return 1; if ($n == 2) return 2; if ($n == 3) return 4; return method($n - 1) + method($n - 2) + method($n - 3); } function method1($n) { if ($n <= 0) return 0; $r = 1; for ($i = 0; $i < $n; $i++) { $r += method1($i); } return $r; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 2
Branch analysis from position: 23
Branch analysis from position: 2
filename:       /in/632MR
function name:  (null)
number of ops:  24
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->21
    3     2    >   INIT_FCALL                                               'var_dump'
          3        INIT_FCALL_BY_NAME                                       'method'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $2      
          6        CONCAT                                           ~3      $2, '%09'
          7        INIT_FCALL_BY_NAME                                       'method1'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $4      
         10        CONCAT                                           ~5      ~3, $4
         11        CONCAT                                           ~6      ~5, '%09'
         12        INIT_FCALL                                               'pow'
         13        SEND_VAL                                                 2
         14        SUB                                              ~7      !0, 1
         15        SEND_VAL                                                 ~7
         16        DO_ICALL                                         $8      
         17        CONCAT                                           ~9      ~6, $8
         18        SEND_VAL                                                 ~9
         19        DO_ICALL                                                 
    2    20        PRE_INC                                                  !0
         21    >   IS_SMALLER                                               !0, 16
         22      > JMPNZ                                                    ~12, ->2
   24    23    > > RETURN                                                   1

Function method:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
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 = 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
filename:       /in/632MR
function name:  method
number of ops:  29
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        IS_SMALLER_OR_EQUAL                                      !0, 0
          2      > JMPZ                                                     ~1, ->4
          3    > > RETURN                                                   0
    8     4    >   IS_EQUAL                                                 !0, 1
          5      > JMPZ                                                     ~2, ->7
          6    > > RETURN                                                   1
    9     7    >   IS_EQUAL                                                 !0, 2
          8      > JMPZ                                                     ~3, ->10
          9    > > RETURN                                                   2
   10    10    >   IS_EQUAL                                                 !0, 3
         11      > JMPZ                                                     ~4, ->13
         12    > > RETURN                                                   4
   12    13    >   INIT_FCALL_BY_NAME                                       'method'
         14        SUB                                              ~5      !0, 1
         15        SEND_VAL_EX                                              ~5
         16        DO_FCALL                                      0  $6      
         17        INIT_FCALL_BY_NAME                                       'method'
         18        SUB                                              ~7      !0, 2
         19        SEND_VAL_EX                                              ~7
         20        DO_FCALL                                      0  $8      
         21        ADD                                              ~9      $6, $8
         22        INIT_FCALL_BY_NAME                                       'method'
         23        SUB                                              ~10     !0, 3
         24        SEND_VAL_EX                                              ~10
         25        DO_FCALL                                      0  $11     
         26        ADD                                              ~12     ~9, $11
         27      > RETURN                                                   ~12
   13    28*     > RETURN                                                   null

End of function method

Function method1:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 7
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 7
Branch analysis from position: 14
Branch analysis from position: 7
filename:       /in/632MR
function name:  method1
number of ops:  16
compiled vars:  !0 = $n, !1 = $r, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        IS_SMALLER_OR_EQUAL                                      !0, 0
          2      > JMPZ                                                     ~3, ->4
          3    > > RETURN                                                   0
   18     4    >   ASSIGN                                                   !1, 1
   19     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->12
   20     7    >   INIT_FCALL_BY_NAME                                       'method1'
          8        SEND_VAR_EX                                              !2
          9        DO_FCALL                                      0  $6      
         10        ASSIGN_OP                                     1          !1, $6
   19    11        PRE_INC                                                  !2
         12    >   IS_SMALLER                                               !2, !0
         13      > JMPNZ                                                    ~9, ->7
   23    14    > > RETURN                                                   !1
   24    15*     > RETURN                                                   null

End of function method1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.08 ms | 1404 KiB | 17 Q