3v4l.org

run code in 300+ PHP versions simultaneously
<?php function weightedRand($min, $max, $gamma) { $offset = $max - $min + 1; return floor($min + pow(lcg_value(), $gamma) * $offset); } $ola = weightedRand(1, 4, 1); var_dump($ola);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Jo4nL
function name:  (null)
number of ops:  10
compiled vars:  !0 = $ola
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'weightedrand'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 4
          3        SEND_VAL                                                 1
          4        DO_FCALL                                      0  $1      
          5        ASSIGN                                                   !0, $1
    7     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function weightedrand:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Jo4nL
function name:  weightedRand
number of ops:  19
compiled vars:  !0 = $min, !1 = $max, !2 = $gamma, !3 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    3     3        SUB                                              ~4      !1, !0
          4        ADD                                              ~5      ~4, 1
          5        ASSIGN                                                   !3, ~5
    4     6        INIT_FCALL                                               'floor'
          7        INIT_FCALL                                               'pow'
          8        INIT_FCALL                                               'lcg_value'
          9        DO_ICALL                                         $7      
         10        SEND_VAR                                                 $7
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $8      
         13        MUL                                              ~9      !3, $8
         14        ADD                                              ~10     !0, ~9
         15        SEND_VAL                                                 ~10
         16        DO_ICALL                                         $11     
         17      > RETURN                                                   $11
    5    18*     > RETURN                                                   null

End of function weightedrand

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.98 ms | 1399 KiB | 22 Q