3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function nulles($max) { $x = []; for ($i = 1; $i < $max; ++$i) { $md5 = md5((string)$i); $cnt = 0; for ($md_i = 0; $md_i < 32; ++$md_i) { if ($md5[$md_i] !== '0') { break; } ++$cnt; } $x[$cnt] = 1 + ($x[$cnt] ?? 0); } return [$max => $x]; } function raspred($x) { $result = []; foreach ($x as $max => $res) { foreach ($res as $zeros => $count) { $result["от 1 до $max"]["md5 имеет $zeros нулей в начале"] = '1/' . round( $max / $count, 3 ) . ' или ' . round($count / $max * 100, 2) . '%'; } } return $result; } foreach ( [ 5000, 10000, 50000, 100000, 500000, 1000000, 10000000, ] as $size ) { var_dump(raspred(nulles($size))); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 1, Position 2 = 12
Branch analysis from position: 1
2 jumps found. (Code = 78) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 1
Branch analysis from position: 1
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/eRqbS
function name:  (null)
number of ops:  14
compiled vars:  !0 = $size
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E > > FE_RESET_R                                       $1      <array>, ->12
          1    > > FE_FETCH_R                                               $1, !0, ->12
   49     2    >   INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'raspred'
          4        INIT_FCALL                                               'nulles'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        DO_FCALL                                      0  $3      
          9        SEND_VAR                                                 $3
         10        DO_ICALL                                                 
   40    11      > JMP                                                      ->1
         12    >   FE_FREE                                                  $1
   50    13      > RETURN                                                   1

Function nulles:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 4
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 12
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 4
Branch analysis from position: 29
Branch analysis from position: 4
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 12
Branch analysis from position: 20
Branch analysis from position: 12
filename:       /in/eRqbS
function name:  nulles
number of ops:  32
compiled vars:  !0 = $max, !1 = $x, !2 = $i, !3 = $md5, !4 = $cnt, !5 = $md_i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, <array>
    8     2        ASSIGN                                                   !2, 1
          3      > JMP                                                      ->27
    9     4    >   INIT_FCALL                                               'md5'
          5        CAST                                          6  ~8      !2
          6        SEND_VAL                                                 ~8
          7        DO_ICALL                                         $9      
          8        ASSIGN                                                   !3, $9
   10     9        ASSIGN                                                   !4, 0
   11    10        ASSIGN                                                   !5, 0
         11      > JMP                                                      ->18
   12    12    >   FETCH_DIM_R                                      ~13     !3, !5
         13        IS_NOT_IDENTICAL                                         ~13, '0'
         14      > JMPZ                                                     ~14, ->16
   13    15    > > JMP                                                      ->20
   15    16    >   PRE_INC                                                  !4
   11    17        PRE_INC                                                  !5
         18    >   IS_SMALLER                                               !5, 32
         19      > JMPNZ                                                    ~17, ->12
   17    20    >   FETCH_DIM_IS                                     ~19     !1, !4
         21        COALESCE                                         ~20     ~19
         22        QM_ASSIGN                                        ~20     0
         23        ADD                                              ~21     1, ~20
         24        ASSIGN_DIM                                               !1, !4
         25        OP_DATA                                                  ~21
    8    26        PRE_INC                                                  !2
         27    >   IS_SMALLER                                               !2, !0
         28      > JMPNZ                                                    ~23, ->4
   20    29    >   INIT_ARRAY                                       ~24     !1, !0
         30      > RETURN                                                   ~24
   21    31*     > RETURN                                                   null

End of function nulles

Function raspred:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 34
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 34
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 32
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 32
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 32
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/eRqbS
function name:  raspred
number of ops:  37
compiled vars:  !0 = $x, !1 = $result, !2 = $res, !3 = $max, !4 = $count, !5 = $zeros
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        ASSIGN                                                   !1, <array>
   26     2      > FE_RESET_R                                       $7      !0, ->34
          3    > > FE_FETCH_R                                       ~8      $7, !2, ->34
          4    >   ASSIGN                                                   !3, ~8
   27     5      > FE_RESET_R                                       $10     !2, ->32
          6    > > FE_FETCH_R                                       ~11     $10, !4, ->32
          7    >   ASSIGN                                                   !5, ~11
   28     8        NOP                                                      
          9        FAST_CONCAT                                      ~13     '%D0%BE%D1%82+1+%D0%B4%D0%BE+', !3
         10        ROPE_INIT                                     3  ~16     'md5+%D0%B8%D0%BC%D0%B5%D0%B5%D1%82+'
         11        ROPE_ADD                                      1  ~16     ~16, !5
         12        ROPE_END                                      2  ~15     ~16, '+%D0%BD%D1%83%D0%BB%D0%B5%D0%B9+%D0%B2+%D0%BD%D0%B0%D1%87%D0%B0%D0%BB%D0%B5'
         13        INIT_FCALL                                               'round'
   29    14        DIV                                              ~19     !3, !4
         15        SEND_VAL                                                 ~19
   30    16        SEND_VAL                                                 3
   28    17        DO_ICALL                                         $20     
   30    18        CONCAT                                           ~21     '1%2F', $20
   31    19        CONCAT                                           ~22     ~21, '+%D0%B8%D0%BB%D0%B8+'
         20        INIT_FCALL                                               'round'
         21        DIV                                              ~23     !4, !3
         22        MUL                                              ~24     ~23, 100
         23        SEND_VAL                                                 ~24
         24        SEND_VAL                                                 2
         25        DO_ICALL                                         $25     
         26        CONCAT                                           ~26     ~22, $25
         27        CONCAT                                           ~27     ~26, '%25'
   28    28        FETCH_DIM_W                                      $14     !1, ~13
         29        ASSIGN_DIM                                               $14, ~15
   31    30        OP_DATA                                                  ~27
   27    31      > JMP                                                      ->6
         32    >   FE_FREE                                                  $10
   26    33      > JMP                                                      ->3
         34    >   FE_FREE                                                  $7
   35    35      > RETURN                                                   !1
   36    36*     > RETURN                                                   null

End of function raspred

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.85 ms | 1024 KiB | 18 Q