3v4l.org

run code in 300+ PHP versions simultaneously
<?php function romToDec ($dec) { $return = ''; while ($dec >= 1000) { $dec -= 1000; $return .= 'M'; } if ($dec >= 900) { $dec -= 900; $return .= 'CM'; } if ($dec >= 500) { $dec -= 500; $return .= 'D'; } if ($dec >= 400) { $dec -= 400; $return .= 'CD'; } while ($dec >= 100) { $dec -= 100; $return .= 'C'; } if ($dec >= 90) { $dec -= 90; $return .= 'XC'; } if ($dec >= 50) { $dec -= 50; $return .= 'L'; } if ($dec >= 40) { $dec -= 40; $return .= 'XL'; } while ($dec >= 10) { $dec -= 10; $return .= 'X'; } if ($dec == 9) { $dec = 0; $return .= 'IX'; } if ($dec >= 5) { $dec -= 5; $return .= 'V'; } if ($dec == 4) { $dec = 0; $return .= 'IV'; } while ($dec >= 1) { $dec -= 1; $return .= 'I'; } return $return; } $tests = array(1, 999, 2016, 23458, 104696); foreach ($tests as $test) { echo $test.' → '.romToDec($test)."\n"; } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 11
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/f9cin
function name:  (null)
number of ops:  13
compiled vars:  !0 = $tests, !1 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   75     0  E >   ASSIGN                                                   !0, <array>
   76     1      > FE_RESET_R                                       $3      !0, ->11
          2    > > FE_FETCH_R                                               $3, !1, ->11
   77     3    >   CONCAT                                           ~4      !1, '+%E2%86%92+'
          4        INIT_FCALL                                               'romtodec'
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $5      
          7        CONCAT                                           ~6      ~4, $5
          8        CONCAT                                           ~7      ~6, '%0A'
          9        ECHO                                                     ~7
   76    10      > JMP                                                      ->2
         11    >   FE_FREE                                                  $3
   79    12      > RETURN                                                   1

Function romtodec:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 3
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 20
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 36
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 37
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 45
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 49
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 53
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 54
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 54
Branch analysis from position: 58
Branch analysis from position: 54
Branch analysis from position: 53
Branch analysis from position: 49
Branch analysis from position: 45
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 37
Branch analysis from position: 41
Branch analysis from position: 37
Branch analysis from position: 36
Branch analysis from position: 32
Branch analysis from position: 28
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 20
Branch analysis from position: 24
Branch analysis from position: 20
Branch analysis from position: 19
Branch analysis from position: 15
Branch analysis from position: 11
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 3
Branch analysis from position: 7
Branch analysis from position: 3
filename:       /in/f9cin
function name:  romToDec
number of ops:  60
compiled vars:  !0 = $dec, !1 = $return
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, ''
    5     2      > JMP                                                      ->5
    6     3    >   ASSIGN_OP                                     2          !0, 1000
    7     4        ASSIGN_OP                                     8          !1, 'M'
    5     5    >   IS_SMALLER_OR_EQUAL                                      1000, !0
          6      > JMPNZ                                                    ~5, ->3
   10     7    >   IS_SMALLER_OR_EQUAL                                      900, !0
          8      > JMPZ                                                     ~6, ->11
   11     9    >   ASSIGN_OP                                     2          !0, 900
   12    10        ASSIGN_OP                                     8          !1, 'CM'
   15    11    >   IS_SMALLER_OR_EQUAL                                      500, !0
         12      > JMPZ                                                     ~9, ->15
   16    13    >   ASSIGN_OP                                     2          !0, 500
   17    14        ASSIGN_OP                                     8          !1, 'D'
   20    15    >   IS_SMALLER_OR_EQUAL                                      400, !0
         16      > JMPZ                                                     ~12, ->19
   21    17    >   ASSIGN_OP                                     2          !0, 400
   22    18        ASSIGN_OP                                     8          !1, 'CD'
   25    19    > > JMP                                                      ->22
   26    20    >   ASSIGN_OP                                     2          !0, 100
   27    21        ASSIGN_OP                                     8          !1, 'C'
   25    22    >   IS_SMALLER_OR_EQUAL                                      100, !0
         23      > JMPNZ                                                    ~17, ->20
   30    24    >   IS_SMALLER_OR_EQUAL                                      90, !0
         25      > JMPZ                                                     ~18, ->28
   31    26    >   ASSIGN_OP                                     2          !0, 90
   32    27        ASSIGN_OP                                     8          !1, 'XC'
   35    28    >   IS_SMALLER_OR_EQUAL                                      50, !0
         29      > JMPZ                                                     ~21, ->32
   36    30    >   ASSIGN_OP                                     2          !0, 50
   37    31        ASSIGN_OP                                     8          !1, 'L'
   40    32    >   IS_SMALLER_OR_EQUAL                                      40, !0
         33      > JMPZ                                                     ~24, ->36
   41    34    >   ASSIGN_OP                                     2          !0, 40
   42    35        ASSIGN_OP                                     8          !1, 'XL'
   45    36    > > JMP                                                      ->39
   46    37    >   ASSIGN_OP                                     2          !0, 10
   47    38        ASSIGN_OP                                     8          !1, 'X'
   45    39    >   IS_SMALLER_OR_EQUAL                                      10, !0
         40      > JMPNZ                                                    ~29, ->37
   50    41    >   IS_EQUAL                                                 !0, 9
         42      > JMPZ                                                     ~30, ->45
   51    43    >   ASSIGN                                                   !0, 0
   52    44        ASSIGN_OP                                     8          !1, 'IX'
   55    45    >   IS_SMALLER_OR_EQUAL                                      5, !0
         46      > JMPZ                                                     ~33, ->49
   56    47    >   ASSIGN_OP                                     2          !0, 5
   57    48        ASSIGN_OP                                     8          !1, 'V'
   60    49    >   IS_EQUAL                                                 !0, 4
         50      > JMPZ                                                     ~36, ->53
   61    51    >   ASSIGN                                                   !0, 0
   62    52        ASSIGN_OP                                     8          !1, 'IV'
   65    53    > > JMP                                                      ->56
   66    54    >   ASSIGN_OP                                     2          !0, 1
   67    55        ASSIGN_OP                                     8          !1, 'I'
   65    56    >   IS_SMALLER_OR_EQUAL                                      1, !0
         57      > JMPNZ                                                    ~41, ->54
   70    58    > > RETURN                                                   !1
   71    59*     > RETURN                                                   null

End of function romtodec

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.42 ms | 1411 KiB | 14 Q