3v4l.org

run code in 300+ PHP versions simultaneously
<?php function my_mt_srand(?int $seed = null) { $GLOBALS['my_mt_rand'] = new \Random\Randomizer(new \Random\Engine\Mt19937($seed)); } function my_mt_rand($min = null, $max = null) { if (!isset($GLOBALS['my_mt_rand'])) { $GLOBALS['my_mt_rand'] = new \Random\Randomizer(new \Random\Engine\Mt19937()); } if ($min === null && $max === null) { return $GLOBALS['my_mt_rand']->nextInt(); } return $GLOBALS['my_mt_rand']->getInt($min, $max); } mt_srand(1234); my_mt_srand(1234); var_dump(mt_rand()); var_dump(my_mt_rand()); var_dump(mt_rand(1, 1000)); var_dump(my_mt_rand(1, 1000));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B18he
function name:  (null)
number of ops:  31
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'mt_srand'
          1        SEND_VAL                                                 1234
          2        DO_ICALL                                                 
   19     3        INIT_FCALL                                               'my_mt_srand'
          4        SEND_VAL                                                 1234
          5        DO_FCALL                                      0          
   21     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'mt_rand'
          8        DO_ICALL                                         $2      
          9        SEND_VAR                                                 $2
         10        DO_ICALL                                                 
   22    11        INIT_FCALL                                               'var_dump'
         12        INIT_FCALL                                               'my_mt_rand'
         13        DO_FCALL                                      0  $4      
         14        SEND_VAR                                                 $4
         15        DO_ICALL                                                 
   23    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'mt_rand'
         18        SEND_VAL                                                 1
         19        SEND_VAL                                                 1000
         20        DO_ICALL                                         $6      
         21        SEND_VAR                                                 $6
         22        DO_ICALL                                                 
   24    23        INIT_FCALL                                               'var_dump'
         24        INIT_FCALL                                               'my_mt_rand'
         25        SEND_VAL                                                 1
         26        SEND_VAL                                                 1000
         27        DO_FCALL                                      0  $8      
         28        SEND_VAR                                                 $8
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Function my_mt_srand:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B18he
function name:  my_mt_srand
number of ops:  11
compiled vars:  !0 = $seed
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      null
    4     1        NEW                                              $3      'Random%5CRandomizer'
          2        NEW                                              $4      'Random%5CEngine%5CMt19937'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $4
          6        DO_FCALL                                      0          
          7        FETCH_W                      global              $1      'GLOBALS'
          8        ASSIGN_DIM                                               $1, 'my_mt_rand'
          9        OP_DATA                                                  $3
    5    10      > RETURN                                                   null

End of function my_mt_srand

Function my_mt_rand:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 14
filename:       /in/B18he
function name:  my_mt_rand
number of ops:  32
compiled vars:  !0 = $min, !1 = $max
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
    7     2        FETCH_IS                                         ~2      'GLOBALS'
          3        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      ~2, 'my_mt_rand'
          4        BOOL_NOT                                         ~4      ~3
          5      > JMPZ                                                     ~4, ->14
    8     6    >   NEW                                              $7      'Random%5CRandomizer'
          7        NEW                                              $8      'Random%5CEngine%5CMt19937'
          8        DO_FCALL                                      0          
          9        SEND_VAR_NO_REF_EX                                       $8
         10        DO_FCALL                                      0          
         11        FETCH_W                      global              $5      'GLOBALS'
         12        ASSIGN_DIM                                               $5, 'my_mt_rand'
         13        OP_DATA                                                  $7
   11    14    >   TYPE_CHECK                                    2  ~11     !0
         15      > JMPZ_EX                                          ~11     ~11, ->18
         16    >   TYPE_CHECK                                    2  ~12     !1
         17        BOOL                                             ~11     ~12
         18    > > JMPZ                                                     ~11, ->24
   12    19    >   FETCH_R                      global              ~13     'GLOBALS'
         20        FETCH_DIM_R                                      ~14     ~13, 'my_mt_rand'
         21        INIT_METHOD_CALL                                         ~14, 'nextInt'
         22        DO_FCALL                                      0  $15     
         23      > RETURN                                                   $15
   15    24    >   FETCH_R                      global              ~16     'GLOBALS'
         25        FETCH_DIM_R                                      ~17     ~16, 'my_mt_rand'
         26        INIT_METHOD_CALL                                         ~17, 'getInt'
         27        SEND_VAR_EX                                              !0
         28        SEND_VAR_EX                                              !1
         29        DO_FCALL                                      0  $18     
         30      > RETURN                                                   $18
   16    31*     > RETURN                                                   null

End of function my_mt_rand

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.86 ms | 1403 KiB | 22 Q