3v4l.org

run code in 300+ PHP versions simultaneously
<?php $digits = array(9,8,7,6,5,4,3,2,1); $primes = array(2,3,5,7,11); function simplify(Int $num, Int $denom, Array $primes){ //going from high primes to low primes foreach(array_reverse($primes) as $prime) { if (($num % $prime == 0) && ($denom % $prime == 0)) { return [$num / $prime,$denom / $prime]; } } return [$num,$denom]; } echo "simplify 10:4 = " . implode(':',simplify(10,4,$primes)) . "\n"; echo "simplify 121:22 = " . implode(':',simplify(121,22,$primes)) . "\n"; echo "simplify 5:5 = " . implode(':',simplify(5,5,$primes)) . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TuTqV
function name:  (null)
number of ops:  39
compiled vars:  !0 = $digits, !1 = $primes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
   16     2        INIT_FCALL                                               'implode'
          3        SEND_VAL                                                 '%3A'
          4        INIT_FCALL                                               'simplify'
          5        SEND_VAL                                                 10
          6        SEND_VAL                                                 4
          7        SEND_VAR                                                 !1
          8        DO_FCALL                                      0  $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                         $5      
         11        CONCAT                                           ~6      'simplify+10%3A4+%3D+', $5
         12        CONCAT                                           ~7      ~6, '%0A'
         13        ECHO                                                     ~7
   17    14        INIT_FCALL                                               'implode'
         15        SEND_VAL                                                 '%3A'
         16        INIT_FCALL                                               'simplify'
         17        SEND_VAL                                                 121
         18        SEND_VAL                                                 22
         19        SEND_VAR                                                 !1
         20        DO_FCALL                                      0  $8      
         21        SEND_VAR                                                 $8
         22        DO_ICALL                                         $9      
         23        CONCAT                                           ~10     'simplify+121%3A22+%3D+', $9
         24        CONCAT                                           ~11     ~10, '%0A'
         25        ECHO                                                     ~11
   18    26        INIT_FCALL                                               'implode'
         27        SEND_VAL                                                 '%3A'
         28        INIT_FCALL                                               'simplify'
         29        SEND_VAL                                                 5
         30        SEND_VAL                                                 5
         31        SEND_VAR                                                 !1
         32        DO_FCALL                                      0  $12     
         33        SEND_VAR                                                 $12
         34        DO_ICALL                                         $13     
         35        CONCAT                                           ~14     'simplify+5%3A5+%3D+', $13
         36        CONCAT                                           ~15     ~14, '%0A'
         37        ECHO                                                     ~15
         38      > RETURN                                                   1

Function simplify:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 22
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 22
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 14
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/TuTqV
function name:  simplify
number of ops:  27
compiled vars:  !0 = $num, !1 = $denom, !2 = $primes, !3 = $prime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    7     3        INIT_FCALL                                               'array_reverse'
          4        SEND_VAR                                                 !2
          5        DO_ICALL                                         $4      
          6      > FE_RESET_R                                       $5      $4, ->22
          7    > > FE_FETCH_R                                               $5, !3, ->22
    8     8    >   MOD                                              ~6      !0, !3
          9        IS_EQUAL                                         ~7      ~6, 0
         10      > JMPZ_EX                                          ~7      ~7, ->14
         11    >   MOD                                              ~8      !1, !3
         12        IS_EQUAL                                         ~9      ~8, 0
         13        BOOL                                             ~7      ~9
         14    > > JMPZ                                                     ~7, ->21
    9    15    >   DIV                                              ~10     !0, !3
         16        INIT_ARRAY                                       ~11     ~10
         17        DIV                                              ~12     !1, !3
         18        ADD_ARRAY_ELEMENT                                ~11     ~12
         19        FE_FREE                                                  $5
         20      > RETURN                                                   ~11
    7    21    > > JMP                                                      ->7
         22    >   FE_FREE                                                  $5
   13    23        INIT_ARRAY                                       ~13     !0
         24        ADD_ARRAY_ELEMENT                                ~13     !1
         25      > RETURN                                                   ~13
   14    26*     > RETURN                                                   null

End of function simplify

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.04 ms | 1394 KiB | 20 Q