3v4l.org

run code in 300+ PHP versions simultaneously
<?php function rome($N) { // support for numbers greater than a thousand $ss = ''; while ($N > 1000) { $ss .= 'M'; $N -= 1000; } $c = 'IVXLCDM'; for ($a = 5, $b = 0, $s = ''; $N; $b++, $a ^= 7) for ($o = $N % $a, $N = (int) ($N / ($a ^ 0)); $o--; ) { $s = $c[$o > 2 ? $b + $N - ($N &= -2) + $o = 1 : $b] . $s; } return $ss.$s; } echo rome(3333); echo "\n---\n"; echo rome(5000);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HnMGO
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'rome'
          1        SEND_VAL                                                 3333
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   20     4        ECHO                                                     '%0A---%0A'
   21     5        INIT_FCALL                                               'rome'
          6        SEND_VAL                                                 5000
          7        DO_FCALL                                      0  $1      
          8        ECHO                                                     $1
          9      > RETURN                                                   1

Function rome:
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
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 12
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 19
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 12
Branch analysis from position: 37
Branch analysis from position: 12
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 28
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 19
Branch analysis from position: 34
Branch analysis from position: 19
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 19
Branch analysis from position: 34
Branch analysis from position: 19
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/HnMGO
function name:  rome
number of ops:  40
compiled vars:  !0 = $N, !1 = $ss, !2 = $c, !3 = $a, !4 = $b, !5 = $s, !6 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, ''
    6     2      > JMP                                                      ->5
    7     3    >   ASSIGN_OP                                     8          !1, 'M'
    8     4        ASSIGN_OP                                     2          !0, 1000
    6     5    >   IS_SMALLER                                               1000, !0
          6      > JMPNZ                                                    ~10, ->3
   11     7    >   ASSIGN                                                   !2, 'IVXLCDM'
   12     8        ASSIGN                                                   !3, 5
          9        ASSIGN                                                   !4, 0
         10        ASSIGN                                                   !5, ''
         11      > JMP                                                      ->36
   13    12    >   MOD                                              ~15     !0, !3
         13        ASSIGN                                                   !6, ~15
         14        BW_XOR                                           ~17     !3, 0
         15        DIV                                              ~18     !0, ~17
         16        CAST                                          4  ~19     ~18
         17        ASSIGN                                                   !0, ~19
         18      > JMP                                                      ->32
   14    19    >   IS_SMALLER                                               2, !6
         20      > JMPZ                                                     ~21, ->28
         21    >   ADD                                              ~22     !4, !0
         22        ASSIGN_OP                                    10  ~23     !0, -2
         23        SUB                                              ~24     ~22, ~23
         24        ASSIGN                                           ~25     !6, 1
         25        ADD                                              ~26     ~24, ~25
         26        QM_ASSIGN                                        ~27     ~26
         27      > JMP                                                      ->29
         28    >   QM_ASSIGN                                        ~27     !4
         29    >   FETCH_DIM_R                                      ~28     !2, ~27
         30        CONCAT                                           ~29     ~28, !5
         31        ASSIGN                                                   !5, ~29
   13    32    >   POST_DEC                                         ~31     !6
         33      > JMPNZ                                                    ~31, ->19
   12    34    >   PRE_INC                                                  !4
         35        ASSIGN_OP                                    11          !3, 7
         36    > > JMPNZ                                                    !0, ->12
   16    37    >   CONCAT                                           ~34     !1, !5
         38      > RETURN                                                   ~34
   17    39*     > RETURN                                                   null

End of function rome

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.25 ms | 1016 KiB | 15 Q