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 = 8 - ($bits % 8); $mask = 0xff >> $offset; var_dump($skip, $copylen, $offset, $mask); $output = str_pad('', $inputlen + 1, "\x00"); if ($offset == 8) { /* 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++) { $output[$i] = chr((ord($input[$i + $skip]) << $offset) | (ord($input[$i + $skip + 1]) & $mask)); } } string_shift_left("\x01", 1, 3, $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/WSshR
function name:  (null)
number of ops:  21
compiled vars:  !0 = $output, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'string_shift_left'
          1        SEND_VAL                                                 '%01'
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 3
          4        SEND_REF                                                 !0
          5        DO_FCALL                                      0          
   29     6        ASSIGN                                                   !1, 0
          7      > JMP                                                      ->17
   30     8    >   INIT_FCALL                                               'printf'
          9        SEND_VAL                                                 '%2508b'
         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                                                 
   29    16        PRE_INC                                                  !1
         17    >   STRLEN                                           ~8      !0
         18        IS_SMALLER                                               !1, ~8
         19      > JMPNZ                                                    ~9, ->8
   31    20    > > RETURN                                                   1

Function string_shift_left:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 40
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 32
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 32
Branch analysis from position: 39
Branch analysis from position: 32
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
2 jumps found. (Code = 44) Position 1 = 64, Position 2 = 42
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 64, Position 2 = 42
Branch analysis from position: 64
Branch analysis from position: 42
filename:       /in/WSshR
function name:  string_shift_left
number of ops:  65
compiled vars:  !0 = $input, !1 = $inputlen, !2 = $bits, !3 = $output, !4 = $skip, !5 = $copylen, !6 = $offset, !7 = $mask, !8 = $i
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        CAST                                          4  ~9      !2
          5        DIV                                              ~10     ~9, 8
          6        ASSIGN                                                   !4, ~10
    6     7        CAST                                          4  ~12     !1
          8        SUB                                              ~13     ~12, !4
          9        ASSIGN                                                   !5, ~13
    7    10        MOD                                              ~15     !2, 8
         11        SUB                                              ~16     8, ~15
         12        ASSIGN                                                   !6, ~16
    8    13        SR                                               ~18     255, !6
         14        ASSIGN                                                   !7, ~18
   10    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !4
         17        SEND_VAR                                                 !5
         18        SEND_VAR                                                 !6
         19        SEND_VAR                                                 !7
         20        DO_ICALL                                                 
   12    21        INIT_FCALL                                               'str_pad'
         22        SEND_VAL                                                 ''
         23        ADD                                              ~21     !1, 1
         24        SEND_VAL                                                 ~21
         25        SEND_VAL                                                 '%00'
         26        DO_ICALL                                         $22     
         27        ASSIGN                                                   !3, $22
   14    28        IS_EQUAL                                                 !6, 8
         29      > JMPZ                                                     ~24, ->40
   16    30    >   ASSIGN                                                   !8, 0
         31      > JMP                                                      ->37
   17    32    >   ADD                                              ~27     !8, !4
         33        FETCH_DIM_R                                      ~28     !0, ~27
         34        ASSIGN_DIM                                               !3, !8
         35        OP_DATA                                                  ~28
   16    36        PRE_INC                                                  !8
         37    >   IS_SMALLER                                               !8, !5
         38      > JMPNZ                                                    ~30, ->32
   19    39    > > RETURN                                                   null
   22    40    >   ASSIGN                                                   !8, 0
         41      > JMP                                                      ->62
   23    42    >   INIT_FCALL                                               'chr'
         43        INIT_FCALL                                               'ord'
         44        ADD                                              ~33     !8, !4
         45        FETCH_DIM_R                                      ~34     !0, ~33
         46        SEND_VAL                                                 ~34
         47        DO_ICALL                                         $35     
         48        SL                                               ~36     $35, !6
         49        INIT_FCALL                                               'ord'
         50        ADD                                              ~37     !8, !4
         51        ADD                                              ~38     ~37, 1
         52        FETCH_DIM_R                                      ~39     !0, ~38
         53        SEND_VAL                                                 ~39
         54        DO_ICALL                                         $40     
         55        BW_AND                                           ~41     !7, $40
         56        BW_OR                                            ~42     ~36, ~41
         57        SEND_VAL                                                 ~42
         58        DO_ICALL                                         $43     
         59        ASSIGN_DIM                                               !3, !8
         60        OP_DATA                                                  $43
   22    61        PRE_INC                                                  !8
         62    >   IS_SMALLER                                               !8, !5
         63      > JMPNZ                                                    ~45, ->42
   25    64    > > RETURN                                                   null

End of function string_shift_left

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.6 ms | 1398 KiB | 24 Q