3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * Fill in all below and click the blue 'eval();' button. * ------------------ */ $server_seed = ""; $client_seed = ""; $game_id = ""; $chance = 0.50; // your chosen chance, e.g. 0.50 for 50% $direction = "under"; // "under" or "over" /* ------------------ */ if ($server_seed == '' || $client_seed === "" || $game_id == '') { echo "Fill in details"; return; } // Create HMAC-SHA256 hash $message = $client_seed . "-" . $game_id; $hmac_hash = hash_hmac('sha256', $message, $server_seed); // Convert hex to decimal using bcmath for large numbers $decimal_value = '0'; $length = strlen($hmac_hash); for ($i = 0; $i < $length; $i++) { $decimal_value = bcmul($decimal_value, '16'); $decimal_value = bcadd($decimal_value, hexdec($hmac_hash[$i])); } // Apply modulo 10^8 $roll = (int) bcmod($decimal_value, '100000000'); // Same threshold/win check as upgrade_start_game() server-side — // house edge 0.10, symmetric under/over. $house_edge = 0.10; $multiplier = (1 - $house_edge) / $chance; $threshold = (int) ($chance * 100000000); $win = $direction !== "over" ? $roll < $threshold : $roll >= (100000000 - $threshold); echo "Roll: " . $roll . "\n"; echo $win ? ("Win \xe2\x80\x94 payout " . number_format($multiplier, 4) . "x") : "Loss"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 47) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 29
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 64
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 80
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 80
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 80
Branch analysis from position: 72
Branch analysis from position: 80
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 29
Branch analysis from position: 46
Branch analysis from position: 29
Branch analysis from position: 12
Branch analysis from position: 9
filename:       /in/Nijco
function name:  (null)
number of ops:  83
compiled vars:  !0 = $server_seed, !1 = $client_seed, !2 = $game_id, !3 = $chance, !4 = $direction, !5 = $message, !6 = $hmac_hash, !7 = $decimal_value, !8 = $length, !9 = $i, !10 = $roll, !11 = $house_edge, !12 = $multiplier, !13 = $threshold, !14 = $win
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                       !0, ''
    6     1        ASSIGN                                                       !1, ''
    7     2        ASSIGN                                                       !2, ''
    8     3        ASSIGN                                                       !3, 0.5
    9     4        ASSIGN                                                       !4, 'under'
   12     5        IS_EQUAL                                             ~20     !0, ''
          6      > JMPNZ_EX                                             ~20     ~20, ->9
          7    >   IS_IDENTICAL                                         ~21     !1, ''
          8        BOOL                                                 ~20     ~21
          9    > > JMPNZ_EX                                             ~20     ~20, ->12
         10    >   IS_EQUAL                                             ~22     !2, ''
         11        BOOL                                                 ~20     ~22
         12    > > JMPZ                                                         ~20, ->15
   13    13    >   ECHO                                                         'Fill+in+details'
   14    14      > RETURN                                                       null
   18    15    >   CONCAT                                               ~23     !1, '-'
         16        CONCAT                                               ~24     ~23, !2
         17        ASSIGN                                                       !5, ~24
   19    18        INIT_FCALL                                                   'hash_hmac'
         19        SEND_VAL                                                     'sha256'
         20        SEND_VAR                                                     !5
         21        SEND_VAR                                                     !0
         22        DO_ICALL                                             $26     
         23        ASSIGN                                                       !6, $26
   22    24        ASSIGN                                                       !7, '0'
   23    25        STRLEN                                               ~29     !6
         26        ASSIGN                                                       !8, ~29
   25    27        ASSIGN                                                       !9, 0
         28      > JMP                                                          ->44
   26    29    >   INIT_FCALL_BY_NAME                                           'bcmul'
         30        SEND_VAR_EX                                                  !7
         31        SEND_VAL_EX                                                  '16'
         32        DO_FCALL                                          0  $32     
         33        ASSIGN                                                       !7, $32
   27    34        INIT_FCALL_BY_NAME                                           'bcadd'
         35        SEND_VAR_EX                                                  !7
         36        INIT_FCALL                                                   'hexdec'
         37        FETCH_DIM_R                                          ~34     !6, !9
         38        SEND_VAL                                                     ~34
         39        DO_ICALL                                             $35     
         40        SEND_VAR_NO_REF_EX                                           $35
         41        DO_FCALL                                          0  $36     
         42        ASSIGN                                                       !7, $36
   25    43        PRE_INC                                                      !9
         44    >   IS_SMALLER                                                   !9, !8
         45      > JMPNZ                                                        ~39, ->29
   31    46    >   INIT_FCALL_BY_NAME                                           'bcmod'
         47        SEND_VAR_EX                                                  !7
         48        SEND_VAL_EX                                                  '100000000'
         49        DO_FCALL                                          0  $40     
         50        CAST                                              4  ~41     $40
         51        ASSIGN                                                       !10, ~41
   35    52        ASSIGN                                                       !11, 0.1
   36    53        SUB                                                  ~44     1, !11
         54        DIV                                                  ~45     ~44, !3
         55        ASSIGN                                                       !12, ~45
   37    56        MUL                                                  ~47     !3, 100000000
         57        CAST                                              4  ~48     ~47
         58        ASSIGN                                                       !13, ~48
   39    59        IS_NOT_IDENTICAL                                             !4, 'over'
         60      > JMPZ                                                         ~50, ->64
   40    61    >   IS_SMALLER                                           ~51     !10, !13
         62        QM_ASSIGN                                            ~52     ~51
         63      > JMP                                                          ->67
   41    64    >   SUB                                                  ~53     100000000, !13
         65        IS_SMALLER_OR_EQUAL                                  ~54     ~53, !10
         66        QM_ASSIGN                                            ~52     ~54
   39    67    >   ASSIGN                                                       !14, ~52
   43    68        CONCAT                                               ~56     'Roll%3A+', !10
         69        CONCAT                                               ~57     ~56, '%0A'
         70        ECHO                                                         ~57
   44    71      > JMPZ                                                         !14, ->80
         72    >   INIT_FCALL                                                   'number_format'
         73        SEND_VAR                                                     !12
         74        SEND_VAL                                                     4
         75        DO_ICALL                                             $58     
         76        CONCAT                                               ~59     'Win+%E2%80%94+payout+', $58
         77        CONCAT                                               ~60     ~59, 'x'
         78        QM_ASSIGN                                            ~61     ~60
         79      > JMP                                                          ->81
         80    >   QM_ASSIGN                                            ~61     'Loss'
         81    >   ECHO                                                         ~61
   45    82      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
131.88 ms | 777 KiB | 11 Q