3v4l.org

run code in 500+ PHP versions simultaneously
<?php function roll($seed, $key, $nonce) { $key = "your client seed"; // excluding the dash and the nonce! $seed = "your server seed"; // bet made with seed pair (excluding current bet) $nonce = 0; $hash = hash_hmac('sha512', $key . '-' . $nonce, $seed); $index = 0; $lucky = hexdec(substr($hash, $index * 5, 5)); while ($lucky >= pow(10, 6)) { $index++; $lucky = hexdec(substr($hash, $index * 5, 5)); if ($index * 5 + 5 > 128) { return '99.99'; break; } } $lucky %= pow(10, 4); $lucky = sprintf('%.2f', bcdiv($lucky, '100', 2)); return $lucky; } echo roll('bla','blah',2); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KZRZD
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                                   'roll'
          1        SEND_VAL                                                     'bla'
          2        SEND_VAL                                                     'blah'
          3        SEND_VAL                                                     2
          4        DO_FCALL                                          0  $0      
          5        ECHO                                                         $0
   32     6      > RETURN                                                       1

Function roll:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 23
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 37
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/KZRZD
function name:  roll
number of ops:  60
compiled vars:  !0 = $seed, !1 = $key, !2 = $nonce, !3 = $hash, !4 = $index, !5 = $lucky
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
    3     3        ASSIGN                                                       !1, 'your+client+seed'
    4     4        ASSIGN                                                       !0, 'your+server+seed'
    7     5        ASSIGN                                                       !2, 0
   10     6        INIT_FCALL                                                   'hash_hmac'
          7        SEND_VAL                                                     'sha512'
          8        CONCAT                                               ~9      !1, '-'
          9        CONCAT                                               ~10     ~9, !2
         10        SEND_VAL                                                     ~10
         11        SEND_VAR                                                     !0
         12        DO_ICALL                                             $11     
         13        ASSIGN                                                       !3, $11
   12    14        ASSIGN                                                       !4, 0
   14    15        INIT_FCALL                                                   'hexdec'
         16        MUL                                                  ~14     !4, 5
         17        FRAMELESS_ICALL_3                substr              ~15     !3, ~14
         18        OP_DATA                                                      5
         19        SEND_VAL                                                     ~15
         20        DO_ICALL                                             $16     
         21        ASSIGN                                                       !5, $16
   16    22      > JMP                                                          ->37
   17    23    >   PRE_INC                                                      !4
   18    24        INIT_FCALL                                                   'hexdec'
         25        MUL                                                  ~19     !4, 5
         26        FRAMELESS_ICALL_3                substr              ~20     !3, ~19
         27        OP_DATA                                                      5
         28        SEND_VAL                                                     ~20
         29        DO_ICALL                                             $21     
         30        ASSIGN                                                       !5, $21
   20    31        MUL                                                  ~23     !4, 5
         32        ADD                                                  ~24     ~23, 5
         33        IS_SMALLER                                                   128, ~24
         34      > JMPZ                                                         ~25, ->37
   21    35    > > RETURN                                                       '99.99'
   22    36*       JMP                                                          ->43
   16    37    >   INIT_FCALL                                                   'pow'
         38        SEND_VAL                                                     10
         39        SEND_VAL                                                     6
         40        DO_ICALL                                             $26     
         41        IS_SMALLER_OR_EQUAL                                          $26, !5
         42      > JMPNZ                                                        ~27, ->23
   26    43    >   INIT_FCALL                                                   'pow'
         44        SEND_VAL                                                     10
         45        SEND_VAL                                                     4
         46        DO_ICALL                                             $28     
         47        ASSIGN_OP                                         5          !5, $28
   27    48        INIT_FCALL                                                   'sprintf'
         49        SEND_VAL                                                     '%25.2f'
         50        INIT_FCALL_BY_NAME                                           'bcdiv'
         51        SEND_VAR_EX                                                  !5
         52        SEND_VAL_EX                                                  '100'
         53        SEND_VAL_EX                                                  2
         54        DO_FCALL                                          0  $30     
         55        SEND_VAR                                                     $30
         56        DO_ICALL                                             $31     
         57        ASSIGN                                                       !5, $31
   28    58      > RETURN                                                       !5
   29    59*     > RETURN                                                       null

End of function roll

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
215.28 ms | 2900 KiB | 18 Q