3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = "123 -> x 456 -> y x AND y -> d x OR y -> e x LSHIFT 2 -> f y RSHIFT 2 -> g NOT x -> h NOT y -> i"; $inputs = explode("\n", $input); function operation($s){ $matchesand = null; $and = preg_match("/(.{1,2})\sAND\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesand); if(count($matchesand)>0){ return [$matchesand[1] & $matchesand[2], $matchesand[3]]; } $matchesor= null; $or = preg_match("/(.{1,2})\sOR\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesor); if(count($matchesor)>0){ return [$matchesor[1] | $matchesor[2], $matchesor[3]]; } $matchesnot = null; $not = preg_match("/NOT\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesnot); if(count($matchesnot)>0){ return [~$matchesnot[1], $matchesnot[2]]; } $matchesleft = null; $left = preg_match("/(.{1,2})\sLSHIFT\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesleft); if(count($matchesleft)>0){ return [$matchesleft[1] << $matchesleft[2], $matchesleft[3]]; } $matchesright = null; $right = preg_match("/(.{1,2})\sRSHIFT\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesright); if(count($matchesright)>0){ return [$matchesright[1] >> $matchesright[2], $matchesright[3]]; } $matches = null; $simple = preg_match("/(.{1,5})\s->\s(.{1,2})/",$s,$matches); if(count($matches)>0){ return [$matches[1], $matches[2]]; } } $array=[]; for($i = 'a'; $i<'z'; $i++){ $array[$i]=0; } for($i = 'a'; $i<'z'; $i++){ for($j = 'a'; $j<'z'; $j++){ $array[$i.$j]=0; } } for($i = 0; $i<count($inputs); $i++){ $var = operation($inputs[$i])[1]; $val = operation($inputs[$i])[0]; $array[$var] = $val; } var_dump($array); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 9
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 16
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 29
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 29
Branch analysis from position: 47
Branch analysis from position: 29
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 18
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 16
Branch analysis from position: 27
Branch analysis from position: 16
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 18
Branch analysis from position: 24
Branch analysis from position: 18
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 9
Branch analysis from position: 14
Branch analysis from position: 9
filename:       /in/9NZH1
function name:  (null)
number of ops:  51
compiled vars:  !0 = $input, !1 = $inputs, !2 = $array, !3 = $i, !4 = $j, !5 = $var, !6 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '123+-%3E+x%0A456+-%3E+y%0Ax+AND+y+-%3E+d%0Ax+OR+y+-%3E+e%0Ax+LSHIFT+2+-%3E+f%0Ay+RSHIFT+2+-%3E+g%0ANOT+x+-%3E+h%0ANOT+y+-%3E+i'
   10     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
   48     6        ASSIGN                                                   !2, <array>
   49     7        ASSIGN                                                   !3, 'a'
          8      > JMP                                                      ->12
   50     9    >   ASSIGN_DIM                                               !2, !3
         10        OP_DATA                                                  0
   49    11        PRE_INC                                                  !3
         12    >   IS_SMALLER                                               !3, 'z'
         13      > JMPNZ                                                    ~14, ->9
   52    14    >   ASSIGN                                                   !3, 'a'
         15      > JMP                                                      ->25
   53    16    >   ASSIGN                                                   !4, 'a'
         17      > JMP                                                      ->22
   54    18    >   CONCAT                                           ~17     !3, !4
         19        ASSIGN_DIM                                               !2, ~17
         20        OP_DATA                                                  0
   53    21        PRE_INC                                                  !4
         22    >   IS_SMALLER                                               !4, 'z'
         23      > JMPNZ                                                    ~20, ->18
   52    24    >   PRE_INC                                                  !3
         25    >   IS_SMALLER                                               !3, 'z'
         26      > JMPNZ                                                    ~22, ->16
   57    27    >   ASSIGN                                                   !3, 0
         28      > JMP                                                      ->44
   58    29    >   INIT_FCALL                                               'operation'
         30        FETCH_DIM_R                                      ~24     !1, !3
         31        SEND_VAL                                                 ~24
         32        DO_FCALL                                      0  $25     
         33        FETCH_DIM_R                                      ~26     $25, 1
         34        ASSIGN                                                   !5, ~26
   59    35        INIT_FCALL                                               'operation'
         36        FETCH_DIM_R                                      ~28     !1, !3
         37        SEND_VAL                                                 ~28
         38        DO_FCALL                                      0  $29     
         39        FETCH_DIM_R                                      ~30     $29, 0
         40        ASSIGN                                                   !6, ~30
   61    41        ASSIGN_DIM                                               !2, !5
         42        OP_DATA                                                  !6
   57    43        PRE_INC                                                  !3
         44    >   COUNT                                            ~34     !1
         45        IS_SMALLER                                               !3, ~34
         46      > JMPNZ                                                    ~35, ->29
   63    47    >   INIT_FCALL                                               'var_dump'
         48        SEND_VAR                                                 !2
         49        DO_ICALL                                                 
   64    50      > RETURN                                                   1

Function operation:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 35
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 51
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 68
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 85
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 85
2 jumps found. (Code = 43) Position 1 = 95, Position 2 = 100
Branch analysis from position: 95
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 100
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9NZH1
function name:  operation
number of ops:  101
compiled vars:  !0 = $s, !1 = $matchesand, !2 = $and, !3 = $matchesor, !4 = $or, !5 = $matchesnot, !6 = $not, !7 = $matchesleft, !8 = $left, !9 = $matchesright, !10 = $right, !11 = $matches, !12 = $simple
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        ASSIGN                                                   !1, null
   14     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAL                                                 '%2F%28.%7B1%2C2%7D%29%5CsAND%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !1
          6        DO_ICALL                                         $14     
          7        ASSIGN                                                   !2, $14
   15     8        COUNT                                            ~16     !1
          9        IS_SMALLER                                               0, ~16
         10      > JMPZ                                                     ~17, ->18
   16    11    >   FETCH_DIM_R                                      ~18     !1, 1
         12        FETCH_DIM_R                                      ~19     !1, 2
         13        BW_AND                                           ~20     ~18, ~19
         14        INIT_ARRAY                                       ~21     ~20
         15        FETCH_DIM_R                                      ~22     !1, 3
         16        ADD_ARRAY_ELEMENT                                ~21     ~22
         17      > RETURN                                                   ~21
   19    18    >   ASSIGN                                                   !3, null
   20    19        INIT_FCALL                                               'preg_match'
         20        SEND_VAL                                                 '%2F%28.%7B1%2C2%7D%29%5CsOR%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         21        SEND_VAR                                                 !0
         22        SEND_REF                                                 !3
         23        DO_ICALL                                         $24     
         24        ASSIGN                                                   !4, $24
   21    25        COUNT                                            ~26     !3
         26        IS_SMALLER                                               0, ~26
         27      > JMPZ                                                     ~27, ->35
   22    28    >   FETCH_DIM_R                                      ~28     !3, 1
         29        FETCH_DIM_R                                      ~29     !3, 2
         30        BW_OR                                            ~30     ~28, ~29
         31        INIT_ARRAY                                       ~31     ~30
         32        FETCH_DIM_R                                      ~32     !3, 3
         33        ADD_ARRAY_ELEMENT                                ~31     ~32
         34      > RETURN                                                   ~31
   25    35    >   ASSIGN                                                   !5, null
   26    36        INIT_FCALL                                               'preg_match'
         37        SEND_VAL                                                 '%2FNOT%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         38        SEND_VAR                                                 !0
         39        SEND_REF                                                 !5
         40        DO_ICALL                                         $34     
         41        ASSIGN                                                   !6, $34
   27    42        COUNT                                            ~36     !5
         43        IS_SMALLER                                               0, ~36
         44      > JMPZ                                                     ~37, ->51
   28    45    >   FETCH_DIM_R                                      ~38     !5, 1
         46        BW_NOT                                           ~39     ~38
         47        INIT_ARRAY                                       ~40     ~39
         48        FETCH_DIM_R                                      ~41     !5, 2
         49        ADD_ARRAY_ELEMENT                                ~40     ~41
         50      > RETURN                                                   ~40
   31    51    >   ASSIGN                                                   !7, null
   32    52        INIT_FCALL                                               'preg_match'
         53        SEND_VAL                                                 '%2F%28.%7B1%2C2%7D%29%5CsLSHIFT%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         54        SEND_VAR                                                 !0
         55        SEND_REF                                                 !7
         56        DO_ICALL                                         $43     
         57        ASSIGN                                                   !8, $43
   33    58        COUNT                                            ~45     !7
         59        IS_SMALLER                                               0, ~45
         60      > JMPZ                                                     ~46, ->68
   34    61    >   FETCH_DIM_R                                      ~47     !7, 1
         62        FETCH_DIM_R                                      ~48     !7, 2
         63        SL                                               ~49     ~47, ~48
         64        INIT_ARRAY                                       ~50     ~49
         65        FETCH_DIM_R                                      ~51     !7, 3
         66        ADD_ARRAY_ELEMENT                                ~50     ~51
         67      > RETURN                                                   ~50
   36    68    >   ASSIGN                                                   !9, null
   37    69        INIT_FCALL                                               'preg_match'
         70        SEND_VAL                                                 '%2F%28.%7B1%2C2%7D%29%5CsRSHIFT%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         71        SEND_VAR                                                 !0
         72        SEND_REF                                                 !9
         73        DO_ICALL                                         $53     
         74        ASSIGN                                                   !10, $53
   38    75        COUNT                                            ~55     !9
         76        IS_SMALLER                                               0, ~55
         77      > JMPZ                                                     ~56, ->85
   39    78    >   FETCH_DIM_R                                      ~57     !9, 1
         79        FETCH_DIM_R                                      ~58     !9, 2
         80        SR                                               ~59     ~57, ~58
         81        INIT_ARRAY                                       ~60     ~59
         82        FETCH_DIM_R                                      ~61     !9, 3
         83        ADD_ARRAY_ELEMENT                                ~60     ~61
         84      > RETURN                                                   ~60
   42    85    >   ASSIGN                                                   !11, null
   43    86        INIT_FCALL                                               'preg_match'
         87        SEND_VAL                                                 '%2F%28.%7B1%2C5%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         88        SEND_VAR                                                 !0
         89        SEND_REF                                                 !11
         90        DO_ICALL                                         $63     
         91        ASSIGN                                                   !12, $63
   44    92        COUNT                                            ~65     !11
         93        IS_SMALLER                                               0, ~65
         94      > JMPZ                                                     ~66, ->100
   45    95    >   FETCH_DIM_R                                      ~67     !11, 1
         96        INIT_ARRAY                                       ~68     ~67
         97        FETCH_DIM_R                                      ~69     !11, 2
         98        ADD_ARRAY_ELEMENT                                ~68     ~69
         99      > RETURN                                                   ~68
   47   100    > > RETURN                                                   null

End of function operation

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.22 ms | 1415 KiB | 21 Q