3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); set_time_limit(0); generate_nice('php'); function generate_nice($word) { echo 'Word: ', $word, "\n"; $i = generate($word); echo 'Seed: ', $i, "\n"; echo 'Test: ', test($i, strlen($word)), "\n"; } function generate($word) { $l = strlen($word); $s = ''; for ($i = 0; $s !== $word; ++$i) { $s = ''; mt_srand($i); for ($j = 0; $j < $l; ++$j) { $s .= chr(96 + mt_rand(1, 26)); } } return $i - 1; } function test($i, $l) { $s = ''; mt_srand($i); for ($j = 0; $j < $l; ++$j) { $s .= chr(96 + mt_rand(1, 26)); } return $s; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jEfgk
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 -1
          2        DO_ICALL                                                 
    3     3        INIT_FCALL                                               'set_time_limit'
          4        SEND_VAL                                                 0
          5        DO_ICALL                                                 
    5     6        INIT_FCALL_BY_NAME                                       'generate_nice'
          7        SEND_VAL_EX                                              'php'
          8        DO_FCALL                                      0          
   34     9      > RETURN                                                   1

Function generate_nice:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jEfgk
function name:  generate_nice
number of ops:  20
compiled vars:  !0 = $word, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ECHO                                                     'Word%3A+'
          2        ECHO                                                     !0
          3        ECHO                                                     '%0A'
    9     4        INIT_FCALL_BY_NAME                                       'generate'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $2      
          7        ASSIGN                                                   !1, $2
   10     8        ECHO                                                     'Seed%3A+'
          9        ECHO                                                     !1
         10        ECHO                                                     '%0A'
   11    11        ECHO                                                     'Test%3A+'
         12        INIT_FCALL_BY_NAME                                       'test'
         13        SEND_VAR_EX                                              !1
         14        STRLEN                                           ~4      !0
         15        SEND_VAL_EX                                              ~4
         16        DO_FCALL                                      0  $5      
         17        ECHO                                                     $5
         18        ECHO                                                     '%0A'
   12    19      > RETURN                                                   null

End of function generate_nice

Function generate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 6
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 12
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 6
Branch analysis from position: 27
Branch analysis from position: 6
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 12
Branch analysis from position: 24
Branch analysis from position: 12
filename:       /in/jEfgk
function name:  generate
number of ops:  30
compiled vars:  !0 = $word, !1 = $l, !2 = $s, !3 = $i, !4 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        STRLEN                                           ~5      !0
          2        ASSIGN                                                   !1, ~5
   16     3        ASSIGN                                                   !2, ''
   17     4        ASSIGN                                                   !3, 0
          5      > JMP                                                      ->25
   18     6    >   ASSIGN                                                   !2, ''
   19     7        INIT_FCALL                                               'mt_srand'
          8        SEND_VAR                                                 !3
          9        DO_ICALL                                                 
   20    10        ASSIGN                                                   !4, 0
         11      > JMP                                                      ->22
   21    12    >   INIT_FCALL                                               'chr'
         13        INIT_FCALL                                               'mt_rand'
         14        SEND_VAL                                                 1
         15        SEND_VAL                                                 26
         16        DO_ICALL                                         $12     
         17        ADD                                              ~13     96, $12
         18        SEND_VAL                                                 ~13
         19        DO_ICALL                                         $14     
         20        ASSIGN_OP                                     8          !2, $14
   20    21        PRE_INC                                                  !4
         22    >   IS_SMALLER                                               !4, !1
         23      > JMPNZ                                                    ~17, ->12
   17    24    >   PRE_INC                                                  !3
         25    >   IS_NOT_IDENTICAL                                         !2, !0
         26      > JMPNZ                                                    ~19, ->6
   24    27    >   SUB                                              ~20     !3, 1
         28      > RETURN                                                   ~20
   25    29*     > RETURN                                                   null

End of function generate

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 8
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 8
Branch analysis from position: 20
Branch analysis from position: 8
filename:       /in/jEfgk
function name:  test
number of ops:  22
compiled vars:  !0 = $i, !1 = $l, !2 = $s, !3 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   28     2        ASSIGN                                                   !2, ''
   29     3        INIT_FCALL                                               'mt_srand'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
   30     6        ASSIGN                                                   !3, 0
          7      > JMP                                                      ->18
   31     8    >   INIT_FCALL                                               'chr'
          9        INIT_FCALL                                               'mt_rand'
         10        SEND_VAL                                                 1
         11        SEND_VAL                                                 26
         12        DO_ICALL                                         $7      
         13        ADD                                              ~8      96, $7
         14        SEND_VAL                                                 ~8
         15        DO_ICALL                                         $9      
         16        ASSIGN_OP                                     8          !2, $9
   30    17        PRE_INC                                                  !3
         18    >   IS_SMALLER                                               !3, !1
         19      > JMPNZ                                                    ~12, ->8
   33    20    > > RETURN                                                   !2
   34    21*     > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
193.41 ms | 1396 KiB | 23 Q