3v4l.org

run code in 300+ PHP versions simultaneously
<?php class WebASM { private $_input; private $_val; private $_0 = 0; private $_1 = 0; private $_2 = 0; private $_3 = 0; private $_4 = 0; private $_5 = 0; private $_6 = 0; private $_7 = 0; public function __construct($code) { $this->_0 = $code; unset($code); if(!is_string($this->_0)) { $this->_0 = 0; return 1; } if(preg_match('#^file\:#', $this->_0)) { $this->_0 = preg_replace('#^file\:#', '', $this->_0); if(file_exists($this->_0)) { $this->_0 = file_get_contents($this->_0); } else { $this->_0 = 0; return 1; } } $this->_0 = preg_replace_callback('#(.*):#', function ($matches) { if(is_numeric($matches[1])) { return 'a'.$matches[0]; } else { return '//'.$matches[0]; } }, $this->_0); $this->_0 = preg_replace('#pri?nt (.*)#', 'echo(\$this->_$1);', $this->_0); $this->_0 = preg_replace('#set ([0-7]) ([0-9]{1,256})#U', '\$this->_$1 = $2;', $this->_0); $this->_0 = preg_replace('#copyto ([0-7])#', '\$this->_$1 = \$this->_val;', $this->_0); $this->_0 = preg_replace('#copyfrom ([0-7])#', '\$this->_val = \$this->_$1;', $this->_0); //$this->_0 = preg_replace('#pro?mpt (str|int) ([0-9]{256})#', 'echo($1);', $this->_0); $this->_0 = preg_replace('#add ([0-7])#', '\$this->_val = \$this->_val + \$this->_$1;', $this->_0); $this->_0 = preg_replace('#sub ([0-7])#', '\$this->_val = \$this->_val - \$this->_$1;', $this->_0); $this->_0 = preg_replace('#jump ([0-9]{1,256}) if ([0-7]) ([0-9]{1,256})#', 'if(\$this->_$2 == $3) goto a$1;', $this->_0); $this->_0 = preg_replace('#jump ([0-9]{1,256}) if ([0-9]{1,256})#', 'if(\$this->_val == $2) goto a$1;', $this->_0); $this->_0 = preg_replace('#jump ([0-9]{1,256})#', 'goto a$1;', $this->_0); $this->_0 = preg_replace('#(die|re?tu?rn|exit)#', 'return 0;', $this->_0); $this->_0 = '$c = function () {'.$this->_0.'return 1;};$x=$c();if($x!=0)echo("An error has occured.");'; eval($this->_0); } } $code = <<<WebASM set 0 1 set 1 1 copyfrom 0 0: add 1 jump 1 if 3 jump 0 1: copyto 0 print 0 lol: print 1 WebASM; $asm = new WebASM($code);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ptomd
function name:  (null)
number of ops:  6
compiled vars:  !0 = $code, !1 = $asm
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   ASSIGN                                                   !0, 'set+0+1%0Aset+1+1%0Acopyfrom+0%0A0%3A%0Aadd+1%0Ajump+1+if+3%0Ajump+0%0A1%3A%0Acopyto+0%0Aprint+0%0Alol%3A%0Aprint+1'
   68     1        NEW                                              $3      'WebASM'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
          5      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fptomd%3A30%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ptomd
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        INIT_FCALL                                               'is_numeric'
          2        FETCH_DIM_R                                      ~1      !0, 1
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5      > JMPZ                                                     $2, ->10
   32     6    >   FETCH_DIM_R                                      ~3      !0, 0
          7        CONCAT                                           ~4      'a', ~3
          8      > RETURN                                                   ~4
          9*       JMP                                                      ->13
   35    10    >   FETCH_DIM_R                                      ~5      !0, 0
         11        CONCAT                                           ~6      '%2F%2F', ~5
         12      > RETURN                                                   ~6
   37    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fptomd%3A30%240

Class WebASM:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 40
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 37
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/ptomd
function name:  __construct
number of ops:  137
compiled vars:  !0 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        ASSIGN_OBJ                                               '_0'
          2        OP_DATA                                                  !0
   15     3        UNSET_CV                                                 !0
   16     4        FETCH_OBJ_R                                      ~2      '_0'
          5        TYPE_CHECK                                   64  ~3      ~2
          6        BOOL_NOT                                         ~4      ~3
          7      > JMPZ                                                     ~4, ->11
   17     8    >   ASSIGN_OBJ                                               '_0'
          9        OP_DATA                                                  0
   18    10      > RETURN                                                   1
   20    11    >   INIT_FCALL                                               'preg_match'
         12        SEND_VAL                                                 '%23%5Efile%5C%3A%23'
         13        FETCH_OBJ_R                                      ~6      '_0'
         14        SEND_VAL                                                 ~6
         15        DO_ICALL                                         $7      
         16      > JMPZ                                                     $7, ->40
   21    17    >   INIT_FCALL                                               'preg_replace'
         18        SEND_VAL                                                 '%23%5Efile%5C%3A%23'
         19        SEND_VAL                                                 ''
         20        FETCH_OBJ_R                                      ~9      '_0'
         21        SEND_VAL                                                 ~9
         22        DO_ICALL                                         $10     
         23        ASSIGN_OBJ                                               '_0'
         24        OP_DATA                                                  $10
   22    25        INIT_FCALL                                               'file_exists'
         26        FETCH_OBJ_R                                      ~11     '_0'
         27        SEND_VAL                                                 ~11
         28        DO_ICALL                                         $12     
         29      > JMPZ                                                     $12, ->37
   23    30    >   INIT_FCALL                                               'file_get_contents'
         31        FETCH_OBJ_R                                      ~14     '_0'
         32        SEND_VAL                                                 ~14
         33        DO_ICALL                                         $15     
         34        ASSIGN_OBJ                                               '_0'
         35        OP_DATA                                                  $15
         36      > JMP                                                      ->40
   26    37    >   ASSIGN_OBJ                                               '_0'
         38        OP_DATA                                                  0
   27    39      > RETURN                                                   1
   30    40    >   INIT_FCALL                                               'preg_replace_callback'
         41        SEND_VAL                                                 '%23%28.%2A%29%3A%23'
         42        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fptomd%3A30%240'
   37    43        SEND_VAL                                                 ~18
         44        FETCH_OBJ_R                                      ~19     '_0'
         45        SEND_VAL                                                 ~19
         46        DO_ICALL                                         $20     
   30    47        ASSIGN_OBJ                                               '_0'
   37    48        OP_DATA                                                  $20
   38    49        INIT_FCALL                                               'preg_replace'
         50        SEND_VAL                                                 '%23pri%3Fnt+%28.%2A%29%23'
         51        SEND_VAL                                                 'echo%28%5C%24this-%3E_%241%29%3B'
         52        FETCH_OBJ_R                                      ~22     '_0'
         53        SEND_VAL                                                 ~22
         54        DO_ICALL                                         $23     
         55        ASSIGN_OBJ                                               '_0'
         56        OP_DATA                                                  $23
   39    57        INIT_FCALL                                               'preg_replace'
         58        SEND_VAL                                                 '%23set+%28%5B0-7%5D%29+%28%5B0-9%5D%7B1%2C256%7D%29%23U'
         59        SEND_VAL                                                 '%5C%24this-%3E_%241+%3D+%242%3B'
         60        FETCH_OBJ_R                                      ~25     '_0'
         61        SEND_VAL                                                 ~25
         62        DO_ICALL                                         $26     
         63        ASSIGN_OBJ                                               '_0'
         64        OP_DATA                                                  $26
   40    65        INIT_FCALL                                               'preg_replace'
         66        SEND_VAL                                                 '%23copyto+%28%5B0-7%5D%29%23'
         67        SEND_VAL                                                 '%5C%24this-%3E_%241+%3D+%5C%24this-%3E_val%3B'
         68        FETCH_OBJ_R                                      ~28     '_0'
         69        SEND_VAL                                                 ~28
         70        DO_ICALL                                         $29     
         71        ASSIGN_OBJ                                               '_0'
         72        OP_DATA                                                  $29
   41    73        INIT_FCALL                                               'preg_replace'
         74        SEND_VAL                                                 '%23copyfrom+%28%5B0-7%5D%29%23'
         75        SEND_VAL                                                 '%5C%24this-%3E_val+%3D+%5C%24this-%3E_%241%3B'
         76        FETCH_OBJ_R                                      ~31     '_0'
         77        SEND_VAL                                                 ~31
         78        DO_ICALL                                         $32     
         79        ASSIGN_OBJ                                               '_0'
         80        OP_DATA                                                  $32
   43    81        INIT_FCALL                                               'preg_replace'
         82        SEND_VAL                                                 '%23add+%28%5B0-7%5D%29%23'
         83        SEND_VAL                                                 '%5C%24this-%3E_val+%3D+%5C%24this-%3E_val+%2B+%5C%24this-%3E_%241%3B'
         84        FETCH_OBJ_R                                      ~34     '_0'
         85        SEND_VAL                                                 ~34
         86        DO_ICALL                                         $35     
         87        ASSIGN_OBJ                                               '_0'
         88        OP_DATA                                                  $35
   44    89        INIT_FCALL                                               'preg_replace'
         90        SEND_VAL                                                 '%23sub+%28%5B0-7%5D%29%23'
         91        SEND_VAL                                                 '%5C%24this-%3E_val+%3D+%5C%24this-%3E_val+-+%5C%24this-%3E_%241%3B'
         92        FETCH_OBJ_R                                      ~37     '_0'
         93        SEND_VAL                                                 ~37
         94        DO_ICALL                                         $38     
         95        ASSIGN_OBJ                                               '_0'
         96        OP_DATA                                                  $38
   45    97        INIT_FCALL                                               'preg_replace'
         98        SEND_VAL                                                 '%23jump+%28%5B0-9%5D%7B1%2C256%7D%29+if+%28%5B0-7%5D%29+%28%5B0-9%5D%7B1%2C256%7D%29%23'
         99        SEND_VAL                                                 'if%28%5C%24this-%3E_%242+%3D%3D+%243%29+goto+a%241%3B'
        100        FETCH_OBJ_R                                      ~40     '_0'
        101        SEND_VAL                                                 ~40
        102        DO_ICALL                                         $41     
        103        ASSIGN_OBJ                                               '_0'
        104        OP_DATA                                                  $41
   46   105        INIT_FCALL                                               'preg_replace'
        106        SEND_VAL                                                 '%23jump+%28%5B0-9%5D%7B1%2C256%7D%29+if+%28%5B0-9%5D%7B1%2C256%7D%29%23'
        107        SEND_VAL                                                 'if%28%5C%24this-%3E_val+%3D%3D+%242%29+goto+a%241%3B'
        108        FETCH_OBJ_R                                      ~43     '_0'
        109        SEND_VAL                                                 ~43
        110        DO_ICALL                                         $44     
        111        ASSIGN_OBJ                                               '_0'
        112        OP_DATA                                                  $44
   47   113        INIT_FCALL                                               'preg_replace'
        114        SEND_VAL                                                 '%23jump+%28%5B0-9%5D%7B1%2C256%7D%29%23'
        115        SEND_VAL                                                 'goto+a%241%3B'
        116        FETCH_OBJ_R                                      ~46     '_0'
        117        SEND_VAL                                                 ~46
        118        DO_ICALL                                         $47     
        119        ASSIGN_OBJ                                               '_0'
        120        OP_DATA                                                  $47
   48   121        INIT_FCALL                                               'preg_replace'
        122        SEND_VAL                                                 '%23%28die%7Cre%3Ftu%3Frn%7Cexit%29%23'
        123        SEND_VAL                                                 'return+0%3B'
        124        FETCH_OBJ_R                                      ~49     '_0'
        125        SEND_VAL                                                 ~49
        126        DO_ICALL                                         $50     
        127        ASSIGN_OBJ                                               '_0'
        128        OP_DATA                                                  $50
   49   129        FETCH_OBJ_R                                      ~52     '_0'
        130        CONCAT                                           ~53     '%24c+%3D+function+%28%29+%7B', ~52
        131        CONCAT                                           ~54     ~53, 'return+1%3B%7D%3B%24x%3D%24c%28%29%3Bif%28%24x%21%3D0%29echo%28%22An+error+has+occured.%22%29%3B'
        132        ASSIGN_OBJ                                               '_0'
        133        OP_DATA                                                  ~54
   50   134        FETCH_OBJ_R                                      ~55     '_0'
        135        INCLUDE_OR_EVAL                                          ~55, EVAL
   51   136      > RETURN                                                   null

End of function __construct

End of class WebASM.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.96 ms | 1408 KiB | 25 Q