3v4l.org

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

End of function rpi_getrpirevision

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.87 ms | 1411 KiB | 24 Q