3v4l.org

run code in 300+ PHP versions simultaneously
<?php function myRand($max){ do{ $result = floor($max*(hexdec(bin2hex(openssl_random_pseudo_bytes(4)))/0xffffffff)); }while($result == $max); return $result; } echo myRand(1000);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c3eC6
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'myrand'
          1        SEND_VAL                                                 1000
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function myrand:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 1
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 1
filename:       /in/c3eC6
function name:  myRand
number of ops:  20
compiled vars:  !0 = $max, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1    >   INIT_FCALL                                               'floor'
          2        INIT_FCALL                                               'hexdec'
          3        INIT_FCALL                                               'bin2hex'
          4        INIT_FCALL_BY_NAME                                       'openssl_random_pseudo_bytes'
          5        SEND_VAL_EX                                              4
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                         $3      
          9        SEND_VAR                                                 $3
         10        DO_ICALL                                         $4      
         11        DIV                                              ~5      $4, 4294967295
         12        MUL                                              ~6      !0, ~5
         13        SEND_VAL                                                 ~6
         14        DO_ICALL                                         $7      
         15        ASSIGN                                                   !1, $7
    6    16        IS_EQUAL                                                 !1, !0
         17      > JMPNZ                                                    ~9, ->1
    7    18    > > RETURN                                                   !1
    8    19*     > RETURN                                                   null

End of function myrand

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
193.04 ms | 1402 KiB | 20 Q