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 [1,$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 [2,$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 [3,$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 [4,$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 [5,$matchesright[1] , $matchesright[2], $matchesright[3]]; } $matches = null; $simple = preg_match("/(.{1,5})\s->\s(.{1,2})/",$s,$matches); if(count($matches)>0){ return [6,$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++){ $values = operation($inputs[$i]); //var_dump($values); if($values[0] === 1){ if(intval($values[1])>0) $array[$values[3]] = (int)$values[1] & $array[$values[2]]; else $array[$values[3]] = $array[$values[1]] & $array[$values[2]]; } if($values[0] === 2){ $array[$values[3]] = $array[$values[1]] | $array[$values[2]]; } if($values[0] === 3){ $array[$values[2]] = ~$array[$values[1]]; } if($values[0] === 4){ $array[$values[3]] = $array[$values[1]]<<intval($values[2]); } if($values[0] === 5){ $array[$values[3]] = $array[$values[1]]>>intval($values[2]); } if($values[0] === 6){ $array[$values[2]] = intval($values[1]); } //$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 = 109
Branch analysis from position: 109
2 jumps found. (Code = 44) Position 1 = 112, Position 2 = 29
Branch analysis from position: 112
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 58
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 50
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 69
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 78
Branch analysis from position: 72
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 89
Branch analysis from position: 81
2 jumps found. (Code = 43) Position 1 = 92, Position 2 = 100
Branch analysis from position: 92
2 jumps found. (Code = 43) Position 1 = 103, Position 2 = 108
Branch analysis from position: 103
2 jumps found. (Code = 44) Position 1 = 112, Position 2 = 29
Branch analysis from position: 112
Branch analysis from position: 29
Branch analysis from position: 108
Branch analysis from position: 100
Branch analysis from position: 89
Branch analysis from position: 78
Branch analysis from position: 69
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 69
Branch analysis from position: 61
Branch analysis from position: 69
Branch analysis from position: 58
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/qulhE
function name:  (null)
number of ops:  116
compiled vars:  !0 = $input, !1 = $inputs, !2 = $array, !3 = $i, !4 = $j, !5 = $values
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                                         $7      
          5        ASSIGN                                                   !1, $7
   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                                                    ~13, ->9
   52    14    >   ASSIGN                                                   !3, 'a'
         15      > JMP                                                      ->25
   53    16    >   ASSIGN                                                   !4, 'a'
         17      > JMP                                                      ->22
   54    18    >   CONCAT                                           ~16     !3, !4
         19        ASSIGN_DIM                                               !2, ~16
         20        OP_DATA                                                  0
   53    21        PRE_INC                                                  !4
         22    >   IS_SMALLER                                               !4, 'z'
         23      > JMPNZ                                                    ~19, ->18
   52    24    >   PRE_INC                                                  !3
         25    >   IS_SMALLER                                               !3, 'z'
         26      > JMPNZ                                                    ~21, ->16
   57    27    >   ASSIGN                                                   !3, 0
         28      > JMP                                                      ->109
   58    29    >   INIT_FCALL                                               'operation'
         30        FETCH_DIM_R                                      ~23     !1, !3
         31        SEND_VAL                                                 ~23
         32        DO_FCALL                                      0  $24     
         33        ASSIGN                                                   !5, $24
   60    34        FETCH_DIM_R                                      ~26     !5, 0
         35        IS_IDENTICAL                                             ~26, 1
         36      > JMPZ                                                     ~27, ->58
   61    37    >   FETCH_DIM_R                                      ~28     !5, 1
         38        CAST                                          4  ~29     ~28
         39        IS_SMALLER                                               0, ~29
         40      > JMPZ                                                     ~30, ->50
   62    41    >   FETCH_DIM_R                                      ~31     !5, 3
         42        FETCH_DIM_R                                      ~33     !5, 1
         43        CAST                                          4  ~34     ~33
         44        FETCH_DIM_R                                      ~35     !5, 2
         45        FETCH_DIM_R                                      ~36     !2, ~35
         46        BW_AND                                           ~37     ~34, ~36
         47        ASSIGN_DIM                                               !2, ~31
         48        OP_DATA                                                  ~37
         49      > JMP                                                      ->58
   64    50    >   FETCH_DIM_R                                      ~38     !5, 3
         51        FETCH_DIM_R                                      ~40     !5, 1
         52        FETCH_DIM_R                                      ~41     !2, ~40
         53        FETCH_DIM_R                                      ~42     !5, 2
         54        FETCH_DIM_R                                      ~43     !2, ~42
         55        BW_AND                                           ~44     ~41, ~43
         56        ASSIGN_DIM                                               !2, ~38
         57        OP_DATA                                                  ~44
   67    58    >   FETCH_DIM_R                                      ~45     !5, 0
         59        IS_IDENTICAL                                             ~45, 2
         60      > JMPZ                                                     ~46, ->69
   68    61    >   FETCH_DIM_R                                      ~47     !5, 3
         62        FETCH_DIM_R                                      ~49     !5, 1
         63        FETCH_DIM_R                                      ~50     !2, ~49
         64        FETCH_DIM_R                                      ~51     !5, 2
         65        FETCH_DIM_R                                      ~52     !2, ~51
         66        BW_OR                                            ~53     ~50, ~52
         67        ASSIGN_DIM                                               !2, ~47
         68        OP_DATA                                                  ~53
   70    69    >   FETCH_DIM_R                                      ~54     !5, 0
         70        IS_IDENTICAL                                             ~54, 3
         71      > JMPZ                                                     ~55, ->78
   71    72    >   FETCH_DIM_R                                      ~56     !5, 2
         73        FETCH_DIM_R                                      ~58     !5, 1
         74        FETCH_DIM_R                                      ~59     !2, ~58
         75        BW_NOT                                           ~60     ~59
         76        ASSIGN_DIM                                               !2, ~56
         77        OP_DATA                                                  ~60
   73    78    >   FETCH_DIM_R                                      ~61     !5, 0
         79        IS_IDENTICAL                                             ~61, 4
         80      > JMPZ                                                     ~62, ->89
   74    81    >   FETCH_DIM_R                                      ~63     !5, 3
         82        FETCH_DIM_R                                      ~65     !5, 1
         83        FETCH_DIM_R                                      ~66     !2, ~65
         84        FETCH_DIM_R                                      ~67     !5, 2
         85        CAST                                          4  ~68     ~67
         86        SL                                               ~69     ~66, ~68
         87        ASSIGN_DIM                                               !2, ~63
         88        OP_DATA                                                  ~69
   76    89    >   FETCH_DIM_R                                      ~70     !5, 0
         90        IS_IDENTICAL                                             ~70, 5
         91      > JMPZ                                                     ~71, ->100
   77    92    >   FETCH_DIM_R                                      ~72     !5, 3
         93        FETCH_DIM_R                                      ~74     !5, 1
         94        FETCH_DIM_R                                      ~75     !2, ~74
         95        FETCH_DIM_R                                      ~76     !5, 2
         96        CAST                                          4  ~77     ~76
         97        SR                                               ~78     ~75, ~77
         98        ASSIGN_DIM                                               !2, ~72
         99        OP_DATA                                                  ~78
   79   100    >   FETCH_DIM_R                                      ~79     !5, 0
        101        IS_IDENTICAL                                             ~79, 6
        102      > JMPZ                                                     ~80, ->108
   80   103    >   FETCH_DIM_R                                      ~81     !5, 2
        104        FETCH_DIM_R                                      ~83     !5, 1
        105        CAST                                          4  ~84     ~83
        106        ASSIGN_DIM                                               !2, ~81
        107        OP_DATA                                                  ~84
   57   108    >   PRE_INC                                                  !3
        109    >   COUNT                                            ~86     !1
        110        IS_SMALLER                                               !3, ~86
        111      > JMPNZ                                                    ~87, ->29
   85   112    >   INIT_FCALL                                               'var_dump'
        113        SEND_VAR                                                 !2
        114        DO_ICALL                                                 
   86   115      > RETURN                                                   1

Function operation:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 37
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 53
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 71
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 89
Branch analysis from position: 81
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 89
2 jumps found. (Code = 43) Position 1 = 99, Position 2 = 105
Branch analysis from position: 99
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 105
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qulhE
function name:  operation
number of ops:  106
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, ->19
   16    11    >   INIT_ARRAY                                       ~18     1
         12        FETCH_DIM_R                                      ~19     !1, 1
         13        ADD_ARRAY_ELEMENT                                ~18     ~19
         14        FETCH_DIM_R                                      ~20     !1, 2
         15        ADD_ARRAY_ELEMENT                                ~18     ~20
         16        FETCH_DIM_R                                      ~21     !1, 3
         17        ADD_ARRAY_ELEMENT                                ~18     ~21
         18      > RETURN                                                   ~18
   19    19    >   ASSIGN                                                   !3, null
   20    20        INIT_FCALL                                               'preg_match'
         21        SEND_VAL                                                 '%2F%28.%7B1%2C2%7D%29%5CsOR%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         22        SEND_VAR                                                 !0
         23        SEND_REF                                                 !3
         24        DO_ICALL                                         $23     
         25        ASSIGN                                                   !4, $23
   21    26        COUNT                                            ~25     !3
         27        IS_SMALLER                                               0, ~25
         28      > JMPZ                                                     ~26, ->37
   22    29    >   INIT_ARRAY                                       ~27     2
         30        FETCH_DIM_R                                      ~28     !3, 1
         31        ADD_ARRAY_ELEMENT                                ~27     ~28
         32        FETCH_DIM_R                                      ~29     !3, 2
         33        ADD_ARRAY_ELEMENT                                ~27     ~29
         34        FETCH_DIM_R                                      ~30     !3, 3
         35        ADD_ARRAY_ELEMENT                                ~27     ~30
         36      > RETURN                                                   ~27
   25    37    >   ASSIGN                                                   !5, null
   26    38        INIT_FCALL                                               'preg_match'
         39        SEND_VAL                                                 '%2FNOT%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         40        SEND_VAR                                                 !0
         41        SEND_REF                                                 !5
         42        DO_ICALL                                         $32     
         43        ASSIGN                                                   !6, $32
   27    44        COUNT                                            ~34     !5
         45        IS_SMALLER                                               0, ~34
         46      > JMPZ                                                     ~35, ->53
   28    47    >   INIT_ARRAY                                       ~36     3
         48        FETCH_DIM_R                                      ~37     !5, 1
         49        ADD_ARRAY_ELEMENT                                ~36     ~37
         50        FETCH_DIM_R                                      ~38     !5, 2
         51        ADD_ARRAY_ELEMENT                                ~36     ~38
         52      > RETURN                                                   ~36
   31    53    >   ASSIGN                                                   !7, null
   32    54        INIT_FCALL                                               'preg_match'
         55        SEND_VAL                                                 '%2F%28.%7B1%2C2%7D%29%5CsLSHIFT%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         56        SEND_VAR                                                 !0
         57        SEND_REF                                                 !7
         58        DO_ICALL                                         $40     
         59        ASSIGN                                                   !8, $40
   33    60        COUNT                                            ~42     !7
         61        IS_SMALLER                                               0, ~42
         62      > JMPZ                                                     ~43, ->71
   34    63    >   INIT_ARRAY                                       ~44     4
         64        FETCH_DIM_R                                      ~45     !7, 1
         65        ADD_ARRAY_ELEMENT                                ~44     ~45
         66        FETCH_DIM_R                                      ~46     !7, 2
         67        ADD_ARRAY_ELEMENT                                ~44     ~46
         68        FETCH_DIM_R                                      ~47     !7, 3
         69        ADD_ARRAY_ELEMENT                                ~44     ~47
         70      > RETURN                                                   ~44
   36    71    >   ASSIGN                                                   !9, null
   37    72        INIT_FCALL                                               'preg_match'
         73        SEND_VAL                                                 '%2F%28.%7B1%2C2%7D%29%5CsRSHIFT%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         74        SEND_VAR                                                 !0
         75        SEND_REF                                                 !9
         76        DO_ICALL                                         $49     
         77        ASSIGN                                                   !10, $49
   38    78        COUNT                                            ~51     !9
         79        IS_SMALLER                                               0, ~51
         80      > JMPZ                                                     ~52, ->89
   39    81    >   INIT_ARRAY                                       ~53     5
         82        FETCH_DIM_R                                      ~54     !9, 1
         83        ADD_ARRAY_ELEMENT                                ~53     ~54
         84        FETCH_DIM_R                                      ~55     !9, 2
         85        ADD_ARRAY_ELEMENT                                ~53     ~55
         86        FETCH_DIM_R                                      ~56     !9, 3
         87        ADD_ARRAY_ELEMENT                                ~53     ~56
         88      > RETURN                                                   ~53
   42    89    >   ASSIGN                                                   !11, null
   43    90        INIT_FCALL                                               'preg_match'
         91        SEND_VAL                                                 '%2F%28.%7B1%2C5%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         92        SEND_VAR                                                 !0
         93        SEND_REF                                                 !11
         94        DO_ICALL                                         $58     
         95        ASSIGN                                                   !12, $58
   44    96        COUNT                                            ~60     !11
         97        IS_SMALLER                                               0, ~60
         98      > JMPZ                                                     ~61, ->105
   45    99    >   INIT_ARRAY                                       ~62     6
        100        FETCH_DIM_R                                      ~63     !11, 1
        101        ADD_ARRAY_ELEMENT                                ~62     ~63
        102        FETCH_DIM_R                                      ~64     !11, 2
        103        ADD_ARRAY_ELEMENT                                ~62     ~64
        104      > RETURN                                                   ~62
   47   105    > > RETURN                                                   null

End of function operation

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.99 ms | 1419 KiB | 20 Q