3v4l.org

run code in 300+ PHP versions simultaneously
<?php function roll ($probability, $precision = 5) { if ($probability == 0) { return null; } return mt_rand(1, pow(10, $precision) / $probability) / pow(10, $precision); } $rolls = array(); for ($i = 0; $i < 500; $i++) { $rolls[roll(0.25)]++; } var_dump($rolls); if (roll(0.25) === 0) { print "Winner"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
Branch analysis from position: 3
filename:       /in/RKjU6
function name:  (null)
number of ops:  21
compiled vars:  !0 = $rolls, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   13     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->9
   14     3    >   INIT_FCALL                                               'roll'
          4        SEND_VAL                                                 0.25
          5        DO_FCALL                                      0  $4      
          6        FETCH_DIM_RW                                     $5      !0, $4
          7        PRE_INC                                                  $5
   13     8        PRE_INC                                                  !1
          9    >   IS_SMALLER                                               !1, 500
         10      > JMPNZ                                                    ~8, ->3
   17    11    >   INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
   19    14        INIT_FCALL                                               'roll'
         15        SEND_VAL                                                 0.25
         16        DO_FCALL                                      0  $10     
         17        IS_IDENTICAL                                             $10, 0
         18      > JMPZ                                                     ~11, ->20
   20    19    >   ECHO                                                     'Winner'
   21    20    > > RETURN                                                   1

Function roll:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RKjU6
function name:  roll
number of ops:  21
compiled vars:  !0 = $probability, !1 = $precision
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      5
    4     2        IS_EQUAL                                                 !0, 0
          3      > JMPZ                                                     ~2, ->5
    5     4    > > RETURN                                                   null
    8     5    >   INIT_FCALL                                               'mt_rand'
          6        SEND_VAL                                                 1
          7        INIT_FCALL                                               'pow'
          8        SEND_VAL                                                 10
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $3      
         11        DIV                                              ~4      $3, !0
         12        SEND_VAL                                                 ~4
         13        DO_ICALL                                         $5      
         14        INIT_FCALL                                               'pow'
         15        SEND_VAL                                                 10
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $6      
         18        DIV                                              ~7      $5, $6
         19      > RETURN                                                   ~7
    9    20*     > RETURN                                                   null

End of function roll

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.62 ms | 1403 KiB | 21 Q