3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gdr_encode($val) { $str = ''; while ($val > 0) { $str .= chr($val & 0xFF); $val = $val >> 8; } return str_replace(array('/', '='), array('_', ''), base64_encode($str)); } function gdr_decode($bin) { $str = base64_decode(str_replace('_', '/', $bin)); $val = 0; for ($i=0; $i<strlen($str); $i++) { $val |= ord($str[$i]) << $i*8; } return $val; } for ($i=0; $i<32; $i++) { $val = 1<<$i; $enc = gdr_encode($val); $dec = gdr_decode($enc); echo "$val => $enc => $dec\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 2
Branch analysis from position: 22
Branch analysis from position: 2
filename:       /in/FQAKJ
function name:  (null)
number of ops:  23
compiled vars:  !0 = $i, !1 = $val, !2 = $enc, !3 = $dec
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->20
   22     2    >   SL                                               ~5      1, !0
          3        ASSIGN                                                   !1, ~5
   23     4        INIT_FCALL                                               'gdr_encode'
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $7      
          7        ASSIGN                                                   !2, $7
   24     8        INIT_FCALL                                               'gdr_decode'
          9        SEND_VAR                                                 !2
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !3, $9
   25    12        ROPE_INIT                                     6  ~12     !1
         13        ROPE_ADD                                      1  ~12     ~12, '+%3D%3E+'
         14        ROPE_ADD                                      2  ~12     ~12, !2
         15        ROPE_ADD                                      3  ~12     ~12, '+%3D%3E+'
         16        ROPE_ADD                                      4  ~12     ~12, !3
         17        ROPE_END                                      5  ~11     ~12, '%0A'
         18        ECHO                                                     ~11
   21    19        PRE_INC                                                  !0
         20    >   IS_SMALLER                                               !0, 32
         21      > JMPNZ                                                    ~16, ->2
   26    22    > > RETURN                                                   1

Function gdr_encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
Branch analysis from position: 3
filename:       /in/FQAKJ
function name:  gdr_encode
number of ops:  22
compiled vars:  !0 = $val, !1 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, ''
    5     2      > JMP                                                      ->10
    6     3    >   INIT_FCALL                                               'chr'
          4        BW_AND                                           ~3      !0, 255
          5        SEND_VAL                                                 ~3
          6        DO_ICALL                                         $4      
          7        ASSIGN_OP                                     8          !1, $4
    7     8        SR                                               ~6      !0, 8
          9        ASSIGN                                                   !0, ~6
    5    10    >   IS_SMALLER                                               0, !0
         11      > JMPNZ                                                    ~8, ->3
    9    12    >   INIT_FCALL                                               'str_replace'
         13        SEND_VAL                                                 <array>
         14        SEND_VAL                                                 <array>
         15        INIT_FCALL                                               'base64_encode'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                         $10     
         20      > RETURN                                                   $10
   10    21*     > RETURN                                                   null

End of function gdr_encode

Function gdr_decode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 13
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 13
Branch analysis from position: 24
Branch analysis from position: 13
filename:       /in/FQAKJ
function name:  gdr_decode
number of ops:  26
compiled vars:  !0 = $bin, !1 = $str, !2 = $val, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'base64_decode'
          2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 '_'
          4        SEND_VAL                                                 '%2F'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !1, $5
   14    10        ASSIGN                                                   !2, 0
   15    11        ASSIGN                                                   !3, 0
         12      > JMP                                                      ->21
   16    13    >   INIT_FCALL                                               'ord'
         14        FETCH_DIM_R                                      ~9      !1, !3
         15        SEND_VAL                                                 ~9
         16        DO_ICALL                                         $10     
         17        MUL                                              ~11     !3, 8
         18        SL                                               ~12     $10, ~11
         19        ASSIGN_OP                                     9          !2, ~12
   15    20        PRE_INC                                                  !3
         21    >   STRLEN                                           ~15     !1
         22        IS_SMALLER                                               !3, ~15
         23      > JMPNZ                                                    ~16, ->13
   18    24    > > RETURN                                                   !2
   19    25*     > RETURN                                                   null

End of function gdr_decode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.5 ms | 1403 KiB | 25 Q