3v4l.org

run code in 500+ PHP versions simultaneously
<?php function dechex_size($val, $size) { if ($size < 1) { error_log("Invalid value for $size"); return false; } $bits = $size << 2; if ($bits > log(PHP_INT_MAX, 2)) { return dechex($val); } $mask = 0; for ($i = 0; $i < $size; ++$i) { $mask = ($mask << 4) | 0xF; } $val &= $mask; return sprintf("%x", $val); } echo dechex_size(15,4), "\n"; // gives 000f echo dechex_size(-1,16), "\n"; // gives ffffffffffffffff echo dechex_size(-1,2), "\n"; // gives ff echo dechex_size(1025,2), "\n"; // gives ? (either 401, 01, ff, or false)
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8J7Nk
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                                   'dechex_size'
          1        SEND_VAL                                                     15
          2        SEND_VAL                                                     4
          3        DO_FCALL                                          0  $0      
          4        ECHO                                                         $0
          5        ECHO                                                         '%0A'
   24     6        INIT_FCALL                                                   'dechex_size'
          7        SEND_VAL                                                     -1
          8        SEND_VAL                                                     16
          9        DO_FCALL                                          0  $1      
         10        ECHO                                                         $1
         11        ECHO                                                         '%0A'
   25    12        INIT_FCALL                                                   'dechex_size'
         13        SEND_VAL                                                     -1
         14        SEND_VAL                                                     2
         15        DO_FCALL                                          0  $2      
         16        ECHO                                                         $2
         17        ECHO                                                         '%0A'
   26    18        INIT_FCALL                                                   'dechex_size'
         19        SEND_VAL                                                     1025
         20        SEND_VAL                                                     2
         21        DO_FCALL                                          0  $3      
         22        ECHO                                                         $3
         23        ECHO                                                         '%0A'
         24      > RETURN                                                       1

Function dechex_size:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 23
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 23
Branch analysis from position: 29
Branch analysis from position: 23
filename:       /in/8J7Nk
function name:  dechex_size
number of ops:  36
compiled vars:  !0 = $val, !1 = $size, !2 = $bits, !3 = $mask, !4 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    4     2        IS_SMALLER                                                   !1, 1
          3      > JMPZ                                                         ~5, ->10
    5     4    >   INIT_FCALL                                                   'error_log'
          5        NOP                                                          
          6        FAST_CONCAT                                          ~6      'Invalid+value+for+', !1
          7        SEND_VAL                                                     ~6
          8        DO_ICALL                                                     
    6     9      > RETURN                                                       <false>
    9    10    >   SL                                                   ~8      !1, 2
         11        ASSIGN                                                       !2, ~8
   10    12        INIT_FCALL                                                   'log'
         13        SEND_VAL                                                     9223372036854775807
         14        SEND_VAL                                                     2
         15        DO_ICALL                                             $10     
         16        IS_SMALLER                                                   $10, !2
         17      > JMPZ                                                         ~11, ->20
   11    18    >   FRAMELESS_ICALL_1                dechex              ~12     !0
         19      > RETURN                                                       ~12
   14    20    >   ASSIGN                                                       !3, 0
   15    21        ASSIGN                                                       !4, 0
         22      > JMP                                                          ->27
   16    23    >   SL                                                   ~15     !3, 4
         24        BW_OR                                                ~16     ~15, 15
         25        ASSIGN                                                       !3, ~16
   15    26        PRE_INC                                                      !4
         27    >   IS_SMALLER                                                   !4, !1
         28      > JMPNZ                                                        ~19, ->23
   19    29    >   ASSIGN_OP                                        10          !0, !3
   20    30        INIT_FCALL                                                   'sprintf'
         31        SEND_VAL                                                     '%25x'
         32        SEND_VAR                                                     !0
         33        DO_ICALL                                             $21     
         34      > RETURN                                                       $21
   21    35*     > RETURN                                                       null

End of function dechex_size

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.69 ms | 2555 KiB | 22 Q