3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sInput = 'turn on 0,0 through 999,999'; $aLights = array(); for($x = 0; $x < 1000; $x++) { for($y = 0; $y < 1000; $y++) { $aLights[$x . 'x' . $y] = false; } } $aInput = explode("\r\n", $sInput); foreach($aInput as $sInput) { preg_match('#(?<action>turn (?:on|off)|toggle) (?<from_x>[0-9]{1,3}),(?<from_y>[0-9]{1,3}) through (?<to_x>[0-9]{1,3}),(?<to_y>[0-9]{1,3})#', $sInput, $aMatch); for($x = $aMatch['from_x']; $x <= $aMatch['to_x']; $x++) { for($y = $aMatch['from_y']; $y <= $aMatch['to_y']; $y++) { switch($aMatch['action']) { case 'turn on': $aLights[$x . 'x' . $y] = true; break; case 'turn off': $aLights[$x . 'x' . $y] = false; break; case 'toggle': $aLights[$x . 'x' . $y] = ($aLights[$x . 'x' . $y] ? false : true); break; } } } } echo count(array_filter($aLights));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 4
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 75
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 75
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 31
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 34
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 31
Branch analysis from position: 74
Branch analysis from position: 31
Branch analysis from position: 34
5 jumps found. (Code = 188) Position 1 = 43, Position 2 = 48, Position 3 = 53, Position 4 = 65, Position 5 = 36
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 34
Branch analysis from position: 70
Branch analysis from position: 34
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 61
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
Branch analysis from position: 65
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 43
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 48
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 53
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
Branch analysis from position: 53
Branch analysis from position: 48
Branch analysis from position: 43
Branch analysis from position: 75
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 75
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 6
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 4
Branch analysis from position: 16
Branch analysis from position: 4
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 6
Branch analysis from position: 13
Branch analysis from position: 6
filename:       /in/PBmXX
function name:  (null)
number of ops:  82
compiled vars:  !0 = $sInput, !1 = $aLights, !2 = $x, !3 = $y, !4 = $aInput, !5 = $aMatch
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'turn+on+0%2C0+through+999%2C999'
    4     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->14
    8     4    >   ASSIGN                                                   !3, 0
          5      > JMP                                                      ->11
   10     6    >   CONCAT                                           ~10     !2, 'x'
          7        CONCAT                                           ~11     ~10, !3
          8        ASSIGN_DIM                                               !1, ~11
          9        OP_DATA                                                  <false>
    8    10        PRE_INC                                                  !3
         11    >   IS_SMALLER                                               !3, 1000
         12      > JMPNZ                                                    ~14, ->6
    6    13    >   PRE_INC                                                  !2
         14    >   IS_SMALLER                                               !2, 1000
         15      > JMPNZ                                                    ~16, ->4
   14    16    >   INIT_FCALL                                               'explode'
         17        SEND_VAL                                                 '%0D%0A'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $17     
         20        ASSIGN                                                   !4, $17
   16    21      > FE_RESET_R                                       $19     !4, ->75
         22    > > FE_FETCH_R                                               $19, !0, ->75
   18    23    >   INIT_FCALL                                               'preg_match'
         24        SEND_VAL                                                 '%23%28%3F%3Caction%3Eturn+%28%3F%3Aon%7Coff%29%7Ctoggle%29+%28%3F%3Cfrom_x%3E%5B0-9%5D%7B1%2C3%7D%29%2C%28%3F%3Cfrom_y%3E%5B0-9%5D%7B1%2C3%7D%29+through+%28%3F%3Cto_x%3E%5B0-9%5D%7B1%2C3%7D%29%2C%28%3F%3Cto_y%3E%5B0-9%5D%7B1%2C3%7D%29%23'
         25        SEND_VAR                                                 !0
         26        SEND_REF                                                 !5
         27        DO_ICALL                                                 
   20    28        FETCH_DIM_R                                      ~21     !5, 'from_x'
         29        ASSIGN                                                   !2, ~21
         30      > JMP                                                      ->71
   22    31    >   FETCH_DIM_R                                      ~23     !5, 'from_y'
         32        ASSIGN                                                   !3, ~23
         33      > JMP                                                      ->67
   24    34    >   FETCH_DIM_R                                      ~25     !5, 'action'
         35      > SWITCH_STRING                                            ~25, [ 'turn+on':->43, 'turn+off':->48, 'toggle':->53, ], ->65
   26    36    >   CASE                                                     ~25, 'turn+on'
         37      > JMPNZ                                                    ~26, ->43
   30    38    >   CASE                                                     ~25, 'turn+off'
         39      > JMPNZ                                                    ~26, ->48
   34    40    >   CASE                                                     ~25, 'toggle'
         41      > JMPNZ                                                    ~26, ->53
         42    > > JMP                                                      ->65
   27    43    >   CONCAT                                           ~27     !2, 'x'
         44        CONCAT                                           ~28     ~27, !3
         45        ASSIGN_DIM                                               !1, ~28
         46        OP_DATA                                                  <true>
   28    47      > JMP                                                      ->65
   31    48    >   CONCAT                                           ~30     !2, 'x'
         49        CONCAT                                           ~31     ~30, !3
         50        ASSIGN_DIM                                               !1, ~31
         51        OP_DATA                                                  <false>
   32    52      > JMP                                                      ->65
   35    53    >   CONCAT                                           ~33     !2, 'x'
         54        CONCAT                                           ~34     ~33, !3
         55        CONCAT                                           ~36     !2, 'x'
         56        CONCAT                                           ~37     ~36, !3
         57        FETCH_DIM_R                                      ~38     !1, ~37
         58      > JMPZ                                                     ~38, ->61
         59    >   QM_ASSIGN                                        ~39     <false>
         60      > JMP                                                      ->62
         61    >   QM_ASSIGN                                        ~39     <true>
         62    >   ASSIGN_DIM                                               !1, ~34
         63        OP_DATA                                                  ~39
   36    64      > JMP                                                      ->65
         65    >   FREE                                                     ~25
   22    66        PRE_INC                                                  !3
         67    >   FETCH_DIM_R                                      ~41     !5, 'to_y'
         68        IS_SMALLER_OR_EQUAL                                      !3, ~41
         69      > JMPNZ                                                    ~42, ->34
   20    70    >   PRE_INC                                                  !2
         71    >   FETCH_DIM_R                                      ~44     !5, 'to_x'
         72        IS_SMALLER_OR_EQUAL                                      !2, ~44
         73      > JMPNZ                                                    ~45, ->31
   16    74    > > JMP                                                      ->22
         75    >   FE_FREE                                                  $19
   42    76        INIT_FCALL                                               'array_filter'
         77        SEND_VAR                                                 !1
         78        DO_ICALL                                         $46     
         79        COUNT                                            ~47     $46
         80        ECHO                                                     ~47
         81      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.4 ms | 950 KiB | 20 Q