3v4l.org

run code in 300+ PHP versions simultaneously
<?php $teams[0] = array(1784, 1602, 1550, 1442, 1666); $teams[1] = array(1560, 1758, 1660, 1500, 1440); $diff = array_sum($teams[0]) - array_sum($teams[1]); for ($i = 0; $i < 1000 && $diff != 0; ++$i) { $r1 = mt_rand(0, 4); // assumes nine players on each team $r2 = mt_rand(0, 4); $new_diff = $diff - ($teams[0][$r1] - $teams[1][$r2]) * 2; if (abs($new_diff) < abs($diff) || mt_rand(0, 100) < 5) { // if the switch makes the teams more equal, then swap $tmp = $teams[0][$r1]; $teams[0][$r1] = $teams[1][$r2]; $teams[1][$r2] = $tmp; #var_dump(abs($new_diff)); $diff = $new_diff; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
2 jumps found. (Code = 46) Position 1 = 64, Position 2 = 66
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 16
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 47) Position 1 = 42, Position 2 = 48
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 61
Branch analysis from position: 49
2 jumps found. (Code = 46) Position 1 = 64, Position 2 = 66
Branch analysis from position: 64
Branch analysis from position: 66
Branch analysis from position: 61
Branch analysis from position: 48
Branch analysis from position: 66
filename:       /in/0OWFO
function name:  (null)
number of ops:  68
compiled vars:  !0 = $teams, !1 = $diff, !2 = $i, !3 = $r1, !4 = $r2, !5 = $new_diff, !6 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN_DIM                                               !0, 0
          1        OP_DATA                                                  <array>
    4     2        ASSIGN_DIM                                               !0, 1
          3        OP_DATA                                                  <array>
    6     4        INIT_FCALL                                               'array_sum'
          5        FETCH_DIM_R                                      ~9      !0, 0
          6        SEND_VAL                                                 ~9
          7        DO_ICALL                                         $10     
          8        INIT_FCALL                                               'array_sum'
          9        FETCH_DIM_R                                      ~11     !0, 1
         10        SEND_VAL                                                 ~11
         11        DO_ICALL                                         $12     
         12        SUB                                              ~13     $10, $12
         13        ASSIGN                                                   !1, ~13
    7    14        ASSIGN                                                   !2, 0
         15      > JMP                                                      ->62
    9    16    >   INIT_FCALL                                               'mt_rand'
         17        SEND_VAL                                                 0
         18        SEND_VAL                                                 4
         19        DO_ICALL                                         $16     
         20        ASSIGN                                                   !3, $16
   10    21        INIT_FCALL                                               'mt_rand'
         22        SEND_VAL                                                 0
         23        SEND_VAL                                                 4
         24        DO_ICALL                                         $18     
         25        ASSIGN                                                   !4, $18
   12    26        FETCH_DIM_R                                      ~20     !0, 0
         27        FETCH_DIM_R                                      ~21     ~20, !3
         28        FETCH_DIM_R                                      ~22     !0, 1
         29        FETCH_DIM_R                                      ~23     ~22, !4
         30        SUB                                              ~24     ~21, ~23
         31        MUL                                              ~25     ~24, 2
         32        SUB                                              ~26     !1, ~25
         33        ASSIGN                                                   !5, ~26
   14    34        INIT_FCALL                                               'abs'
         35        SEND_VAR                                                 !5
         36        DO_ICALL                                         $28     
         37        INIT_FCALL                                               'abs'
         38        SEND_VAR                                                 !1
         39        DO_ICALL                                         $29     
         40        IS_SMALLER                                       ~30     $28, $29
         41      > JMPNZ_EX                                         ~30     ~30, ->48
         42    >   INIT_FCALL                                               'mt_rand'
         43        SEND_VAL                                                 0
         44        SEND_VAL                                                 100
         45        DO_ICALL                                         $31     
         46        IS_SMALLER                                       ~32     $31, 5
         47        BOOL                                             ~30     ~32
         48    > > JMPZ                                                     ~30, ->61
   17    49    >   FETCH_DIM_R                                      ~33     !0, 0
         50        FETCH_DIM_R                                      ~34     ~33, !3
         51        ASSIGN                                                   !6, ~34
   18    52        FETCH_DIM_R                                      ~38     !0, 1
         53        FETCH_DIM_R                                      ~39     ~38, !4
         54        FETCH_DIM_W                                      $36     !0, 0
         55        ASSIGN_DIM                                               $36, !3
         56        OP_DATA                                                  ~39
   19    57        FETCH_DIM_W                                      $40     !0, 1
         58        ASSIGN_DIM                                               $40, !4
         59        OP_DATA                                                  !6
   23    60        ASSIGN                                                   !1, !5
    7    61    >   PRE_INC                                                  !2
         62    >   IS_SMALLER                                       ~44     !2, 1000
         63      > JMPZ_EX                                          ~44     ~44, ->66
         64    >   IS_NOT_EQUAL                                     ~45     !1, 0
         65        BOOL                                             ~44     ~45
         66    > > JMPNZ                                                    ~44, ->16
   25    67    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.14 ms | 1400 KiB | 19 Q