3v4l.org

run code in 300+ PHP versions simultaneously
<?php function comp_rand($min, $max) { $loops = 1000; while ($loops--) { $v = rand($min, $max); $v%2 ? @$rand['odd']++ : @$rand['even']++; $v = mt_rand($min, $max); $v%2 ? @$mt_rand['odd']++ : @$mt_rand['even']++; //$v = random_int($min, $max); //$v%2 ? @$random_int['odd']++ : @$random_int['even']++; } var_dump($rand, $mt_rand, $random_int); } // even only $min = 1; $max = mt_getrandmax()*2+1; comp_rand($min, $max); // odd only $min = 0; $max = mt_getrandmax()*2; comp_rand($min, $max);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kYpAF
function name:  (null)
number of ops:  20
compiled vars:  !0 = $min, !1 = $max
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, 1
   18     1        INIT_FCALL                                               'mt_getrandmax'
          2        DO_ICALL                                         $3      
          3        MUL                                              ~4      $3, 2
          4        ADD                                              ~5      ~4, 1
          5        ASSIGN                                                   !1, ~5
   19     6        INIT_FCALL                                               'comp_rand'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0          
   22    10        ASSIGN                                                   !0, 0
   23    11        INIT_FCALL                                               'mt_getrandmax'
         12        DO_ICALL                                         $9      
         13        MUL                                              ~10     $9, 2
         14        ASSIGN                                                   !1, ~10
   24    15        INIT_FCALL                                               'comp_rand'
         16        SEND_VAR                                                 !0
         17        SEND_VAR                                                 !1
         18        DO_FCALL                                      0          
         19      > RETURN                                                   1

Function comp_rand:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 4
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 36
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 4
Branch analysis from position: 44
Branch analysis from position: 4
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 4
Branch analysis from position: 44
Branch analysis from position: 4
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 36
Branch analysis from position: 30
Branch analysis from position: 36
filename:       /in/kYpAF
function name:  comp_rand
number of ops:  50
compiled vars:  !0 = $min, !1 = $max, !2 = $loops, !3 = $v, !4 = $rand, !5 = $mt_rand, !6 = $random_int
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, 1000
    5     3      > JMP                                                      ->42
    6     4    >   INIT_FCALL                                               'rand'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !3, $8
    7     9        MOD                                              ~10     !3, 2
         10      > JMPZ                                                     ~10, ->17
         11    >   BEGIN_SILENCE                                    ~11     
         12        FETCH_DIM_RW                                     $12     !4, 'odd'
         13        POST_INC                                         ~13     $12
         14        END_SILENCE                                              ~11
         15        QM_ASSIGN                                        ~14     ~13
         16      > JMP                                                      ->22
         17    >   BEGIN_SILENCE                                    ~15     
         18        FETCH_DIM_RW                                     $16     !4, 'even'
         19        POST_INC                                         ~17     $16
         20        END_SILENCE                                              ~15
         21        QM_ASSIGN                                        ~14     ~17
         22    >   FREE                                                     ~14
    8    23        INIT_FCALL                                               'mt_rand'
         24        SEND_VAR                                                 !0
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $18     
         27        ASSIGN                                                   !3, $18
    9    28        MOD                                              ~20     !3, 2
         29      > JMPZ                                                     ~20, ->36
         30    >   BEGIN_SILENCE                                    ~21     
         31        FETCH_DIM_RW                                     $22     !5, 'odd'
         32        POST_INC                                         ~23     $22
         33        END_SILENCE                                              ~21
         34        QM_ASSIGN                                        ~24     ~23
         35      > JMP                                                      ->41
         36    >   BEGIN_SILENCE                                    ~25     
         37        FETCH_DIM_RW                                     $26     !5, 'even'
         38        POST_INC                                         ~27     $26
         39        END_SILENCE                                              ~25
         40        QM_ASSIGN                                        ~24     ~27
         41    >   FREE                                                     ~24
    5    42    >   POST_DEC                                         ~28     !2
         43      > JMPNZ                                                    ~28, ->4
   13    44    >   INIT_FCALL                                               'var_dump'
         45        SEND_VAR                                                 !4
         46        SEND_VAR                                                 !5
         47        SEND_VAR                                                 !6
         48        DO_ICALL                                                 
   14    49      > RETURN                                                   null

End of function comp_rand

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.8 ms | 1403 KiB | 23 Q