3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xcount = [0 => 0, 1 => 0, 2 => 0]; for ($i0 = 0; $i0 < 3*333; ++$i0) { for ($i1 = 0; $i1 < 2; ++$i1) { for ($i2 = 0; $i2 < 2; ++$i2) { for ($i3 = 0; $i3 < 2; ++$i3) { for ($i4 = 0; $i4 < 2; ++$i4) { for ($i5 = 0; $i5 < 2; ++$i5) { for ($i6 = 0; $i6 < 2; ++$i6) { ++$xcount[random3(rr3x3($i1, $i2, $i3, $i4, $i5, $i6))]; }}}}}} } var_dump($xcount); $xcount = [0 => 0, 1 => 0, 2 => 0]; $x = 500 * 3 * (2 * 2 * 2 * 2 * 2 * 2); while ($x--) { ++$xcount[random3( rr3x3( random2(), random2(), random2(), random2(), random2(), random2() ) )]; } var_dump($xcount); /** * @return 0|1|2 */ function random3($x): int { $num = (int) "{$x[0]}{$x[1]}{$x[2]}"; static $mem = 0; if ($num === 111) { if (++$mem % 2) { $num = $mem; } if ($mem === 6) $mem = 0; } return $num % 3; } //1,1,1 //1,1,2 //1,1,3 //всегда полная равнораспределенная комбинация 1-2-3 в каждом регистре function rr3x3($i1, $i2, $i3, $i4, $i5, $i6): array { $x1 = 1 + $i1 + $i2; $x2 = 1 + $i3 + $i4; $x3 = 1 + $i5 + $i6; if ($x2 === 2) { $x2 = 1; } elseif ($x2 === 1) { $x2 = 2; } if ($x3 === 2) { $x3 = 3; } elseif ($x3 === 3) { $x3 = 2; } return [$x1, $x2, $x3]; } function random2(): int { return random_int(0, 1); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 3
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 80
Branch analysis from position: 80
2 jumps found. (Code = 44) Position 1 = 82, Position 2 = 55
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 82, Position 2 = 55
Branch analysis from position: 82
Branch analysis from position: 55
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 5
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 3
Branch analysis from position: 49
Branch analysis from position: 3
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 7
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 5
Branch analysis from position: 46
Branch analysis from position: 5
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 9
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 7
Branch analysis from position: 43
Branch analysis from position: 7
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 11
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 9
Branch analysis from position: 40
Branch analysis from position: 9
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 13
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 11
Branch analysis from position: 37
Branch analysis from position: 11
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 15
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 13
Branch analysis from position: 34
Branch analysis from position: 13
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 15
Branch analysis from position: 31
Branch analysis from position: 15
filename:       /in/vdWjE
function name:  (null)
number of ops:  86
compiled vars:  !0 = $xcount, !1 = $i0, !2 = $i1, !3 = $i2, !4 = $i3, !5 = $i4, !6 = $i5, !7 = $i6, !8 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->47
    6     3    >   ASSIGN                                                   !2, 0
          4      > JMP                                                      ->44
    7     5    >   ASSIGN                                                   !3, 0
          6      > JMP                                                      ->41
    8     7    >   ASSIGN                                                   !4, 0
          8      > JMP                                                      ->38
    9     9    >   ASSIGN                                                   !5, 0
         10      > JMP                                                      ->35
   10    11    >   ASSIGN                                                   !6, 0
         12      > JMP                                                      ->32
   11    13    >   ASSIGN                                                   !7, 0
         14      > JMP                                                      ->29
   12    15    >   INIT_FCALL_BY_NAME                                       'random3'
         16        INIT_FCALL_BY_NAME                                       'rr3x3'
         17        SEND_VAR_EX                                              !2
         18        SEND_VAR_EX                                              !3
         19        SEND_VAR_EX                                              !4
         20        SEND_VAR_EX                                              !5
         21        SEND_VAR_EX                                              !6
         22        SEND_VAR_EX                                              !7
         23        DO_FCALL                                      0  $17     
         24        SEND_VAR_NO_REF_EX                                       $17
         25        DO_FCALL                                      0  $18     
         26        FETCH_DIM_RW                                     $19     !0, $18
         27        PRE_INC                                                  $19
   11    28        PRE_INC                                                  !7
         29    >   IS_SMALLER                                               !7, 2
         30      > JMPNZ                                                    ~22, ->15
   10    31    >   PRE_INC                                                  !6
         32    >   IS_SMALLER                                               !6, 2
         33      > JMPNZ                                                    ~24, ->13
    9    34    >   PRE_INC                                                  !5
         35    >   IS_SMALLER                                               !5, 2
         36      > JMPNZ                                                    ~26, ->11
    8    37    >   PRE_INC                                                  !4
         38    >   IS_SMALLER                                               !4, 2
         39      > JMPNZ                                                    ~28, ->9
    7    40    >   PRE_INC                                                  !3
         41    >   IS_SMALLER                                               !3, 2
         42      > JMPNZ                                                    ~30, ->7
    6    43    >   PRE_INC                                                  !2
         44    >   IS_SMALLER                                               !2, 2
         45      > JMPNZ                                                    ~32, ->5
    5    46    >   PRE_INC                                                  !1
         47    >   IS_SMALLER                                               !1, 999
         48      > JMPNZ                                                    ~34, ->3
   16    49    >   INIT_FCALL                                               'var_dump'
         50        SEND_VAR                                                 !0
         51        DO_ICALL                                                 
   20    52        ASSIGN                                                   !0, <array>
   21    53        ASSIGN                                                   !8, 96000
   23    54      > JMP                                                      ->80
   24    55    >   INIT_FCALL_BY_NAME                                       'random3'
   25    56        INIT_FCALL_BY_NAME                                       'rr3x3'
   26    57        INIT_FCALL_BY_NAME                                       'random2'
         58        DO_FCALL                                      0  $38     
         59        SEND_VAR_NO_REF_EX                                       $38
   27    60        INIT_FCALL_BY_NAME                                       'random2'
         61        DO_FCALL                                      0  $39     
         62        SEND_VAR_NO_REF_EX                                       $39
   28    63        INIT_FCALL_BY_NAME                                       'random2'
         64        DO_FCALL                                      0  $40     
         65        SEND_VAR_NO_REF_EX                                       $40
   29    66        INIT_FCALL_BY_NAME                                       'random2'
         67        DO_FCALL                                      0  $41     
         68        SEND_VAR_NO_REF_EX                                       $41
   30    69        INIT_FCALL_BY_NAME                                       'random2'
         70        DO_FCALL                                      0  $42     
         71        SEND_VAR_NO_REF_EX                                       $42
   31    72        INIT_FCALL_BY_NAME                                       'random2'
         73        DO_FCALL                                      0  $43     
         74        SEND_VAR_NO_REF_EX                                       $43
   25    75        DO_FCALL                                      0  $44     
   31    76        SEND_VAR_NO_REF_EX                                       $44
   24    77        DO_FCALL                                      0  $45     
   31    78        FETCH_DIM_RW                                     $46     !0, $45
         79        PRE_INC                                                  $46
   23    80    >   POST_DEC                                         ~48     !8
         81      > JMPNZ                                                    ~48, ->55
   36    82    >   INIT_FCALL                                               'var_dump'
         83        SEND_VAR                                                 !0
         84        DO_ICALL                                                 
   83    85      > RETURN                                                   1

