3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Roman { public $dividorsBelowTen = [0 => "", 1 => "I", 2 => "II", 3 => "III", 4 => "IV", 5 => "V", 6 => "VI", 7 => "VII", 8 => "VIII", 9 => "IX"]; public $dividorsTen = [0 => "", 1 => "X", 2 => "XX", 3 => "XXX", 4 => "XL", 5 => "L", 6 => "LX", 7 => "LXX", 8 => "LXXX", 9 => "XC"]; public $dividorsHundreds = [0 => "", 1 => "C", 2 => "CC", 3 => "CCC", 4 => "CD", 5 => "D", 6 => "DC", 7 => "DCC", 8 => "DCCC", 9 => "CM",]; public $dividorsThousands = [1 => "M", 2 => "MM", 3 => "MMM", 4 => "MMMM"]; public function transform($in) { if ($in >= 1000) { $thousand = (int)($in / 1000); $hundreds = (int)(($in - $thousand * 1000) / 100); $tens = (int)(($in - $thousand * 1000 - $hundreds * 100) / 10); $once = ($in - $thousand * 1000 - $hundreds * 100 - $tens * 10); return $this->dividorsThousands[$thousand] . $this->dividorsHundreds[$hundreds] . $this->dividorsTen[$tens] . $this->dividorsBelowTen[$once]; } else if ($in >= 100) { $hundreds = (int)($in / 100); $tens = (int)(($in - $hundreds * 100) / 10); $once = ($in - $hundreds * 100 - $tens * 10); return $this->dividorsHundreds[$hundreds] . $this->dividorsTen[$tens] . $this->dividorsBelowTen[$once]; } else if ($in >= 10) { $once = $in % 10; $tens = (int)($in / 10); return $this->dividorsTen[$tens] . $this->dividorsBelowTen[$once]; } else { return $this->dividorsBelowTen[$in]; } } } $r = new Roman(); for ($i = 1; $i < 5000; $i++) { $r->transform($i); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 5
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 5
Branch analysis from position: 11
Branch analysis from position: 5
filename:       /in/dCBT7
function name:  (null)
number of ops:  12
compiled vars:  !0 = $r, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   NEW                                              $2      'Roman'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   42     3        ASSIGN                                                   !1, 1
          4      > JMP                                                      ->9
   43     5    >   INIT_METHOD_CALL                                         !0, 'transform'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
   42     8        PRE_INC                                                  !1
          9    >   IS_SMALLER                                               !1, 5000
         10      > JMPNZ                                                    ~8, ->5
   44    11    > > RETURN                                                   1

Class Roman:
Function transform:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 38
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 63
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 77
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dCBT7
function name:  transform
number of ops:  81
compiled vars:  !0 = $in, !1 = $thousand, !2 = $hundreds, !3 = $tens, !4 = $once
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        IS_SMALLER_OR_EQUAL                                      1000, !0
          2      > JMPZ                                                     ~5, ->38
   17     3    >   DIV                                              ~6      !0, 1000
          4        CAST                                          4  ~7      ~6
          5        ASSIGN                                                   !1, ~7
   18     6        MUL                                              ~9      !1, 1000
          7        SUB                                              ~10     !0, ~9
          8        DIV                                              ~11     ~10, 100
          9        CAST                                          4  ~12     ~11
         10        ASSIGN                                                   !2, ~12
   19    11        MUL                                              ~14     !1, 1000
         12        SUB                                              ~15     !0, ~14
         13        MUL                                              ~16     !2, 100
         14        SUB                                              ~17     ~15, ~16
         15        DIV                                              ~18     ~17, 10
         16        CAST                                          4  ~19     ~18
         17        ASSIGN                                                   !3, ~19
   20    18        MUL                                              ~21     !1, 1000
         19        SUB                                              ~22     !0, ~21
         20        MUL                                              ~23     !2, 100
         21        SUB                                              ~24     ~22, ~23
         22        MUL                                              ~25     !3, 10
         23        SUB                                              ~26     ~24, ~25
         24        ASSIGN                                                   !4, ~26
   21    25        FETCH_OBJ_R                                      ~28     'dividorsThousands'
         26        FETCH_DIM_R                                      ~29     ~28, !1
         27        FETCH_OBJ_R                                      ~30     'dividorsHundreds'
         28        FETCH_DIM_R                                      ~31     ~30, !2
         29        CONCAT                                           ~32     ~29, ~31
         30        FETCH_OBJ_R                                      ~33     'dividorsTen'
         31        FETCH_DIM_R                                      ~34     ~33, !3
         32        CONCAT                                           ~35     ~32, ~34
         33        FETCH_OBJ_R                                      ~36     'dividorsBelowTen'
         34        FETCH_DIM_R                                      ~37     ~36, !4
         35        CONCAT                                           ~38     ~35, ~37
         36      > RETURN                                                   ~38
         37*       JMP                                                      ->80
   23    38    >   IS_SMALLER_OR_EQUAL                                      100, !0
         39      > JMPZ                                                     ~39, ->63
   24    40    >   DIV                                              ~40     !0, 100
         41        CAST                                          4  ~41     ~40
         42        ASSIGN                                                   !2, ~41
   25    43        MUL                                              ~43     !2, 100
         44        SUB                                              ~44     !0, ~43
         45        DIV                                              ~45     ~44, 10
         46        CAST                                          4  ~46     ~45
         47        ASSIGN                                                   !3, ~46
   26    48        MUL                                              ~48     !2, 100
         49        SUB                                              ~49     !0, ~48
         50        MUL                                              ~50     !3, 10
         51        SUB                                              ~51     ~49, ~50
         52        ASSIGN                                                   !4, ~51
   28    53        FETCH_OBJ_R                                      ~53     'dividorsHundreds'
         54        FETCH_DIM_R                                      ~54     ~53, !2
         55        FETCH_OBJ_R                                      ~55     'dividorsTen'
         56        FETCH_DIM_R                                      ~56     ~55, !3
         57        CONCAT                                           ~57     ~54, ~56
         58        FETCH_OBJ_R                                      ~58     'dividorsBelowTen'
         59        FETCH_DIM_R                                      ~59     ~58, !4
         60        CONCAT                                           ~60     ~57, ~59
         61      > RETURN                                                   ~60
         62*       JMP                                                      ->80
   30    63    >   IS_SMALLER_OR_EQUAL                                      10, !0
         64      > JMPZ                                                     ~61, ->77
   31    65    >   MOD                                              ~62     !0, 10
         66        ASSIGN                                                   !4, ~62
   32    67        DIV                                              ~64     !0, 10
         68        CAST                                          4  ~65     ~64
         69        ASSIGN                                                   !3, ~65
   33    70        FETCH_OBJ_R                                      ~67     'dividorsTen'
         71        FETCH_DIM_R                                      ~68     ~67, !3
         72        FETCH_OBJ_R                                      ~69     'dividorsBelowTen'
         73        FETCH_DIM_R                                      ~70     ~69, !4
         74        CONCAT                                           ~71     ~68, ~70
         75      > RETURN                                                   ~71
         76*       JMP                                                      ->80
   35    77    >   FETCH_OBJ_R                                      ~72     'dividorsBelowTen'
         78        FETCH_DIM_R                                      ~73     ~72, !0
         79      > RETURN                                                   ~73
   37    80*     > RETURN                                                   null

End of function transform

End of class Roman.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.49 ms | 1403 KiB | 13 Q