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; $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++) { $output[$i] = chr((ord($input[$i + $skip]) << $offset) | (ord($input[$i + $skip + 1]) & $mask)); } } string_shift_left("\x01\x00", 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/qooBI
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%00'
          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%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                                                 
   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/qooBI
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        DIV                                              ~9      !2, 8
          5        CAST                                          4  ~10     ~9
          6        ASSIGN                                                   !4, ~10
    6     7        SUB                                              ~12     !1, !4
          8        CAST                                          4  ~13     ~12
          9        ASSIGN                                                   !5, ~13
    7    10        MOD                                              ~15     !2, 8
         11        ASSIGN                                                   !6, ~15
    8    12        SR                                               ~17     255, !6
         13        ASSIGN                                                   !7, ~17
   10    14        INIT_FCALL                                               'str_pad'
         15        SEND_VAL                                                 ''
         16        ADD                                              ~19     !1, 1
         17        SEND_VAL                                                 ~19
         18        SEND_VAL                                                 '%00'
         19        DO_ICALL                                         $20     
         20        ASSIGN                                                   !3, $20
   12    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !4
         23        SEND_VAR                                                 !5
         24        SEND_VAR                                                 !6
         25        SEND_VAR                                                 !7
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                                 
   14    28        IS_EQUAL                                                 !6, 0
         29      > JMPZ                                                     ~23, ->40
   16    30    >   ASSIGN                                                   !8, 0
         31      > JMP                                                      ->37
   17    32    >   ADD                                              ~26     !8, !4
         33        FETCH_DIM_R                                      ~27     !0, ~26
         34        ASSIGN_DIM                                               !3, !8
         35        OP_DATA                                                  ~27
   16    36        PRE_INC                                                  !8
         37    >   IS_SMALLER                                               !8, !5
         38      > JMPNZ                                                    ~29, ->32
   19    39    > > RETURN                                                   null
   22    40    >   ASSIGN                                                   !8, 0
         41      > JMP                                                      ->62
   23    42    >   INIT_FCALL                                               'chr'
         43        INIT_FCALL                                               'ord'
         44        ADD                                              ~32     !8, !4
         45        FETCH_DIM_R                                      ~33     !0, ~32
         46        SEND_VAL                                                 ~33
         47        DO_ICALL                                         $34     
         48        SL                                               ~35     $34, !6
         49        INIT_FCALL                                               'ord'
         50        ADD                                              ~36     !8, !4
         51        ADD                                              ~37     ~36, 1
         52        FETCH_DIM_R                                      ~38     !0, ~37
         53        SEND_VAL                                                 ~38
         54        DO_ICALL                                         $39     
         55        BW_AND                                           ~40     !7, $39
         56        BW_OR                                            ~41     ~35, ~40
         57        SEND_VAL                                                 ~41
         58        DO_ICALL                                         $42     
         59        ASSIGN_DIM                                               !3, !8
         60        OP_DATA                                                  $42
   22    61        PRE_INC                                                  !8
         62    >   IS_SMALLER                                               !8, !5
         63      > JMPNZ                                                    ~44, ->42
   25    64    > > RETURN                                                   null

End of function string_shift_left

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.82 ms | 1407 KiB | 24 Q