3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @return array */ function crc64Table() { $crc64tab = []; // ECMA polynomial $poly64rev = (0xC96C5795 << 32) | 0xD7870F42; echo sprintf("%x", $poly64rev) . PHP_EOL; // ISO polynomial // $poly64rev = (0xD8 << 56); for ($i = 0; $i < 256; $i++) { for ($part = $i, $bit = 0; $bit < 8; $bit++) { if ($part & 1) { $part = ($part >> 1) ^ $poly64rev; } else { $part = ($part >> 1) ; } } $crc64tab[$i] = $part; } return $crc64tab; } /** * @param string $string * @param string $format * @return mixed * * Formats: * crc64('php'); // afe4e823e7cef190 * crc64('php', '0x%x'); // 0xafe4e823e7cef190 * crc64('php', '0x%X'); // 0xAFE4E823E7CEF190 * crc64('php', '%d'); // -5772233581471534704 signed int * crc64('php', '%u'); // 12674510492238016912 unsigned int */ function crc64($string, $format = '%x') { static $crc64tab; if ($crc64tab === null) { $crc64tab = crc64Table(); } print_r($crc64tab); $crc = 0; for ($i = 0; $i < strlen($string); $i++) { $crc = $crc64tab[($crc ^ ord($string[$i])) & 0xff] ^ (($crc >> 8) & ~(0xff << 56)); } return sprintf($format, $crc); } echo crc64("123456", "%u");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9RoRW
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   65     0  E >   INIT_FCALL                                               'crc64'
          1        SEND_VAL                                                 '123456'
          2        SEND_VAL                                                 '%25u'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function crc64table:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 10
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 13
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 10
Branch analysis from position: 29
Branch analysis from position: 10
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 13
Branch analysis from position: 24
Branch analysis from position: 13
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 13
Branch analysis from position: 24
Branch analysis from position: 13
filename:       /in/9RoRW
function name:  crc64Table
number of ops:  31
compiled vars:  !0 = $crc64tab, !1 = $poly64rev, !2 = $i, !3 = $part, !4 = $bit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, -3932672073523589310
   13     2        INIT_FCALL                                               'sprintf'
          3        SEND_VAL                                                 '%25x'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $7      
          6        CONCAT                                           ~8      $7, '%0A'
          7        ECHO                                                     ~8
   18     8        ASSIGN                                                   !2, 0
          9      > JMP                                                      ->27
   20    10    >   ASSIGN                                                   !3, !2
         11        ASSIGN                                                   !4, 0
         12      > JMP                                                      ->22
   21    13    >   BW_AND                                           ~12     !3, 1
         14      > JMPZ                                                     ~12, ->19
   22    15    >   SR                                               ~13     !3, 1
         16        BW_XOR                                           ~14     !1, ~13
         17        ASSIGN                                                   !3, ~14
         18      > JMP                                                      ->21
   24    19    >   SR                                               ~16     !3, 1
         20        ASSIGN                                                   !3, ~16
   20    21    >   PRE_INC                                                  !4
         22    >   IS_SMALLER                                               !4, 8
         23      > JMPNZ                                                    ~19, ->13
   28    24    >   ASSIGN_DIM                                               !0, !2
         25        OP_DATA                                                  !3
   18    26        PRE_INC                                                  !2
         27    >   IS_SMALLER                                               !2, 256
         28      > JMPNZ                                                    ~22, ->10
   31    29    > > RETURN                                                   !0
   32    30*     > RETURN                                                   null

End of function crc64table

Function crc64:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 14
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 14
Branch analysis from position: 29
Branch analysis from position: 14
Branch analysis from position: 8
filename:       /in/9RoRW
function name:  crc64
number of ops:  35
compiled vars:  !0 = $string, !1 = $format, !2 = $crc64tab, !3 = $crc, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      '%25x'
   48     2        BIND_STATIC                                              !2
   50     3        TYPE_CHECK                                    2          !2
          4      > JMPZ                                                     ~5, ->8
   51     5    >   INIT_FCALL                                               'crc64table'
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !2, $6
   54     8    >   INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                                 
   56    11        ASSIGN                                                   !3, 0
   58    12        ASSIGN                                                   !4, 0
         13      > JMP                                                      ->26
   59    14    >   INIT_FCALL                                               'ord'
         15        FETCH_DIM_R                                      ~11     !0, !4
         16        SEND_VAL                                                 ~11
         17        DO_ICALL                                         $12     
         18        BW_XOR                                           ~13     !3, $12
         19        BW_AND                                           ~14     ~13, 255
         20        FETCH_DIM_R                                      ~15     !2, ~14
         21        SR                                               ~16     !3, 8
         22        BW_AND                                           ~17     ~16, 72057594037927935
         23        BW_XOR                                           ~18     ~15, ~17
         24        ASSIGN                                                   !3, ~18
   58    25        PRE_INC                                                  !4
         26    >   STRLEN                                           ~21     !0
         27        IS_SMALLER                                               !4, ~21
         28      > JMPNZ                                                    ~22, ->14
   62    29    >   INIT_FCALL                                               'sprintf'
         30        SEND_VAR                                                 !1
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                         $23     
         33      > RETURN                                                   $23
   63    34*     > RETURN                                                   null

End of function crc64

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.97 ms | 1411 KiB | 21 Q