3v4l.org

run code in 300+ PHP versions simultaneously
<?php function charclass($flag) { define('WARRIOR_OFFSET', 16); define('MAGE_OFFSET', 17); define('CLASS_MASK', ( 1 << WARRIOR_OFFSET ) | ( 1 << MAGE_OFFSET )); define('CF_GOD', 1 << 2); // may issue #god commands define('CF_PLAYER', 1 << 3); // is a player define('CF_STAFF', 1 << 4); // member of the staff define('CF_INVISIBLE', 1 << 5); // character is completely invisible define('CF_GENDER', 1 << 14 | 1 << 15); // Determine Gender define('CF_ARCH', 1 << 18); // is arch-XXX define('CF_LQMASTER', 1 << 52); // may host LQs $classMap = array( 0b00 => 'error', 0b01 => 'warrior', 0b10 => 'mage', 0b11 => 'seyan', ); $class = $flag & CLASS_MASK; $class = $class >> WARRIOR_OFFSET; $class_name = $classMap[$class]; $is_god = $flag & CF_GOD; $is_arch = $flag & CF_ARCH; $is_staff = $flag & CF_STAFF; if ($is_god) { print "Godly "; } if ($is_staff) { print "Staffer "; } if ($is_arch) { print "Arch "; } print "$class_name\n"; } function chargender($flag) { define('MALE_OFFSET', 14); define('FEMALE_OFFSET', 15); define('GENDER_MASK', ( 1 << MALE_OFFSET ) | ( 1 << FEMALE_OFFSET )); $classMap = array( 0b00 => 'error', 0b01 => 'Male', 0b10 => 'Female', 0b11 => 'error', ); $gender = $flag & GENDER_MASK; $gender = $gender >> MALE_OFFSET; $gender_name = $classMap[$gender]; print "$gender_name\n"; } echo chargender(475149); echo charclass(475149);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Wc4C
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   INIT_FCALL                                               'chargender'
          1        SEND_VAL                                                 475149
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   68     4        INIT_FCALL                                               'charclass'
          5        SEND_VAL                                                 475149
          6        DO_FCALL                                      0  $1      
          7        ECHO                                                     $1
          8      > RETURN                                                   1

Function charclass:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 66
Branch analysis from position: 65
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 68
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 69, Position 2 = 70
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
Branch analysis from position: 68
Branch analysis from position: 66
filename:       /in/2Wc4C
function name:  charclass
number of ops:  74
compiled vars:  !0 = $flag, !1 = $classMap, !2 = $class, !3 = $class_name, !4 = $is_god, !5 = $is_arch, !6 = $is_staff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'define'
          2        SEND_VAL                                                 'WARRIOR_OFFSET'
          3        SEND_VAL                                                 16
          4        DO_ICALL                                                 
    4     5        INIT_FCALL                                               'define'
          6        SEND_VAL                                                 'MAGE_OFFSET'
          7        SEND_VAL                                                 17
          8        DO_ICALL                                                 
    5     9        INIT_FCALL                                               'define'
         10        SEND_VAL                                                 'CLASS_MASK'
         11        FETCH_CONSTANT                                   ~9      'WARRIOR_OFFSET'
         12        SL                                               ~10     1, ~9
         13        FETCH_CONSTANT                                   ~11     'MAGE_OFFSET'
         14        SL                                               ~12     1, ~11
         15        BW_OR                                            ~13     ~10, ~12
         16        SEND_VAL                                                 ~13
         17        DO_ICALL                                                 
    6    18        INIT_FCALL                                               'define'
         19        SEND_VAL                                                 'CF_GOD'
         20        SEND_VAL                                                 4
         21        DO_ICALL                                                 
    7    22        INIT_FCALL                                               'define'
         23        SEND_VAL                                                 'CF_PLAYER'
         24        SEND_VAL                                                 8
         25        DO_ICALL                                                 
    8    26        INIT_FCALL                                               'define'
         27        SEND_VAL                                                 'CF_STAFF'
         28        SEND_VAL                                                 16
         29        DO_ICALL                                                 
    9    30        INIT_FCALL                                               'define'
         31        SEND_VAL                                                 'CF_INVISIBLE'
         32        SEND_VAL                                                 32
         33        DO_ICALL                                                 
   10    34        INIT_FCALL                                               'define'
         35        SEND_VAL                                                 'CF_GENDER'
         36        SEND_VAL                                                 49152
         37        DO_ICALL                                                 
   11    38        INIT_FCALL                                               'define'
         39        SEND_VAL                                                 'CF_ARCH'
         40        SEND_VAL                                                 262144
         41        DO_ICALL                                                 
   12    42        INIT_FCALL                                               'define'
         43        SEND_VAL                                                 'CF_LQMASTER'
         44        SEND_VAL                                                 4503599627370496
         45        DO_ICALL                                                 
   14    46        ASSIGN                                                   !1, <array>
   21    47        FETCH_CONSTANT                                   ~23     'CLASS_MASK'
         48        BW_AND                                           ~24     !0, ~23
         49        ASSIGN                                                   !2, ~24
   23    50        FETCH_CONSTANT                                   ~26     'WARRIOR_OFFSET'
         51        SR                                               ~27     !2, ~26
         52        ASSIGN                                                   !2, ~27
   25    53        FETCH_DIM_R                                      ~29     !1, !2
         54        ASSIGN                                                   !3, ~29
   26    55        FETCH_CONSTANT                                   ~31     'CF_GOD'
         56        BW_AND                                           ~32     !0, ~31
         57        ASSIGN                                                   !4, ~32
   27    58        FETCH_CONSTANT                                   ~34     'CF_ARCH'
         59        BW_AND                                           ~35     !0, ~34
         60        ASSIGN                                                   !5, ~35
   28    61        FETCH_CONSTANT                                   ~37     'CF_STAFF'
         62        BW_AND                                           ~38     !0, ~37
         63        ASSIGN                                                   !6, ~38
   29    64      > JMPZ                                                     !4, ->66
   31    65    >   ECHO                                                     'Godly+'
   33    66    > > JMPZ                                                     !6, ->68
   35    67    >   ECHO                                                     'Staffer+'
   37    68    > > JMPZ                                                     !5, ->70
   39    69    >   ECHO                                                     'Arch+'
   41    70    >   NOP                                                      
         71        FAST_CONCAT                                      ~40     !3, '%0A'
         72        ECHO                                                     ~40
   43    73      > RETURN                                                   null

End of function charclass

Function chargender:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Wc4C
function name:  chargender
number of ops:  31
compiled vars:  !0 = $flag, !1 = $classMap, !2 = $gender, !3 = $gender_name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
   47     1        INIT_FCALL                                               'define'
          2        SEND_VAL                                                 'MALE_OFFSET'
          3        SEND_VAL                                                 14
          4        DO_ICALL                                                 
   48     5        INIT_FCALL                                               'define'
          6        SEND_VAL                                                 'FEMALE_OFFSET'
          7        SEND_VAL                                                 15
          8        DO_ICALL                                                 
   49     9        INIT_FCALL                                               'define'
         10        SEND_VAL                                                 'GENDER_MASK'
         11        FETCH_CONSTANT                                   ~6      'MALE_OFFSET'
         12        SL                                               ~7      1, ~6
         13        FETCH_CONSTANT                                   ~8      'FEMALE_OFFSET'
         14        SL                                               ~9      1, ~8
         15        BW_OR                                            ~10     ~7, ~9
         16        SEND_VAL                                                 ~10
         17        DO_ICALL                                                 
   51    18        ASSIGN                                                   !1, <array>
   58    19        FETCH_CONSTANT                                   ~13     'GENDER_MASK'
         20        BW_AND                                           ~14     !0, ~13
         21        ASSIGN                                                   !2, ~14
   60    22        FETCH_CONSTANT                                   ~16     'MALE_OFFSET'
         23        SR                                               ~17     !2, ~16
         24        ASSIGN                                                   !2, ~17
   62    25        FETCH_DIM_R                                      ~19     !1, !2
         26        ASSIGN                                                   !3, ~19
   64    27        NOP                                                      
         28        FAST_CONCAT                                      ~21     !3, '%0A'
         29        ECHO                                                     ~21
   65    30      > RETURN                                                   null

End of function chargender

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.39 ms | 1407 KiB | 17 Q