3v4l.org

run code in 300+ PHP versions simultaneously
<?php $n = 48; //print the last n digits from mysterycode aka greyCode for($k=pow(2,$n)-$n;$k<pow(2,$n);$k++){ //echo tobin($mC[$k], $n)."\r\n<br>"; echo tobin(floatval(binaryToGray($k)),$n)."\r\n"; } function binaryToGray($num) { return $num ^ ($num >> 1); } function tobin($nr,$n){ $cnt = $n;//pow(2,$n); $converted_nr = base_convert($nr,10,2); if (strlen($converted_nr)<$cnt){ return leadZero($converted_nr,$cnt-strlen($converted_nr)-1); }else{ return $converted_nr; } } function leadZero($a,$nrZeros){ return str_pad($a, $nrZeros, "0", STR_PAD_LEFT); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 8
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 8
Branch analysis from position: 25
Branch analysis from position: 8
filename:       /in/jBrTP
function name:  (null)
number of ops:  26
compiled vars:  !0 = $n, !1 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 48
    5     1        INIT_FCALL                                               'pow'
          2        SEND_VAL                                                 2
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        SUB                                              ~4      $3, !0
          6        ASSIGN                                                   !1, ~4
          7      > JMP                                                      ->19
    7     8    >   INIT_FCALL_BY_NAME                                       'tobin'
          9        INIT_FCALL_BY_NAME                                       'binaryToGray'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0  $6      
         12        CAST                                          5  ~7      $6
         13        SEND_VAL_EX                                              ~7
         14        SEND_VAR_EX                                              !0
         15        DO_FCALL                                      0  $8      
         16        CONCAT                                           ~9      $8, '%0D%0A'
         17        ECHO                                                     ~9
    5    18        PRE_INC                                                  !1
         19    >   INIT_FCALL                                               'pow'
         20        SEND_VAL                                                 2
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $11     
         23        IS_SMALLER                                               !1, $11
         24      > JMPNZ                                                    ~12, ->8
   26    25    > > RETURN                                                   1

Function binarytogray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jBrTP
function name:  binaryToGray
number of ops:  5
compiled vars:  !0 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        SR                                               ~1      !0, 1
          2        BW_XOR                                           ~2      !0, ~1
          3      > RETURN                                                   ~2
   12     4*     > RETURN                                                   null

End of function binarytogray

Function tobin:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 21
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jBrTP
function name:  tobin
number of ops:  23
compiled vars:  !0 = $nr, !1 = $n, !2 = $cnt, !3 = $converted_nr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        ASSIGN                                                   !2, !1
   16     3        INIT_FCALL                                               'base_convert'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 10
          6        SEND_VAL                                                 2
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !3, $5
   17     9        STRLEN                                           ~7      !3
         10        IS_SMALLER                                               ~7, !2
         11      > JMPZ                                                     ~8, ->21
   18    12    >   INIT_FCALL_BY_NAME                                       'leadZero'
         13        SEND_VAR_EX                                              !3
         14        STRLEN                                           ~9      !3
         15        SUB                                              ~10     !2, ~9
         16        SUB                                              ~11     ~10, 1
         17        SEND_VAL_EX                                              ~11
         18        DO_FCALL                                      0  $12     
         19      > RETURN                                                   $12
         20*       JMP                                                      ->22
   20    21    > > RETURN                                                   !3
   23    22*     > RETURN                                                   null

End of function tobin

Function leadzero:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jBrTP
function name:  leadZero
number of ops:  10
compiled vars:  !0 = $a, !1 = $nrZeros
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   25     2        INIT_FCALL                                               'str_pad'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 '0'
          6        SEND_VAL                                                 0
          7        DO_ICALL                                         $2      
          8      > RETURN                                                   $2
   26     9*     > RETURN                                                   null

End of function leadzero

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.26 ms | 1400 KiB | 19 Q