3v4l.org

run code in 300+ PHP versions simultaneously
<?php function addRandomToN($n, $m) { $plus = mt_rand(0,1); if ($plus) { return $n + (($n*$m) * rand0To1()); } return $n - (($n*$m) * rand0To1()); } function rand0To1() { return (float)rand()/(float)getrandmax(); } $var = addRandomToN(5, 0.1); echo $var; $var--; echo $var;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/flSWY
function name:  (null)
number of ops:  9
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'addrandomton'
          1        SEND_VAL                                                 5
          2        SEND_VAL                                                 0.1
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   17     5        ECHO                                                     !0
   18     6        PRE_DEC                                                  !0
   19     7        ECHO                                                     !0
          8      > RETURN                                                   1

Function addrandomton:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/flSWY
function name:  addRandomToN
number of ops:  21
compiled vars:  !0 = $n, !1 = $m, !2 = $plus
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'mt_rand'
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 1
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !2, $3
    5     7      > JMPZ                                                     !2, ->14
    6     8    >   MUL                                              ~5      !0, !1
          9        INIT_FCALL_BY_NAME                                       'rand0To1'
         10        DO_FCALL                                      0  $6      
         11        MUL                                              ~7      $6, ~5
         12        ADD                                              ~8      !0, ~7
         13      > RETURN                                                   ~8
    8    14    >   MUL                                              ~9      !0, !1
         15        INIT_FCALL_BY_NAME                                       'rand0To1'
         16        DO_FCALL                                      0  $10     
         17        MUL                                              ~11     $10, ~9
         18        SUB                                              ~12     !0, ~11
         19      > RETURN                                                   ~12
   10    20*     > RETURN                                                   null

End of function addrandomton

Function rand0to1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/flSWY
function name:  rand0To1
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'rand'
          1        DO_ICALL                                         $0      
          2        CAST                                          5  ~1      $0
          3        INIT_FCALL                                               'getrandmax'
          4        DO_ICALL                                         $2      
          5        CAST                                          5  ~3      $2
          6        DIV                                              ~4      ~1, ~3
          7      > RETURN                                                   ~4
   14     8*     > RETURN                                                   null

End of function rand0to1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.92 ms | 1403 KiB | 20 Q