3v4l.org

run code in 300+ PHP versions simultaneously
<?php function string_shift_left($input, $inputlen, $bits, &$output = null) { $skip = (int) ($bits / 8); $copylen = (int) ($inputlen - $skip); $offset = $bits % 8; $mask = (0xff >> $offset) << (8 - $offset); $output = str_pad('', $inputlen + 1, "\x00"); var_dump($skip, $copylen, $offset, $mask, $output); if ($offset == 0) { /* Shifting multiples of 8 allows us to simply copy the relevant bytes */ for ($i = 0; $i < $copylen; $i++) { $output[$i] = $input[$i + $skip]; } return; } for ($i = 0; $i < $copylen; $i++) { $left = (ord($input[$i + $skip]) << $offset); $right = (ord($input[$i + $skip + 1]) & $mask) >> $offset; printf("%08b|%08b\n", $left, $right); $output[$i] = chr($left | $right); } } //0b000100010001000100000000; string_shift_left("\x11\x11\x00", 2, 2, $output); for ($i = 0; $i < strlen($output); $i++) { printf('%08b|', ord($output[$i])); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 8
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 8
Branch analysis from position: 20
Branch analysis from position: 8
filename:       /in/XHrkR
function name:  (null)
number of ops:  21
compiled vars:  !0 = $output, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'string_shift_left'
          1        SEND_VAL                                                 '%11%11%00'
          2        SEND_VAL                                                 2
          3        SEND_VAL                                                 2
          4        SEND_REF                                                 !0
          5        DO_FCALL                                      0          
   33     6        ASSIGN                                                   !1, 0
          7      > JMP                                                      ->17
   34     8    >   INIT_FCALL                                               'printf'
          9        SEND_VAL                                                 '%2508b%7C'
         10        INIT_FCALL                                               'ord'
         11        FETCH_DIM_R                                      ~4      !0, !1
         12        SEND_VAL                                                 ~4
         13        DO_ICALL                                         $5      
         14        SEND_VAR                                                 $5
         15        DO_ICALL                                                 
   33    16        PRE_INC                                                  !1
         17    >   STRLEN                                           ~8      !0
         18        IS_SMALLER                                               !1, ~8
         19      > JMPNZ                                                    ~9, ->8
   35    20    > > RETURN                                                   1

Function string_shift_left:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 42
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 34
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 34
Branch analysis from position: 41
Branch analysis from position: 34
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 44
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 44
Branch analysis from position: 74
Branch analysis from position: 44
filename:       /in/XHrkR
function name:  string_shift_left
number of ops:  75
compiled vars:  !0 = $input, !1 = $inputlen, !2 = $bits, !3 = $output, !4 = $skip, !5 = $copylen, !6 = $offset, !7 = $mask, !8 = $i, !9 = $left, !10 = $right
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      null
    5     4        DIV                                              ~11     !2, 8
          5        CAST                                          4  ~12     ~11
          6        ASSIGN                                                   !4, ~12
    6     7        SUB                                              ~14     !1, !4
          8        CAST                                          4  ~15     ~14
          9        ASSIGN                                                   !5, ~15
    7    10        MOD                                              ~17     !2, 8
         11        ASSIGN                                                   !6, ~17
    8    12        SR                                               ~19     255, !6
         13        SUB                                              ~20     8, !6
         14        SL                                               ~21     ~19, ~20
         15        ASSIGN                                                   !7, ~21
   10    16        INIT_FCALL                                               'str_pad'
         17        SEND_VAL                                                 ''
         18        ADD                                              ~23     !1, 1
         19        SEND_VAL                                                 ~23
         20        SEND_VAL                                                 '%00'
         21        DO_ICALL                                         $24     
         22        ASSIGN                                                   !3, $24
   12    23        INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !4
         25        SEND_VAR                                                 !5
         26        SEND_VAR                                                 !6
         27        SEND_VAR                                                 !7
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                                 
   14    30        IS_EQUAL                                                 !6, 0
         31      > JMPZ                                                     ~27, ->42
   16    32    >   ASSIGN                                                   !8, 0
         33      > JMP                                                      ->39
   17    34    >   ADD                                              ~30     !8, !4
         35        FETCH_DIM_R                                      ~31     !0, ~30
         36        ASSIGN_DIM                                               !3, !8
         37        OP_DATA                                                  ~31
   16    38        PRE_INC                                                  !8
         39    >   IS_SMALLER                                               !8, !5
         40      > JMPNZ                                                    ~33, ->34
   19    41    > > RETURN                                                   null
   22    42    >   ASSIGN                                                   !8, 0
         43      > JMP                                                      ->72
   23    44    >   INIT_FCALL                                               'ord'
         45        ADD                                              ~35     !8, !4
         46        FETCH_DIM_R                                      ~36     !0, ~35
         47        SEND_VAL                                                 ~36
         48        DO_ICALL                                         $37     
         49        SL                                               ~38     $37, !6
         50        ASSIGN                                                   !9, ~38
   24    51        INIT_FCALL                                               'ord'
         52        ADD                                              ~40     !8, !4
         53        ADD                                              ~41     ~40, 1
         54        FETCH_DIM_R                                      ~42     !0, ~41
         55        SEND_VAL                                                 ~42
         56        DO_ICALL                                         $43     
         57        BW_AND                                           ~44     !7, $43
         58        SR                                               ~45     ~44, !6
         59        ASSIGN                                                   !10, ~45
   25    60        INIT_FCALL                                               'printf'
         61        SEND_VAL                                                 '%2508b%7C%2508b%0A'
         62        SEND_VAR                                                 !9
         63        SEND_VAR                                                 !10
         64        DO_ICALL                                                 
   26    65        INIT_FCALL                                               'chr'
         66        BW_OR                                            ~49     !9, !10
         67        SEND_VAL                                                 ~49
         68        DO_ICALL                                         $50     
         69        ASSIGN_DIM                                               !3, !8
         70        OP_DATA                                                  $50
   22    71        PRE_INC                                                  !8
         72    >   IS_SMALLER                                               !8, !5
         73      > JMPNZ                                                    ~52, ->44
   28    74    > > RETURN                                                   null

End of function string_shift_left

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.33 ms | 1407 KiB | 24 Q