3v4l.org

run code in 500+ 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:  58
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    >   FRAMELESS_ICALL_3                preg_replace        ~19     '%2F%0D%7C%0A%2F', ''
         22        OP_DATA                                                      !1
         23        ASSIGN                                                       !1, ~19
   20    24        FRAMELESS_ICALL_3                preg_replace        ~21     '%2F%0D%7C%0A%2F', ''
         25        OP_DATA                                                      !3
         26        ASSIGN                                                       !3, ~21
   44    27        INIT_FCALL                                                   'stringtoint32'
         28        SEND_VAR                                                     !1
         29        DO_FCALL                                          0  $23     
         30        ASSIGN                                                       !5, $23
   45    31        INIT_FCALL                                                   'stringtoint32'
         32        SEND_VAR                                                     !3
         33        DO_FCALL                                          0  $25     
         34        ASSIGN                                                       !6, $25
   46    35        BW_XOR                                               ~27     !5, !6
         36        CAST                                              4  ~28     !0
         37        BW_XOR                                               ~29     ~27, ~28
         38        CAST                                              4  ~30     !2
         39        BW_XOR                                               ~31     ~29, ~30
         40        ASSIGN                                                       !7, ~31
   47    41        INIT_FCALL                                                   'mt_srand'
         42        SEND_VAR                                                     !7
         43        SEND_VAL                                                     0
         44        DO_ICALL                                                     
   49    45        INIT_FCALL                                                   'mt_rand'
         46        SEND_VAL                                                     1
         47        SEND_VAR                                                     !4
         48        DO_ICALL                                             $34     
         49        ASSIGN                                                       !8, $34
   51    50        ROPE_INIT                                         3  ~37     'Seed%3A+'
         51        ROPE_ADD                                          1  ~37     ~37, !7
         52        ROPE_END                                          2  ~36     ~37, '%0A'
         53        ECHO                                                         ~36
   52    54        NOP                                                          
         55        FAST_CONCAT                                          ~39     'Result%3A+', !8
         56        ECHO                                                         ~39
         57      > 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:stringToInt32():26}
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:stringToInt32():29}
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:stringToInt32():33}
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:{closure:stringToInt32():33}:34}
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:stringToInt32():39}
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.5.0


preferences:
168.61 ms | 2161 KiB | 22 Q