3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * Fill in all five below and click blue 'eval();' button below textarea. * * ------------------ */ $caseNumber = -1; $unhashedServerSeed = ''; $nonce = -1; $clientSeed = ''; $qty = -1; /* ------------------ */ if ($caseNumber < 0 || $unhashedServerSeed == '' || $nonce < 0 || $clientSeed == '' || $qty < 0) { echo "Fill in details"; return; } $unhashedServerSeed = preg_replace( "/\r|\n/", "", $unhashedServerSeed ); $clientSeed = preg_replace( "/\r|\n/", "", $clientSeed ); function stringToInt32($seed) { $groups = str_split((string)$seed, 4); $groups = array_map(function ($g) { return unpack('C*', $g); }, $groups); $groups = array_filter($groups, function ($g) { return count($g) === 4; }); $result = array_map(function ($group) { return array_reduce($group, function ($acc, $cur) { return ($acc << 4) | $cur; }, 0); }, $groups); return array_reduce($result, function ($acc, $cur) { return ($acc ^ $cur); }, 0); } $serverSeedInt = stringToInt32($unhashedServerSeed); $clientSeedInt = stringToInt32($clientSeed); $seed = $serverSeedInt ^ $clientSeedInt ^ (int)$caseNumber ^ (int)$nonce; mt_srand($seed, MT_RAND_MT19937); $result = mt_rand(1, $qty); echo "Seed: $seed\n"; echo "Result: $result";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 47) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 47) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 15
Branch analysis from position: 12
Branch analysis from position: 9
filename:       /in/P9Qir
function name:  (null)
number of ops:  64
compiled vars:  !0 = $caseNumber, !1 = $unhashedServerSeed, !2 = $nonce, !3 = $clientSeed, !4 = $qty, !5 = $serverSeedInt, !6 = $clientSeedInt, !7 = $seed, !8 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, -1
    8     1        ASSIGN                                                   !1, ''
    9     2        ASSIGN                                                   !2, -1
   10     3        ASSIGN                                                   !3, ''
   11     4        ASSIGN                                                   !4, -1
   14     5        IS_SMALLER                                       ~14     !0, 0
          6      > JMPNZ_EX                                         ~14     ~14, ->9
          7    >   IS_EQUAL                                         ~15     !1, ''
          8        BOOL                                             ~14     ~15
          9    > > JMPNZ_EX                                         ~14     ~14, ->12
         10    >   IS_SMALLER                                       ~16     !2, 0
         11        BOOL                                             ~14     ~16
         12    > > JMPNZ_EX                                         ~14     ~14, ->15
         13    >   IS_EQUAL                                         ~17     !3, ''
         14        BOOL                                             ~14     ~17
         15    > > JMPNZ_EX                                         ~14     ~14, ->18
         16    >   IS_SMALLER                                       ~18     !4, 0
         17        BOOL                                             ~14     ~18
         18    > > JMPZ                                                     ~14, ->21
   15    19    >   ECHO                                                     'Fill+in+details'
   16    20      > RETURN                                                   null
   19    21    >   INIT_FCALL                                               'preg_replace'
         22        SEND_VAL                                                 '%2F%0D%7C%0A%2F'
         23        SEND_VAL                                                 ''
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $19     
         26        ASSIGN                                                   !1, $19
   20    27        INIT_FCALL                                               'preg_replace'
         28        SEND_VAL                                                 '%2F%0D%7C%0A%2F'
         29        SEND_VAL                                                 ''
         30        SEND_VAR                                                 !3
         31        DO_ICALL                                         $21     
         32        ASSIGN                                                   !3, $21
   44    33        INIT_FCALL                                               'stringtoint32'
         34        SEND_VAR                                                 !1
         35        DO_FCALL                                      0  $23     
         36        ASSIGN                                                   !5, $23
   45    37        INIT_FCALL                                               'stringtoint32'
         38        SEND_VAR                                                 !3
         39        DO_FCALL                                      0  $25     
         40        ASSIGN                                                   !6, $25
   46    41        BW_XOR                                           ~27     !5, !6
         42        CAST                                          4  ~28     !0
         43        BW_XOR                                           ~29     ~27, ~28
         44        CAST                                          4  ~30     !2
         45        BW_XOR                                           ~31     ~29, ~30
         46        ASSIGN                                                   !7, ~31
   47    47        INIT_FCALL                                               'mt_srand'
         48        SEND_VAR                                                 !7
         49        SEND_VAL                                                 0
         50        DO_ICALL                                                 
   49    51        INIT_FCALL                                               'mt_rand'
         52        SEND_VAL                                                 1
         53        SEND_VAR                                                 !4
         54        DO_ICALL                                         $34     
         55        ASSIGN                                                   !8, $34
   51    56        ROPE_INIT                                     3  ~37     'Seed%3A+'
         57        ROPE_ADD                                      1  ~37     ~37, !7
         58        ROPE_END                                      2  ~36     ~37, '%0A'
         59        ECHO                                                     ~36
   52    60        NOP                                                      
         61        FAST_CONCAT                                      ~39     'Result%3A+', !8
         62        ECHO                                                     ~39
         63      > RETURN                                                   1

