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; $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/e1VUr
function name:  (null)
number of ops:  21
compiled vars:  !0 = $output, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     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          
   27     6        ASSIGN                                                   !1, 0
          7      > JMP                                                      ->17
   28     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                                                 
   27    16        PRE_INC                                                  !1
         17    >   STRLEN                                           ~8      !0
         18        IS_SMALLER                                               !1, ~8
         19      > JMPNZ                                                    ~9, ->8
   29    20    > > RETURN                                                   1

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

End of function string_shift_left

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.8 ms | 1407 KiB | 22 Q