3v4l.org

run code in 300+ PHP versions simultaneously
<?php function rpi_getRpiRevision($match) { $revision = array(); $revision[2] = array('revision' => '0002', 'model' => 'B', 'pcb' => '1.0', 'memory' => 256, 'manufacturer' => ''); $revision[3] = array('revision' => '0003', 'model' => 'B', 'pcb' => '1.0', 'memory' => 256, 'manufacturer' => ''); $revision[4] = array('revision' => '0004', 'model' => 'B', 'pcb' => '2.0', 'memory' => 256, 'manufacturer' => 'Sony'); $revision[5] = array('revision' => '0005', 'model' => 'B', 'pcb' => '2.0', 'memory' => 256, 'manufacturer' => 'Qisda'); $revision[6] = array('revision' => '0006', 'model' => 'B', 'pcb' => '2.0', 'memory' => 256, 'manufacturer' => 'Egoman'); $revision[7] = array('revision' => '0007', 'model' => 'A', 'pcb' => '2.0', 'memory' => 256, 'manufacturer' => 'Egoman'); $revision[8] = array('revision' => '0008', 'model' => 'A', 'pcb' => '2.0', 'memory' => 256, 'manufacturer' => 'Sony'); $revision[9] = array('revision' => '0009', 'model' => 'A', 'pcb' => '2.0', 'memory' => 256, 'manufacturer' => 'Qisda'); $revision[13] = array('revision' => '000d', 'model' => 'B', 'pcb' => '2.0', 'memory' => 512, 'manufacturer' => 'Egoman'); $revision[14] = array('revision' => '000e', 'model' => 'B', 'pcb' => '2.0', 'memory' => 512, 'manufacturer' => 'Sony'); $revision[15] = array('revision' => '000f', 'model' => 'B', 'pcb' => '2.0', 'memory' => 512, 'manufacturer' => 'Qisda'); $revision[16] = array('revision' => '0010', 'model' => 'B+', 'pcb' => '1.0', 'memory' => 512, 'manufacturer' => 'Sony'); $revision[17] = array('revision' => '0011', 'model' => 'Compute Module', 'pcb' => '1.0', 'memory' => 512, 'manufacturer' => 'Sony'); $revision[18] = array('revision' => '0012', 'model' => 'A+', 'pcb' => '1.0', 'memory' => 256, 'manufacturer' => 'Sony'); $revision[19] = array('revision' => '0013', 'model' => 'B+', 'pcb' => '1.2', 'memory' => 512, 'manufacturer' => 'Embest'); $revision[20] = array('revision' => '0014', 'model' => 'Compute Module', 'pcb' => '1.0', 'memory' => 512, 'manufacturer' => 'Embest'); $revision[21] = array('revision' => '0015', 'model' => 'A+', 'pcb' => '1.1', 'memory' => 256, 'manufacturer' => 'Embest'); $revision_model = array(0 => 'A', 1 => 'B', 2 => 'A+', 3 => 'B+', 4 => 'Pi 2 B', 5 => 'Alpha', 6 => 'Compute Module', 7 => 'Zero', 8 => 'Pi 3 B', 9 => 'Zero', 10 => 'Compute Module 3'); $revision_memory = array(0 => 256, 1 => 512, 2 => 1024); $revision_manufacturer = array(0 => 'Sony', 1 => 'Egoman', 2 => 'Embest', 3 => 'Sony Japan', 4 => 'Embest'); /* * ###### * |||||+- PCB * ||||+- Model * |||+- Model * ||+- Unknown * |+- Manufacturer * +- Memory */ if (isset($match[1])) { if ($match[1][0] == '1' || $match[1][0] == '2') $match[1] = substr($match[1], 1); if (strlen($match[1]) == 4) return $revision[hexdec($match[1])]; elseif (strlen($match[1]) == 6 && $match[1][0] != 'a' && $match[1][0] != '9') return $revision[hexdec(substr($match[1], -4))]; elseif (strlen($match[1]) == 6) { return array('revision' => $match[1], 'model' => $revision_model[hexdec(substr($match[1], 3, 2))], 'pcb' => '1.'.hexdec(substr($match[1], -1)), 'memory' => $revision_memory[bindec(substr(decbin(hexdec(substr($match[1], 0, 1))), 1))], 'manufacturer' => $revision_manufacturer[hexdec(substr($match[1], 1, 1))]); } } return NULL; } var_dump(rpi_getRpiRevision('a020a0'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l0bMp
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'rpi_getrpirevision'
          2        SEND_VAL                                                 'a020a0'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function rpi_getrpirevision:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 153
Branch analysis from position: 41
2 jumps found. (Code = 47) Position 1 = 45, Position 2 = 49
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 57
Branch analysis from position: 50
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 = 46) Position 1 = 72, Position 2 = 76
Branch analysis from position: 72
2 jumps found. (Code = 46) Position 1 = 77, Position 2 = 81
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 82, Position 2 = 93
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 93
2 jumps found. (Code = 43) Position 1 = 97, Position 2 = 153
Branch analysis from position: 97
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 153
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 81
Branch analysis from position: 76
Branch analysis from position: 57
Branch analysis from position: 49
Branch analysis from position: 153
filename:       /in/l0bMp
function name:  rpi_getRpiRevision
number of ops:  155
compiled vars:  !0 = $match, !1 = $revision, !2 = $revision_model, !3 = $revision_memory, !4 = $revision_manufacturer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN_DIM                                               !1, 2
          3        OP_DATA                                                  <array>
    7     4        ASSIGN_DIM                                               !1, 3
          5        OP_DATA                                                  <array>
    8     6        ASSIGN_DIM                                               !1, 4
          7        OP_DATA                                                  <array>
    9     8        ASSIGN_DIM                                               !1, 5
          9        OP_DATA                                                  <array>
   10    10        ASSIGN_DIM                                               !1, 6
         11        OP_DATA                                                  <array>
   11    12        ASSIGN_DIM                                               !1, 7
         13        OP_DATA                                                  <array>
   12    14        ASSIGN_DIM                                               !1, 8
         15        OP_DATA                                                  <array>
   13    16        ASSIGN_DIM                                               !1, 9
         17        OP_DATA                                                  <array>
   14    18        ASSIGN_DIM                                               !1, 13
         19        OP_DATA                                                  <array>
   15    20        ASSIGN_DIM                                               !1, 14
         21        OP_DATA                                                  <array>
   16    22        ASSIGN_DIM                                               !1, 15
         23        OP_DATA                                                  <array>
   17    24        ASSIGN_DIM                                               !1, 16
         25        OP_DATA                                                  <array>
   18    26        ASSIGN_DIM                                               !1, 17
         27        OP_DATA                                                  <array>
   19    28        ASSIGN_DIM                                               !1, 18
         29        OP_DATA                                                  <array>
   20    30        ASSIGN_DIM                                               !1, 19
         31        OP_DATA                                                  <array>
   21    32        ASSIGN_DIM                                               !1, 20
         33        OP_DATA                                                  <array>
   22    34        ASSIGN_DIM                                               !1, 21
         35        OP_DATA                                                  <array>
   24    36        ASSIGN                                                   !2, <array>
   25    37        ASSIGN                                                   !3, <array>
   26    38        ASSIGN                                                   !4, <array>
   40    39        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 1
         40      > JMPZ                                                     ~26, ->153
   42    41    >   FETCH_DIM_R                                      ~27     !0, 1
         42        FETCH_DIM_R                                      ~28     ~27, 0
         43        IS_EQUAL                                         ~29     ~28, '1'
         44      > JMPNZ_EX                                         ~29     ~29, ->49
         45    >   FETCH_DIM_R                                      ~30     !0, 1
         46        FETCH_DIM_R                                      ~31     ~30, 0
         47        IS_EQUAL                                         ~32     ~31, '2'
         48        BOOL                                             ~29     ~32
         49    > > JMPZ                                                     ~29, ->57
   43    50    >   INIT_FCALL                                               'substr'
         51        FETCH_DIM_R                                      ~34     !0, 1
         52        SEND_VAL                                                 ~34
         53        SEND_VAL                                                 1
         54        DO_ICALL                                         $35     
         55        ASSIGN_DIM                                               !0, 1
         56        OP_DATA                                                  $35
   45    57    >   FETCH_DIM_R                                      ~36     !0, 1
         58        STRLEN                                           ~37     ~36
         59        IS_EQUAL                                                 ~37, 4
         60      > JMPZ                                                     ~38, ->68
   46    61    >   INIT_FCALL                                               'hexdec'
         62        FETCH_DIM_R                                      ~39     !0, 1
         63        SEND_VAL                                                 ~39
         64        DO_ICALL                                         $40     
         65        FETCH_DIM_R                                      ~41     !1, $40
         66      > RETURN                                                   ~41
         67*       JMP                                                      ->153
   47    68    >   FETCH_DIM_R                                      ~42     !0, 1
         69        STRLEN                                           ~43     ~42
         70        IS_EQUAL                                         ~44     ~43, 6
         71      > JMPZ_EX                                          ~44     ~44, ->76
         72    >   FETCH_DIM_R                                      ~45     !0, 1
         73        FETCH_DIM_R                                      ~46     ~45, 0
         74        IS_NOT_EQUAL                                     ~47     ~46, 'a'
         75        BOOL                                             ~44     ~47
         76    > > JMPZ_EX                                          ~44     ~44, ->81
         77    >   FETCH_DIM_R                                      ~48     !0, 1
         78        FETCH_DIM_R                                      ~49     ~48, 0
         79        IS_NOT_EQUAL                                     ~50     ~49, '9'
         80        BOOL                                             ~44     ~50
         81    > > JMPZ                                                     ~44, ->93
   48    82    >   INIT_FCALL                                               'hexdec'
         83        INIT_FCALL                                               'substr'
         84        FETCH_DIM_R                                      ~51     !0, 1
         85        SEND_VAL                                                 ~51
         86        SEND_VAL                                                 -4
         87        DO_ICALL                                         $52     
         88        SEND_VAR                                                 $52
         89        DO_ICALL                                         $53     
         90        FETCH_DIM_R                                      ~54     !1, $53
         91      > RETURN                                                   ~54
         92*       JMP                                                      ->153
   49    93    >   FETCH_DIM_R                                      ~55     !0, 1
         94        STRLEN                                           ~56     ~55
         95        IS_EQUAL                                                 ~56, 6
         96      > JMPZ                                                     ~57, ->153
   51    97    >   FETCH_DIM_R                                      ~58     !0, 1
         98        INIT_ARRAY                                       ~59     ~58, 'revision'
   52    99        INIT_FCALL                                               'hexdec'
        100        INIT_FCALL                                               'substr'
        101        FETCH_DIM_R                                      ~60     !0, 1
        102        SEND_VAL                                                 ~60
        103        SEND_VAL                                                 3
        104        SEND_VAL                                                 2
        105        DO_ICALL                                         $61     
        106        SEND_VAR                                                 $61
        107        DO_ICALL                                         $62     
        108        FETCH_DIM_R                                      ~63     !2, $62
        109        ADD_ARRAY_ELEMENT                                ~59     ~63, 'model'
   53   110        INIT_FCALL                                               'hexdec'
        111        INIT_FCALL                                               'substr'
        112        FETCH_DIM_R                                      ~64     !0, 1
        113        SEND_VAL                                                 ~64
        114        SEND_VAL                                                 -1
        115        DO_ICALL                                         $65     
        116        SEND_VAR                                                 $65
        117        DO_ICALL                                         $66     
        118        CONCAT                                           ~67     '1.', $66
        119        ADD_ARRAY_ELEMENT                                ~59     ~67, 'pcb'
   54   120        INIT_FCALL                                               'bindec'
        121        INIT_FCALL                                               'substr'
        122        INIT_FCALL                                               'decbin'
        123        INIT_FCALL                                               'hexdec'
        124        INIT_FCALL                                               'substr'
        125        FETCH_DIM_R                                      ~68     !0, 1
        126        SEND_VAL                                                 ~68
        127        SEND_VAL                                                 0
        128        SEND_VAL                                                 1
        129        DO_ICALL                                         $69     
        130        SEND_VAR                                                 $69
        131        DO_ICALL                                         $70     
        132        SEND_VAR                                                 $70
        133        DO_ICALL                                         $71     
        134        SEND_VAR                                                 $71
        135        SEND_VAL                                                 1
        136        DO_ICALL                                         $72     
        137        SEND_VAR                                                 $72
        138        DO_ICALL                                         $73     
        139        FETCH_DIM_R                                      ~74     !3, $73
        140        ADD_ARRAY_ELEMENT                                ~59     ~74, 'memory'
   55   141        INIT_FCALL                                               'hexdec'
        142        INIT_FCALL                                               'substr'
        143        FETCH_DIM_R                                      ~75     !0, 1
        144        SEND_VAL                                                 ~75
        145        SEND_VAL                                                 1
        146        SEND_VAL                                                 1
        147        DO_ICALL                                         $76     
        148        SEND_VAR                                                 $76
        149        DO_ICALL                                         $77     
        150        FETCH_DIM_R                                      ~78     !4, $77
        151        ADD_ARRAY_ELEMENT                                ~59     ~78, 'manufacturer'
        152      > RETURN                                                   ~59
   59   153    > > RETURN                                                   null
   60   154*     > RETURN                                                   null

End of function rpi_getrpirevision

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.89 ms | 1411 KiB | 24 Q