3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isPrimeNumber($num) { $isPrime = 1; for ($i = 2; $i <= ($num/2); $i++) { if ($num % $i == 0){ $isPrime = 0; break; } } return ($isPrime==1 || $num==2)? 1 : 0; } function generateRightTriangle( $rows ) { define("START",2); for ($i = 1, $count = START; $i <= $rows; $i++) { for ($j = 1; $j <= $i; $j++) { while( !isPrimeNumber($count) ){ $count++; } printf(" %-2d", $count); $count++; } printf("\n"); } return true; } if (!generateRightTriangle(5)) { trigger_error("An error has occurred!"); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/iAYKI
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'generaterighttriangle'
          1        SEND_VAL                                                 5
          2        DO_FCALL                                      0  $0      
          3        BOOL_NOT                                         ~1      $0
          4      > JMPZ                                                     ~1, ->8
   29     5    >   INIT_FCALL                                               'trigger_error'
          6        SEND_VAL                                                 'An+error+has+occurred%21'
          7        DO_ICALL                                                 
   30     8    > > RETURN                                                   1

Function isprimenumber:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 4
Branch analysis from position: 13
2 jumps found. (Code = 47) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 4
Branch analysis from position: 13
Branch analysis from position: 4
filename:       /in/iAYKI
function name:  isPrimeNumber
number of ops:  23
compiled vars:  !0 = $num, !1 = $isPrime, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, 1
    4     2        ASSIGN                                                   !2, 2
          3      > JMP                                                      ->10
    5     4    >   MOD                                              ~5      !0, !2
          5        IS_EQUAL                                                 ~5, 0
          6      > JMPZ                                                     ~6, ->9
    6     7    >   ASSIGN                                                   !1, 0
    7     8      > JMP                                                      ->13
    4     9    >   PRE_INC                                                  !2
         10    >   DIV                                              ~9      !0, 2
         11        IS_SMALLER_OR_EQUAL                                      !2, ~9
         12      > JMPNZ                                                    ~10, ->4
   10    13    >   IS_EQUAL                                         ~11     !1, 1
         14      > JMPNZ_EX                                         ~11     ~11, ->17
         15    >   IS_EQUAL                                         ~12     !0, 2
         16        BOOL                                             ~11     ~12
         17    > > JMPZ                                                     ~11, ->20
         18    >   QM_ASSIGN                                        ~13     1
         19      > JMP                                                      ->21
         20    >   QM_ASSIGN                                        ~13     0
         21    > > RETURN                                                   ~13
   11    22*     > RETURN                                                   null

End of function isprimenumber

Function generaterighttriangle:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 9
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 11
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 9
Branch analysis from position: 32
Branch analysis from position: 9
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 12
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 11
Branch analysis from position: 26
Branch analysis from position: 11
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 12
Branch analysis from position: 18
Branch analysis from position: 12
filename:       /in/iAYKI
function name:  generateRightTriangle
number of ops:  34
compiled vars:  !0 = $rows, !1 = $i, !2 = $count, !3 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'define'
          2        SEND_VAL                                                 'START'
          3        SEND_VAL                                                 2
          4        DO_ICALL                                                 
   15     5        ASSIGN                                                   !1, 1
          6        FETCH_CONSTANT                                   ~6      'START'
          7        ASSIGN                                                   !2, ~6
          8      > JMP                                                      ->30
   16     9    >   ASSIGN                                                   !3, 1
         10      > JMP                                                      ->24
   17    11    > > JMP                                                      ->13
   18    12    >   PRE_INC                                                  !2
   17    13    >   INIT_FCALL                                               'isprimenumber'
         14        SEND_VAR                                                 !2
         15        DO_FCALL                                      0  $10     
         16        BOOL_NOT                                         ~11     $10
         17      > JMPNZ                                                    ~11, ->12
   20    18    >   INIT_FCALL                                               'printf'
         19        SEND_VAL                                                 '+%25-2d'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                                 
   21    22        PRE_INC                                                  !2
   16    23        PRE_INC                                                  !3
         24    >   IS_SMALLER_OR_EQUAL                                      !3, !1
         25      > JMPNZ                                                    ~15, ->11
   23    26    >   INIT_FCALL                                               'printf'
         27        SEND_VAL                                                 '%0A'
         28        DO_ICALL                                                 
   15    29        PRE_INC                                                  !1
         30    >   IS_SMALLER_OR_EQUAL                                      !1, !0
         31      > JMPNZ                                                    ~18, ->9
   25    32    > > RETURN                                                   <true>
   26    33*     > RETURN                                                   null

End of function generaterighttriangle

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.98 ms | 1407 KiB | 21 Q