3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function generateSignature($signatureHash) { $signatureHash = $signatureHash; //generating signature $minVal = (int) -2147483648; $maxVal = (int) 2147483647; $hash = (int) 0; for ($i = 0; $i < strlen($signatureHash); $i++) { $hash = ((int) $hash * 31) + ((int) ord(substr($signatureHash, $i, 1))); if ($hash > $maxVal) { $hash = (int) $hash + (int) $minVal - (int) $maxVal - 1; } else if ($hash < $minVal) { $hash = (int) $hash + (int) $maxVal - (int) $minVal + 1; } } return (int) $hash; } $hash1 = '05MAIN0044JT00001742IDR30534D34314E303034414B3359503459'; $hash2 = '18044515'; echo $signature = generateSignature($hash1) + generateSignature($hash2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2vYDR
function name:  (null)
number of ops:  13
compiled vars:  !0 = $hash1, !1 = $hash2, !2 = $signature
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  23     1        ASSIGN                                                   !0, '05MAIN0044JT00001742IDR30534D34314E303034414B3359503459'
  24     2        ASSIGN                                                   !1, '18044515'
  25     3        INIT_FCALL                                               'generatesignature'
         4        SEND_VAR                                                 !0
         5        DO_FCALL                                      0  $5      
         6        INIT_FCALL                                               'generatesignature'
         7        SEND_VAR                                                 !1
         8        DO_FCALL                                      0  $6      
         9        ADD                                              ~7      $5, $6
        10        ASSIGN                                           $8      !2, ~7
        11        ECHO                                                     $8
        12      > RETURN                                                   1

Function generatesignature:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 10
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 33
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 10
Branch analysis from position: 47
Branch analysis from position: 10
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 42
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 10
Branch analysis from position: 47
Branch analysis from position: 10
Branch analysis from position: 42
filename:       /in/2vYDR
function name:  generateSignature
number of ops:  50
compiled vars:  !0 = $signatureHash, !1 = $minVal, !2 = $maxVal, !3 = $hash, !4 = $i
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   RECV                                             !0      
   4     1        ASSIGN                                                   !0, !0
   6     2        CAST                                          4  ~6      -2147483648
         3        ASSIGN                                                   !1, ~6
   7     4        CAST                                          4  ~8      2147483647
         5        ASSIGN                                                   !2, ~8
   8     6        CAST                                          4  ~10     0
         7        ASSIGN                                                   !3, ~10
   9     8        ASSIGN                                                   !4, 0
         9      > JMP                                                      ->44
  11    10    >   CAST                                          4  ~13     !3
        11        MUL                                              ~14     ~13, 31
        12        INIT_FCALL                                               'ord'
        13        INIT_FCALL                                               'substr'
        14        SEND_VAR                                                 !0
        15        SEND_VAR                                                 !4
        16        SEND_VAL                                                 1
        17        DO_ICALL                                         $15     
        18        SEND_VAR                                                 $15
        19        DO_ICALL                                         $16     
        20        CAST                                          4  ~17     $16
        21        ADD                                              ~18     ~14, ~17
        22        ASSIGN                                                   !3, ~18
  13    23        IS_SMALLER                                       ~20     !2, !3
        24      > JMPZ                                                     ~20, ->33
  14    25    >   CAST                                          4  ~21     !3
        26        CAST                                          4  ~22     !1
        27        ADD                                              ~23     ~21, ~22
        28        CAST                                          4  ~24     !2
        29        SUB                                              ~25     ~23, ~24
        30        SUB                                              ~26     ~25, 1
        31        ASSIGN                                                   !3, ~26
        32      > JMP                                                      ->42
  15    33    >   IS_SMALLER                                       ~28     !3, !1
        34      > JMPZ                                                     ~28, ->42
  16    35    >   CAST                                          4  ~29     !3
        36        CAST                                          4  ~30     !2
        37        ADD                                              ~31     ~29, ~30
        38        CAST                                          4  ~32     !1
        39        SUB                                              ~33     ~31, ~32
        40        ADD                                              ~34     ~33, 1
        41        ASSIGN                                                   !3, ~34
   9    42    >   POST_INC                                         ~36     !4
        43        FREE                                                     ~36
        44    >   STRLEN                                           ~37     !0
        45        IS_SMALLER                                       ~38     !4, ~37
        46      > JMPNZ                                                    ~38, ->10
  19    47    >   CAST                                          4  ~39     !3
        48      > RETURN                                                   ~39
  20    49*     > RETURN                                                   null

End of function generatesignature

Generated using Vulcan Logic Dumper, using php 7.3.0