Function stringtoint32:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P9Qir
function name:  stringToInt32
number of ops:  33
compiled vars:  !0 = $seed, !1 = $groups, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        INIT_FCALL                                               'str_split'
          2        CAST                                          6  ~3      !0
          3        SEND_VAL                                                 ~3
          4        SEND_VAL                                                 4
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !1, $4
   26     7        INIT_FCALL                                               'array_map'
          8        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
   28     9        SEND_VAL                                                 ~6
         10        SEND_VAR                                                 !1
   26    11        DO_ICALL                                         $7      
         12        ASSIGN                                                   !1, $7
   29    13        INIT_FCALL                                               'array_filter'
         14        SEND_VAR                                                 !1
         15        DECLARE_LAMBDA_FUNCTION                          ~9      [1]
   31    16        SEND_VAL                                                 ~9
   29    17        DO_ICALL                                         $10     
         18        ASSIGN                                                   !1, $10
   33    19        INIT_FCALL                                               'array_map'
         20        DECLARE_LAMBDA_FUNCTION                          ~12     [2]
   37    21        SEND_VAL                                                 ~12
         22        SEND_VAR                                                 !1
   33    23        DO_ICALL                                         $13     
         24        ASSIGN                                                   !2, $13
   39    25        INIT_FCALL                                               'array_reduce'
         26        SEND_VAR                                                 !2
         27        DECLARE_LAMBDA_FUNCTION                          ~15     [3]
   41    28        SEND_VAL                                                 ~15
         29        SEND_VAL                                                 0
   39    30        DO_ICALL                                         $16     
   41    31      > RETURN                                                   $16
   42    32*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P9Qir
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        INIT_FCALL                                               'unpack'
          2        SEND_VAL                                                 'C%2A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   28     6*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P9Qir
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   30     1        COUNT                                            ~1      !0
          2        IS_IDENTICAL                                     ~2      ~1, 4
          3      > RETURN                                                   ~2
   31     4*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P9Qir
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $group
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   34     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
   36     4        SEND_VAL                                                 ~1
          5        SEND_VAL                                                 0
   34     6        DO_ICALL                                         $2      
   36     7      > RETURN                                                   $2
   37     8*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P9Qir
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $acc, !1 = $cur
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   35     2        SL                                               ~2      !0, 4
          3        BW_OR                                            ~3      !1, ~2
          4      > RETURN                                                   ~3
   36     5*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P9Qir
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $acc, !1 = $cur
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   40     2        BW_XOR                                           ~2      !0, !1
          3      > RETURN                                                   ~2
   41     4*     > RETURN                                                   null

End of Dynamic Function 3

End of function stringtoint32

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.4 ms | 1021 KiB | 23 Q