3v4l.org

run code in 300+ 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 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 26
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 43
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
filename:       /in/KZRZD
function name:  roll
number of ops:  66
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        INIT_FCALL                                               'substr'
         17        SEND_VAR                                                 !3
         18        MUL                                              ~14     !4, 5
         19        SEND_VAL                                                 ~14
         20        SEND_VAL                                                 5
         21        DO_ICALL                                         $15     
         22        SEND_VAR                                                 $15
         23        DO_ICALL                                         $16     
         24        ASSIGN                                                   !5, $16
   16    25      > JMP                                                      ->43
   17    26    >   PRE_INC                                                  !4
   18    27        INIT_FCALL                                               'hexdec'
         28        INIT_FCALL                                               'substr'
         29        SEND_VAR                                                 !3
         30        MUL                                              ~19     !4, 5
         31        SEND_VAL                                                 ~19
         32        SEND_VAL                                                 5
         33        DO_ICALL                                         $20     
         34        SEND_VAR                                                 $20
         35        DO_ICALL                                         $21     
         36        ASSIGN                                                   !5, $21
   20    37        MUL                                              ~23     !4, 5
         38        ADD                                              ~24     ~23, 5
         39        IS_SMALLER                                               128, ~24
         40      > JMPZ                                                     ~25, ->43
   21    41    > > RETURN                                                   '99.99'
   22    42*       JMP                                                      ->49
   16    43    >   INIT_FCALL                                               'pow'
         44        SEND_VAL                                                 10
         45        SEND_VAL                                                 6
         46        DO_ICALL                                         $26     
         47        IS_SMALLER_OR_EQUAL                                      $26, !5
         48      > JMPNZ                                                    ~27, ->26
   26    49    >   INIT_FCALL                                               'pow'
         50        SEND_VAL                                                 10
         51        SEND_VAL                                                 4
         52        DO_ICALL                                         $28     
         53        ASSIGN_OP                                     5          !5, $28
   27    54        INIT_FCALL                                               'sprintf'
         55        SEND_VAL                                                 '%25.2f'
         56        INIT_FCALL_BY_NAME                                       'bcdiv'
         57        SEND_VAR_EX                                              !5
         58        SEND_VAL_EX                                              '100'
         59        SEND_VAL_EX                                              2
         60        DO_FCALL                                      0  $30     
         61        SEND_VAR                                                 $30
         62        DO_ICALL                                         $31     
         63        ASSIGN                                                   !5, $31
   28    64      > RETURN                                                   !5
   29    65*     > RETURN                                                   null

End of function roll

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.65 ms | 1465 KiB | 19 Q