3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* ------------------ */ $server_seed = ""; $round = ""; $number_of_tickets = 0; /* ------------------ */ if ($server_seed == '' || $round == '' || $number_of_tickets == 0) { echo "Fill in details"; return; } // Create HMAC-SHA256 hash $hash = hash_hmac('sha256', (string)$round, $server_seed); // Convert hex to decimal using bcmath $decimal_hash = '0'; $length = strlen($hash); for ($i = 0; $i < $length; $i++) { $decimal_hash = bcmul($decimal_hash, '16'); $decimal_hash = bcadd($decimal_hash, (string)hexdec($hash[$i])); } // Apply modulo to get the winning position $roll = bcmod($decimal_hash, (string)$number_of_tickets); echo "Winning ticket position: $roll\n"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
2 jumps found. (Code = 47) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 25
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 25
Branch analysis from position: 43
Branch analysis from position: 25
Branch analysis from position: 10
Branch analysis from position: 7
filename:       /in/4D3fd
function name:  (null)
number of ops:  54
compiled vars:  !0 = $server_seed, !1 = $round, !2 = $number_of_tickets, !3 = $hash, !4 = $decimal_hash, !5 = $length, !6 = $i, !7 = $roll
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, ''
    4     1        ASSIGN                                                       !1, ''
    5     2        ASSIGN                                                       !2, 0
    8     3        IS_EQUAL                                             ~11     !0, ''
          4      > JMPNZ_EX                                             ~11     ~11, ->7
          5    >   IS_EQUAL                                             ~12     !1, ''
          6        BOOL                                                 ~11     ~12
          7    > > JMPNZ_EX                                             ~11     ~11, ->10
          8    >   IS_EQUAL                                             ~13     !2, 0
          9        BOOL                                                 ~11     ~13
         10    > > JMPZ                                                         ~11, ->13
    9    11    >   ECHO                                                         'Fill+in+details'
   10    12      > RETURN                                                       null
   14    13    >   INIT_FCALL                                                   'hash_hmac'
         14        SEND_VAL                                                     'sha256'
         15        CAST                                              6  ~14     !1
         16        SEND_VAL                                                     ~14
         17        SEND_VAR                                                     !0
         18        DO_ICALL                                             $15     
         19        ASSIGN                                                       !3, $15
   17    20        ASSIGN                                                       !4, '0'
   18    21        STRLEN                                               ~18     !3
         22        ASSIGN                                                       !5, ~18
   19    23        ASSIGN                                                       !6, 0
         24      > JMP                                                          ->41
   20    25    >   INIT_FCALL_BY_NAME                                           'bcmul'
         26        SEND_VAR_EX                                                  !4
         27        SEND_VAL_EX                                                  '16'
         28        DO_FCALL                                          0  $21     
         29        ASSIGN                                                       !4, $21
   21    30        INIT_FCALL_BY_NAME                                           'bcadd'
         31        SEND_VAR_EX                                                  !4
         32        INIT_FCALL                                                   'hexdec'
         33        FETCH_DIM_R                                          ~23     !3, !6
         34        SEND_VAL                                                     ~23
         35        DO_ICALL                                             $24     
         36        CAST                                              6  ~25     $24
         37        SEND_VAL_EX                                                  ~25
         38        DO_FCALL                                          0  $26     
         39        ASSIGN                                                       !4, $26
   19    40        PRE_INC                                                      !6
         41    >   IS_SMALLER                                                   !6, !5
         42      > JMPNZ                                                        ~29, ->25
   25    43    >   INIT_FCALL_BY_NAME                                           'bcmod'
         44        SEND_VAR_EX                                                  !4
         45        CAST                                              6  ~30     !2
         46        SEND_VAL_EX                                                  ~30
         47        DO_FCALL                                          0  $31     
         48        ASSIGN                                                       !7, $31
   27    49        ROPE_INIT                                         3  ~34     'Winning+ticket+position%3A+'
         50        ROPE_ADD                                          1  ~34     ~34, !7
         51        ROPE_END                                          2  ~33     ~34, '%0A'
         52        ECHO                                                         ~33
   28    53      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.59 ms | 1394 KiB | 15 Q