Function random3:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 19
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 16
Branch analysis from position: 19
filename:       /in/vdWjE
function name:  random3
number of ops:  24
compiled vars:  !0 = $x, !1 = $num, !2 = $mem
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV                                             !0      
   43     1        FETCH_DIM_R                                      ~3      !0, 0
          2        ROPE_INIT                                     3  ~7      ~3
          3        FETCH_DIM_R                                      ~4      !0, 1
          4        ROPE_ADD                                      1  ~7      ~7, ~4
          5        FETCH_DIM_R                                      ~5      !0, 2
          6        ROPE_END                                      2  ~6      ~7, ~5
          7        CAST                                          4  ~9      ~6
          8        ASSIGN                                                   !1, ~9
   44     9        BIND_STATIC                                              !2
   45    10        IS_IDENTICAL                                             !1, 111
         11      > JMPZ                                                     ~11, ->19
   47    12    >   PRE_INC                                          ~12     !2
         13        MOD                                              ~13     ~12, 2
         14      > JMPZ                                                     ~13, ->16
   48    15    >   ASSIGN                                                   !1, !2
   50    16    >   IS_IDENTICAL                                             !2, 6
         17      > JMPZ                                                     ~15, ->19
         18    >   ASSIGN                                                   !2, 0
   52    19    >   MOD                                              ~17     !1, 3
         20        VERIFY_RETURN_TYPE                                       ~17
         21      > RETURN                                                   ~17
   53    22*       VERIFY_RETURN_TYPE                                       
         23*     > RETURN                                                   null

End of function random3

Function rr3x3:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 29
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
Branch analysis from position: 26
Branch analysis from position: 22
filename:       /in/vdWjE
function name:  rr3x3
number of ops:  36
compiled vars:  !0 = $i1, !1 = $i2, !2 = $i3, !3 = $i4, !4 = $i5, !5 = $i6, !6 = $x1, !7 = $x2, !8 = $x3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        RECV                                             !5      
   61     6        ADD                                              ~9      1, !0
          7        ADD                                              ~10     ~9, !1
          8        ASSIGN                                                   !6, ~10
   62     9        ADD                                              ~12     1, !2
         10        ADD                                              ~13     ~12, !3
         11        ASSIGN                                                   !7, ~13
   63    12        ADD                                              ~15     1, !4
         13        ADD                                              ~16     ~15, !5
         14        ASSIGN                                                   !8, ~16
   65    15        IS_IDENTICAL                                             !7, 2
         16      > JMPZ                                                     ~18, ->19
   66    17    >   ASSIGN                                                   !7, 1
   65    18      > JMP                                                      ->22
   67    19    >   IS_IDENTICAL                                             !7, 1
         20      > JMPZ                                                     ~20, ->22
   68    21    >   ASSIGN                                                   !7, 2
   70    22    >   IS_IDENTICAL                                             !8, 2
         23      > JMPZ                                                     ~22, ->26
   71    24    >   ASSIGN                                                   !8, 3
   70    25      > JMP                                                      ->29
   72    26    >   IS_IDENTICAL                                             !8, 3
         27      > JMPZ                                                     ~24, ->29
   73    28    >   ASSIGN                                                   !8, 2
   76    29    >   INIT_ARRAY                                       ~26     !6
         30        ADD_ARRAY_ELEMENT                                ~26     !7
         31        ADD_ARRAY_ELEMENT                                ~26     !8
         32        VERIFY_RETURN_TYPE                                       ~26
         33      > RETURN                                                   ~26
   77    34*       VERIFY_RETURN_TYPE                                       
         35*     > RETURN                                                   null

End of function rr3x3

Function random2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vdWjE
function name:  random2
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   82     0  E >   INIT_FCALL                                               'random_int'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 1
          3        DO_ICALL                                         $0      
          4        VERIFY_RETURN_TYPE                                       $0
          5      > RETURN                                                   $0
   83     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function random2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
254.15 ms | 1028 KiB | 16 Q