3v4l.org

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

End of function string_shift_left

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
327.26 ms | 1407 KiB | 25 Q