3v4l.org

run code in 300+ PHP versions simultaneously
<?php function move($past, $current) { if($current == 15) return 1; $x = $current >> 2; $y = $current % 4; $valid_moves = array(); if($x < 3) { $possible = $current+4; if(!isset($past[$possible])) { $valid_moves[] = $possible; } } if($x > 0) { $possible = $current-4; if(!isset($past[$possible])) { $valid_moves[] = $possible; } } if($y < 3) { $possible = $current+1; if(!isset($past[$possible])) { $valid_moves[] = $possible; } } if($y > 0) { $possible = $current-1; if(!isset($past[$possible])) { $valid_moves[] = $possible; } } if(empty($valid_moves)) return 0; else { $score = 0; $past[$current] = true; foreach($valid_moves as $valid_move) { $score += move($past, $valid_move); } return $score; } } echo move(array(),0);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RJRtd
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   INIT_FCALL                                               'move'
          1        SEND_VAL                                                 <array>
          2        SEND_VAL                                                 0
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function move:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 28
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 37
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 37
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 46
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 50
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
2 jumps found. (Code = 77) Position 1 = 54, Position 2 = 61
Branch analysis from position: 54
2 jumps found. (Code = 78) Position 1 = 55, Position 2 = 61
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
Branch analysis from position: 46
Branch analysis from position: 46
Branch analysis from position: 37
Branch analysis from position: 37
Branch analysis from position: 28
Branch analysis from position: 28
Branch analysis from position: 19
Branch analysis from position: 19
filename:       /in/RJRtd
function name:  move
number of ops:  64
compiled vars:  !0 = $past, !1 = $current, !2 = $x, !3 = $y, !4 = $valid_moves, !5 = $possible, !6 = $score, !7 = $valid_move
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        IS_EQUAL                                                 !1, 15
          3      > JMPZ                                                     ~8, ->5
          4    > > RETURN                                                   1
    4     5    >   SR                                               ~9      !1, 2
          6        ASSIGN                                                   !2, ~9
    5     7        MOD                                              ~11     !1, 4
          8        ASSIGN                                                   !3, ~11
    7     9        ASSIGN                                                   !4, <array>
    8    10        IS_SMALLER                                               !2, 3
         11      > JMPZ                                                     ~14, ->19
    9    12    >   ADD                                              ~15     !1, 4
         13        ASSIGN                                                   !5, ~15
   10    14        ISSET_ISEMPTY_DIM_OBJ                         0  ~17     !0, !5
         15        BOOL_NOT                                         ~18     ~17
         16      > JMPZ                                                     ~18, ->19
   11    17    >   ASSIGN_DIM                                               !4
         18        OP_DATA                                                  !5
   14    19    >   IS_SMALLER                                               0, !2
         20      > JMPZ                                                     ~20, ->28
   15    21    >   SUB                                              ~21     !1, 4
         22        ASSIGN                                                   !5, ~21
   16    23        ISSET_ISEMPTY_DIM_OBJ                         0  ~23     !0, !5
         24        BOOL_NOT                                         ~24     ~23
         25      > JMPZ                                                     ~24, ->28
   17    26    >   ASSIGN_DIM                                               !4
         27        OP_DATA                                                  !5
   21    28    >   IS_SMALLER                                               !3, 3
         29      > JMPZ                                                     ~26, ->37
   22    30    >   ADD                                              ~27     !1, 1
         31        ASSIGN                                                   !5, ~27
   23    32        ISSET_ISEMPTY_DIM_OBJ                         0  ~29     !0, !5
         33        BOOL_NOT                                         ~30     ~29
         34      > JMPZ                                                     ~30, ->37
   24    35    >   ASSIGN_DIM                                               !4
         36        OP_DATA                                                  !5
   27    37    >   IS_SMALLER                                               0, !3
         38      > JMPZ                                                     ~32, ->46
   28    39    >   SUB                                              ~33     !1, 1
         40        ASSIGN                                                   !5, ~33
   29    41        ISSET_ISEMPTY_DIM_OBJ                         0  ~35     !0, !5
         42        BOOL_NOT                                         ~36     ~35
         43      > JMPZ                                                     ~36, ->46
   30    44    >   ASSIGN_DIM                                               !4
         45        OP_DATA                                                  !5
   34    46    >   ISSET_ISEMPTY_CV                                         !4
         47      > JMPZ                                                     ~38, ->50
         48    > > RETURN                                                   0
         49*       JMP                                                      ->63
   36    50    >   ASSIGN                                                   !6, 0
   37    51        ASSIGN_DIM                                               !0, !1
         52        OP_DATA                                                  <true>
   38    53      > FE_RESET_R                                       $41     !4, ->61
         54    > > FE_FETCH_R                                               $41, !7, ->61
   39    55    >   INIT_FCALL_BY_NAME                                       'move'
         56        SEND_VAR_EX                                              !0
         57        SEND_VAR_EX                                              !7
         58        DO_FCALL                                      0  $42     
         59        ASSIGN_OP                                     1          !6, $42
   38    60      > JMP                                                      ->54
         61    >   FE_FREE                                                  $41
   41    62      > RETURN                                                   !6
   43    63*     > RETURN                                                   null

End of function move

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
256.35 ms | 1407 KiB | 15 Q