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) << $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); printf("%08b|%08b\n", $left, $right); $output[$i] = chr($left | $right); } } string_shift_left("\x11\x11\x00", 2, 7, $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/bXm0Y
function name:  (null)
number of ops:  21
compiled vars:  !0 = $output, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_FCALL                                               'string_shift_left'
          1        SEND_VAL                                                 '%11%11%00'
          2        SEND_VAL                                                 2
          3        SEND_VAL                                                 7
          4        SEND_REF                                                 !0
          5        DO_FCALL                                      0          
   32     6        ASSIGN                                                   !1, 0
          7      > JMP                                                      ->17
   33     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                                                 
   32    16        PRE_INC                                                  !1
         17    >   STRLEN                                           ~8      !0
         18        IS_SMALLER                                               !1, ~8
         19      > JMPNZ                                                    ~9, ->8
   34    20    > > RETURN                                                   1

Function string_shift_left:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 41
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 33
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 33
Branch analysis from position: 40
Branch analysis from position: 33
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 43
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 43
Branch analysis from position: 72
Branch analysis from position: 43
filename:       /in/bXm0Y
function name:  string_shift_left
number of ops:  73
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        SL                                               ~20     ~19, !6
         14        ASSIGN                                                   !7, ~20
   10    15        INIT_FCALL                                               'str_pad'
         16        SEND_VAL                                                 ''
         17        ADD                                              ~22     !1, 1
         18        SEND_VAL                                                 ~22
         19        SEND_VAL                                                 '%00'
         20        DO_ICALL                                         $23     
         21        ASSIGN                                                   !3, $23
   12    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !4
         24        SEND_VAR                                                 !5
         25        SEND_VAR                                                 !6
         26        SEND_VAR                                                 !7
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                                 
   14    29        IS_EQUAL                                                 !6, 0
         30      > JMPZ                                                     ~26, ->41
   16    31    >   ASSIGN                                                   !8, 0
         32      > JMP                                                      ->38
   17    33    >   ADD                                              ~29     !8, !4
         34        FETCH_DIM_R                                      ~30     !0, ~29
         35        ASSIGN_DIM                                               !3, !8
         36        OP_DATA                                                  ~30
   16    37        PRE_INC                                                  !8
         38    >   IS_SMALLER                                               !8, !5
         39      > JMPNZ                                                    ~32, ->33
   19    40    > > RETURN                                                   null
   22    41    >   ASSIGN                                                   !8, 0
         42      > JMP                                                      ->70
   23    43    >   INIT_FCALL                                               'ord'
         44        ADD                                              ~34     !8, !4
         45        FETCH_DIM_R                                      ~35     !0, ~34
         46        SEND_VAL                                                 ~35
         47        DO_ICALL                                         $36     
         48        SL                                               ~37     $36, !6
         49        ASSIGN                                                   !9, ~37
   24    50        INIT_FCALL                                               'ord'
         51        ADD                                              ~39     !8, !4
         52        ADD                                              ~40     ~39, 1
         53        FETCH_DIM_R                                      ~41     !0, ~40
         54        SEND_VAL                                                 ~41
         55        DO_ICALL                                         $42     
         56        BW_AND                                           ~43     !7, $42
         57        ASSIGN                                                   !10, ~43
   25    58        INIT_FCALL                                               'printf'
         59        SEND_VAL                                                 '%2508b%7C%2508b%0A'
         60        SEND_VAR                                                 !9
         61        SEND_VAR                                                 !10
         62        DO_ICALL                                                 
   26    63        INIT_FCALL                                               'chr'
         64        BW_OR                                            ~47     !9, !10
         65        SEND_VAL                                                 ~47
         66        DO_ICALL                                         $48     
         67        ASSIGN_DIM                                               !3, !8
         68        OP_DATA                                                  $48
   22    69        PRE_INC                                                  !8
         70    >   IS_SMALLER                                               !8, !5
         71      > JMPNZ                                                    ~50, ->43
   28    72    > > RETURN                                                   null

End of function string_shift_left

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.93 ms | 1407 KiB | 24 Q