3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_baseconvert($str, $frombase=16, $tobase=36) { $str = trim($str); if (intval($frombase) != 10) { $len = strlen($str); $q = 0; for ($i=0; $i<$len; $i++) { $r = base_convert($str[$i], $frombase, 10); $q = bcadd(bcmul($q, $frombase), $r); } } else $q = $str; if (intval($tobase) != 10) { $s = ''; while (bccomp($q, '0', 0) > 0) { $r = intval(bcmod($q, $tobase)); $s = base_convert($r, 10, $tobase) . $s; $q = bcdiv($q, $tobase, 0); } } else $s = $q; return $s; } $base16string = '5576F4CE68664C0000000000000000000000000'; $base36string = str_baseconvert($base16string,16,36); echo $base36string;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jRFaB
function name:  (null)
number of ops:  9
compiled vars:  !0 = $base16string, !1 = $base36string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ASSIGN                                                   !0, '5576F4CE68664C0000000000000000000000000'
   28     1        INIT_FCALL                                               'str_baseconvert'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 16
          4        SEND_VAL                                                 36
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !1, $3
   29     7        ECHO                                                     !1
          8      > RETURN                                                   1

Function str_baseconvert:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 35
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 15
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 68
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 41
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 41
Branch analysis from position: 67
Branch analysis from position: 41
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 15
Branch analysis from position: 34
Branch analysis from position: 15
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 68
Branch analysis from position: 39
Branch analysis from position: 68
filename:       /in/jRFaB
function name:  str_baseconvert
number of ops:  71
compiled vars:  !0 = $str, !1 = $frombase, !2 = $tobase, !3 = $len, !4 = $q, !5 = $i, !6 = $r, !7 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      16
          2        RECV_INIT                                        !2      36
    4     3        INIT_FCALL                                               'trim'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $8      
          6        ASSIGN                                                   !0, $8
    5     7        CAST                                          4  ~10     !1
          8        IS_NOT_EQUAL                                             ~10, 10
          9      > JMPZ                                                     ~11, ->35
    6    10    >   STRLEN                                           ~12     !0
         11        ASSIGN                                                   !3, ~12
    7    12        ASSIGN                                                   !4, 0
    8    13        ASSIGN                                                   !5, 0
         14      > JMP                                                      ->32
    9    15    >   INIT_FCALL                                               'base_convert'
         16        FETCH_DIM_R                                      ~16     !0, !5
         17        SEND_VAL                                                 ~16
         18        SEND_VAR                                                 !1
         19        SEND_VAL                                                 10
         20        DO_ICALL                                         $17     
         21        ASSIGN                                                   !6, $17
   10    22        INIT_FCALL_BY_NAME                                       'bcadd'
         23        INIT_FCALL_BY_NAME                                       'bcmul'
         24        SEND_VAR_EX                                              !4
         25        SEND_VAR_EX                                              !1
         26        DO_FCALL                                      0  $19     
         27        SEND_VAR_NO_REF_EX                                       $19
         28        SEND_VAR_EX                                              !6
         29        DO_FCALL                                      0  $20     
         30        ASSIGN                                                   !4, $20
    8    31        PRE_INC                                                  !5
         32    >   IS_SMALLER                                               !5, !3
         33      > JMPNZ                                                    ~23, ->15
         34    > > JMP                                                      ->36
   13    35    >   ASSIGN                                                   !4, !0
   15    36    >   CAST                                          4  ~25     !2
         37        IS_NOT_EQUAL                                             ~25, 10
         38      > JMPZ                                                     ~26, ->68
   16    39    >   ASSIGN                                                   !7, ''
   17    40      > JMP                                                      ->60
   18    41    >   INIT_FCALL_BY_NAME                                       'bcmod'
         42        SEND_VAR_EX                                              !4
         43        SEND_VAR_EX                                              !2
         44        DO_FCALL                                      0  $28     
         45        CAST                                          4  ~29     $28
         46        ASSIGN                                                   !6, ~29
   19    47        INIT_FCALL                                               'base_convert'
         48        SEND_VAR                                                 !6
         49        SEND_VAL                                                 10
         50        SEND_VAR                                                 !2
         51        DO_ICALL                                         $31     
         52        CONCAT                                           ~32     $31, !7
         53        ASSIGN                                                   !7, ~32
   20    54        INIT_FCALL_BY_NAME                                       'bcdiv'
         55        SEND_VAR_EX                                              !4
         56        SEND_VAR_EX                                              !2
         57        SEND_VAL_EX                                              0
         58        DO_FCALL                                      0  $34     
         59        ASSIGN                                                   !4, $34
   17    60    >   INIT_FCALL_BY_NAME                                       'bccomp'
         61        SEND_VAR_EX                                              !4
         62        SEND_VAL_EX                                              '0'
         63        SEND_VAL_EX                                              0
         64        DO_FCALL                                      0  $36     
         65        IS_SMALLER                                               0, $36
         66      > JMPNZ                                                    ~37, ->41
         67    > > JMP                                                      ->69
   23    68    >   ASSIGN                                                   !7, !4
   25    69    > > RETURN                                                   !7
   26    70*     > RETURN                                                   null

End of function str_baseconvert

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.06 ms | 1407 KiB | 18 Q