3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dec = intval((-1 * PHP_INT_MAX) + 1); var_dump(decbin($dec), dec2bin($dec)); function dec2bin($dec) { if ($dec == 0) { return 0; } $sgn = 1; if ($dec < 0) { $sgn = -1; $dec = (PHP_INT_MAX + $dec) + 1; } $bin = ''; while ($dec > 0) { $bin = ($dec & 1) . $bin; $dec >>= 1; } return $sgn > 0 ? $bin : '1' . str_pad($bin, 63, '0', STR_PAD_LEFT); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UlGas
function name:  (null)
number of ops:  13
compiled vars:  !0 = $dec
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   CAST                                          4  ~1      -9223372036854775806
          1        ASSIGN                                                   !0, ~1
    3     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'decbin'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        SEND_VAR                                                 $3
          7        INIT_FCALL_BY_NAME                                       'dec2bin'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $4      
         10        SEND_VAR                                                 $4
         11        DO_ICALL                                                 
   22    12      > RETURN                                                   1

Function dec2bin:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 13
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 13
Branch analysis from position: 19
Branch analysis from position: 13
Branch analysis from position: 11
filename:       /in/UlGas
function name:  dec2bin
number of ops:  33
compiled vars:  !0 = $dec, !1 = $sgn, !2 = $bin
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        IS_EQUAL                                                 !0, 0
          2      > JMPZ                                                     ~3, ->4
    7     3    > > RETURN                                                   0
   10     4    >   ASSIGN                                                   !1, 1
   11     5        IS_SMALLER                                               !0, 0
          6      > JMPZ                                                     ~5, ->11
   12     7    >   ASSIGN                                                   !1, -1
   13     8        ADD                                              ~7      9223372036854775807, !0
          9        ADD                                              ~8      ~7, 1
         10        ASSIGN                                                   !0, ~8
   16    11    >   ASSIGN                                                   !2, ''
   17    12      > JMP                                                      ->17
   18    13    >   BW_AND                                           ~11     !0, 1
         14        CONCAT                                           ~12     ~11, !2
         15        ASSIGN                                                   !2, ~12
   19    16        ASSIGN_OP                                     7          !0, 1
   17    17    >   IS_SMALLER                                               0, !0
         18      > JMPNZ                                                    ~15, ->13
   21    19    >   IS_SMALLER                                               0, !1
         20      > JMPZ                                                     ~16, ->23
         21    >   QM_ASSIGN                                        ~17     !2
         22      > JMP                                                      ->31
         23    >   INIT_FCALL                                               'str_pad'
         24        SEND_VAR                                                 !2
         25        SEND_VAL                                                 63
         26        SEND_VAL                                                 '0'
         27        SEND_VAL                                                 0
         28        DO_ICALL                                         $18     
         29        CONCAT                                           ~19     '1', $18
         30        QM_ASSIGN                                        ~17     ~19
         31    > > RETURN                                                   ~17
   22    32*     > RETURN                                                   null

End of function dec2bin

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.91 ms | 1405 KiB | 19 Q