3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * Fill in all four below and click blue 'eval();' button below textarea. * * ------------------ */ $ticketPrice = -1; $unhashedServerSeed = ''; $nonce = -1; $clientSeed = ''; /* ------------------ */ if ($ticketPrice < 0 || $unhashedServerSeed == '' || $nonce < 0 || $clientSeed == '') { echo "Fill in details"; return; } 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)$ticketPrice ^ (int)$nonce; $max = 10000; mt_srand($seed, MT_RAND_MT19937); $result = mt_rand(0, $max); echo "Seed: $seed\n"; echo "Result: $result";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 47) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
Branch analysis from position: 11
Branch analysis from position: 8
filename:       /in/JVFlC
function name:  (null)
number of ops:  49
compiled vars:  !0 = $ticketPrice, !1 = $unhashedServerSeed, !2 = $nonce, !3 = $clientSeed, !4 = $serverSeedInt, !5 = $clientSeedInt, !6 = $seed, !7 = $max, !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, ''
   13     4        IS_SMALLER                                       ~13     !0, 0
          5      > JMPNZ_EX                                         ~13     ~13, ->8
          6    >   IS_EQUAL                                         ~14     !1, ''
          7        BOOL                                             ~13     ~14
          8    > > JMPNZ_EX                                         ~13     ~13, ->11
          9    >   IS_SMALLER                                       ~15     !2, 0
         10        BOOL                                             ~13     ~15
         11    > > JMPNZ_EX                                         ~13     ~13, ->14
         12    >   IS_EQUAL                                         ~16     !3, ''
         13        BOOL                                             ~13     ~16
         14    > > JMPZ                                                     ~13, ->17
   14    15    >   ECHO                                                     'Fill+in+details'
   15    16      > RETURN                                                   null
   39    17    >   INIT_FCALL                                               'stringtoint32'
         18        SEND_VAR                                                 !1
         19        DO_FCALL                                      0  $17     
         20        ASSIGN                                                   !4, $17
   40    21        INIT_FCALL                                               'stringtoint32'
         22        SEND_VAR                                                 !3
         23        DO_FCALL                                      0  $19     
         24        ASSIGN                                                   !5, $19
   41    25        BW_XOR                                           ~21     !4, !5
         26        CAST                                          4  ~22     !0
         27        BW_XOR                                           ~23     ~21, ~22
         28        CAST                                          4  ~24     !2
         29        BW_XOR                                           ~25     ~23, ~24
         30        ASSIGN                                                   !6, ~25
   43    31        ASSIGN                                                   !7, 10000
   44    32        INIT_FCALL                                               'mt_srand'
         33        SEND_VAR                                                 !6
         34        SEND_VAL                                                 0
         35        DO_ICALL                                                 
   45    36        INIT_FCALL                                               'mt_rand'
         37        SEND_VAL                                                 0
         38        SEND_VAR                                                 !7
         39        DO_ICALL                                         $29     
         40        ASSIGN                                                   !8, $29
   47    41        ROPE_INIT                                     3  ~32     'Seed%3A+'
         42        ROPE_ADD                                      1  ~32     ~32, !6
         43        ROPE_END                                      2  ~31     ~32, '%0A'
         44        ECHO                                                     ~31
   48    45        NOP                                                      
         46        FAST_CONCAT                                      ~34     'Result%3A+', !8
         47        ECHO                                                     ~34
         48      > RETURN                                                   1

Function stringtoint32:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JVFlC
function name:  stringToInt32
number of ops:  33
compiled vars:  !0 = $seed, !1 = $groups, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     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
   21     7        INIT_FCALL                                               'array_map'
          8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJVFlC%3A21%240'
   23     9        SEND_VAL                                                 ~6
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $7      
   21    12        ASSIGN                                                   !1, $7
   24    13        INIT_FCALL                                               'array_filter'
         14        SEND_VAR                                                 !1
         15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJVFlC%3A24%241'
   26    16        SEND_VAL                                                 ~9
         17        DO_ICALL                                         $10     
   24    18        ASSIGN                                                   !1, $10
   28    19        INIT_FCALL                                               'array_map'
         20        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJVFlC%3A28%242'
   32    21        SEND_VAL                                                 ~12
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                         $13     
   28    24        ASSIGN                                                   !2, $13
   34    25        INIT_FCALL                                               'array_reduce'
         26        SEND_VAR                                                 !2
         27        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJVFlC%3A34%244'
   36    28        SEND_VAL                                                 ~15
         29        SEND_VAL                                                 0
         30        DO_ICALL                                         $16     
         31      > RETURN                                                   $16
   37    32*     > RETURN                                                   null

End of function stringtoint32

Function %00%7Bclosure%7D%2Fin%2FJVFlC%3A21%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JVFlC
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'unpack'
          2        SEND_VAL                                                 'C%2A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   23     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJVFlC%3A21%240

Function %00%7Bclosure%7D%2Fin%2FJVFlC%3A24%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JVFlC
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   25     1        COUNT                                            ~1      !0
          2        IS_IDENTICAL                                     ~2      ~1, 4
          3      > RETURN                                                   ~2
   26     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJVFlC%3A24%241

Function %00%7Bclosure%7D%2Fin%2FJVFlC%3A28%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JVFlC
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $group
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJVFlC%3A29%243'
   31     4        SEND_VAL                                                 ~1
          5        SEND_VAL                                                 0
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
   32     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJVFlC%3A28%242

Function %00%7Bclosure%7D%2Fin%2FJVFlC%3A29%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JVFlC
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $acc, !1 = $cur
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   30     2        SL                                               ~2      !0, 4
          3        BW_OR                                            ~3      !1, ~2
          4      > RETURN                                                   ~3
   31     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJVFlC%3A29%243

Function %00%7Bclosure%7D%2Fin%2FJVFlC%3A34%244:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JVFlC
function name:  {closure}
number of ops:  5
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        BW_XOR                                           ~2      !0, !1
          3      > RETURN                                                   ~2
   36     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJVFlC%3A34%244

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.31 ms | 1411 KiB | 29 Q