3v4l.org

run code in 300+ PHP versions simultaneously
<?php const INT_SIGNED = 1; const INT_LE = 2; function isLittleEndian() { return pack('S', 0x00FF) === "\xFF\x00"; } function is32Bit() { return PHP_INT_MAX < 0x80000000; } function unpack_int32($str, $flags = 0) { $length = strlen($str); if ($length < 4) { return false; } else if ($length > 4) { $str = substr($str, 0, 4); } $format = ($flags & INT_LE) ? 'V' : 'N'; $result = unpack($format, $str); if (($result & 0x80000000) && ($flags & INT_SIGNED) && !is32Bit()) { $result = 0xFFFFFFFF00000000 | $result; } return $result; } var_dump(isLittleEndian(), is32Bit(), unpack_int32("\xFF\xFF\xFF\xFF", INT_SIGNED)); var_dump(isLittleEndian(), is32Bit());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pvNTs
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'INT_SIGNED', 1
    4     1        DECLARE_CONST                                            'INT_LE', 2
   31     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'islittleendian'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        INIT_FCALL                                               'is32bit'
          7        DO_FCALL                                      0  $1      
          8        SEND_VAR                                                 $1
          9        INIT_FCALL                                               'unpack_int32'
         10        SEND_VAL                                                 '%FF%FF%FF%FF'
         11        FETCH_CONSTANT                                   ~2      'INT_SIGNED'
         12        SEND_VAL                                                 ~2
         13        DO_FCALL                                      0  $3      
         14        SEND_VAR                                                 $3
         15        DO_ICALL                                                 
   32    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'islittleendian'
         18        DO_FCALL                                      0  $5      
         19        SEND_VAR                                                 $5
         20        INIT_FCALL                                               'is32bit'
         21        DO_FCALL                                      0  $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Function islittleendian:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pvNTs
function name:  isLittleEndian
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'pack'
          1        SEND_VAL                                                 'S'
          2        SEND_VAL                                                 255
          3        DO_ICALL                                         $0      
          4        IS_IDENTICAL                                     ~1      $0, '%FF%00'
          5      > RETURN                                                   ~1
    8     6*     > RETURN                                                   null

End of function islittleendian

Function is32bit:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pvNTs
function name:  is32Bit
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E > > RETURN                                                   <false>
   11     1*     > RETURN                                                   null

End of function is32bit

Function unpack_int32:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 46) Position 1 = 30, Position 2 = 33
Branch analysis from position: 30
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 38
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 41
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
Branch analysis from position: 38
Branch analysis from position: 33
Branch analysis from position: 21
2 jumps found. (Code = 46) Position 1 = 30, Position 2 = 33
Branch analysis from position: 30
Branch analysis from position: 33
Branch analysis from position: 16
filename:       /in/pvNTs
function name:  unpack_int32
number of ops:  43
compiled vars:  !0 = $str, !1 = $flags, !2 = $length, !3 = $format, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
   14     2        STRLEN                                           ~5      !0
          3        ASSIGN                                                   !2, ~5
   15     4        IS_SMALLER                                               !2, 4
          5      > JMPZ                                                     ~7, ->8
   16     6    > > RETURN                                                   <false>
          7*       JMP                                                      ->16
   17     8    >   IS_SMALLER                                               4, !2
          9      > JMPZ                                                     ~8, ->16
   18    10    >   INIT_FCALL                                               'substr'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 0
         13        SEND_VAL                                                 4
         14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !0, $9
   21    16    >   FETCH_CONSTANT                                   ~11     'INT_LE'
         17        BW_AND                                           ~12     !1, ~11
         18      > JMPZ                                                     ~12, ->21
         19    >   QM_ASSIGN                                        ~13     'V'
         20      > JMP                                                      ->22
         21    >   QM_ASSIGN                                        ~13     'N'
         22    >   ASSIGN                                                   !3, ~13
   22    23        INIT_FCALL                                               'unpack'
         24        SEND_VAR                                                 !3
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $15     
         27        ASSIGN                                                   !4, $15
   24    28        BW_AND                                           ~17     !4, 2147483648
         29      > JMPZ_EX                                          ~17     ~17, ->33
         30    >   FETCH_CONSTANT                                   ~18     'INT_SIGNED'
         31        BW_AND                                           ~19     !1, ~18
         32        BOOL                                             ~17     ~19
         33    > > JMPZ_EX                                          ~17     ~17, ->38
         34    >   INIT_FCALL                                               'is32bit'
         35        DO_FCALL                                      0  $20     
         36        BOOL_NOT                                         ~21     $20
         37        BOOL                                             ~17     ~21
         38    > > JMPZ                                                     ~17, ->41
   25    39    >   BW_OR                                            ~22     !4, 1.84467e+19
         40        ASSIGN                                                   !4, ~22
   28    41    > > RETURN                                                   !4
   29    42*     > RETURN                                                   null

End of function unpack_int32

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.76 ms | 1407 KiB | 27 Q