3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo sprintf("%x",getCrc16("\x08\x02\x00\x00\x01\x43\xEF\x3A", 0, 0xA001, 0)).'<br />'; function getCrc16($buffer, $offset, $polynom, $preset) { $preset &= 0xFFFF; $polynom &= 0xFFFF; $bufLen = strlen($buffer); $crc = $preset; for($i = 0; $i < $bufLen; $i++) { $data = $buffer[($i + $offset)%$bufLen] & 0xFF; $crc ^= $data; for ($j = 0; $j < 8; $j++) { if (($crc & 0x0001) != 0) { $crc = ($crc >> 1) ^ $polynom; } else { $crc = $crc >> 1; } } } return $crc & 0xFFFF; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NdvR5
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'sprintf'
          1        SEND_VAL                                                 '%25x'
          2        INIT_FCALL_BY_NAME                                       'getCrc16'
          3        SEND_VAL_EX                                              '%08%02%00%00%01C%EF%3A'
          4        SEND_VAL_EX                                              0
          5        SEND_VAL_EX                                              40961
          6        SEND_VAL_EX                                              0
          7        DO_FCALL                                      0  $0      
          8        SEND_VAR                                                 $0
          9        DO_ICALL                                         $1      
         10        CONCAT                                           ~2      $1, '%3Cbr+%2F%3E'
         11        ECHO                                                     ~2
   24    12      > RETURN                                                   1

Function getcrc16:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 11
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 19
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 11
Branch analysis from position: 34
Branch analysis from position: 11
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 19
Branch analysis from position: 31
Branch analysis from position: 19
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 19
Branch analysis from position: 31
Branch analysis from position: 19
filename:       /in/NdvR5
function name:  getCrc16
number of ops:  37
compiled vars:  !0 = $buffer, !1 = $offset, !2 = $polynom, !3 = $preset, !4 = $bufLen, !5 = $crc, !6 = $i, !7 = $data, !8 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    5     4        ASSIGN_OP                                    10          !3, 65535
    6     5        ASSIGN_OP                                    10          !2, 65535
    8     6        STRLEN                                           ~11     !0
          7        ASSIGN                                                   !4, ~11
   10     8        ASSIGN                                                   !5, !3
   11     9        ASSIGN                                                   !6, 0
         10      > JMP                                                      ->32
   12    11    >   ADD                                              ~15     !6, !1
         12        MOD                                              ~16     ~15, !4
         13        FETCH_DIM_R                                      ~17     !0, ~16
         14        BW_AND                                           ~18     ~17, 255
         15        ASSIGN                                                   !7, ~18
   13    16        ASSIGN_OP                                    11          !5, !7
   14    17        ASSIGN                                                   !8, 0
         18      > JMP                                                      ->29
   15    19    >   BW_AND                                           ~22     !5, 1
         20        IS_NOT_EQUAL                                             ~22, 0
         21      > JMPZ                                                     ~23, ->26
   16    22    >   SR                                               ~24     !5, 1
         23        BW_XOR                                           ~25     !2, ~24
         24        ASSIGN                                                   !5, ~25
         25      > JMP                                                      ->28
   18    26    >   SR                                               ~27     !5, 1
         27        ASSIGN                                                   !5, ~27
   14    28    >   PRE_INC                                                  !8
         29    >   IS_SMALLER                                               !8, 8
         30      > JMPNZ                                                    ~30, ->19
   11    31    >   PRE_INC                                                  !6
         32    >   IS_SMALLER                                               !6, !4
         33      > JMPNZ                                                    ~32, ->11
   23    34    >   BW_AND                                           ~33     !5, 65535
         35      > RETURN                                                   ~33
   24    36*     > RETURN                                                   null

End of function getcrc16

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.56 ms | 1400 KiB | 15 Q