3v4l.org

run code in 300+ PHP versions simultaneously
<?php $teams[0] = array(1884, 1602, 1550, 1442, 1666); $teams[1] = array(1560, 1958, 1660, 1500, 1440); $diff = array_sum($teams[0]) - array_sum($teams[1]); for ($i = 0; $i < 1000 && $diff != 0; ++$i) { $r1 = rand(0, 4); // assumes nine players on each team $r2 = rand(0, 4); $new_diff = $diff - ($teams[0][$r1] - $teams[1][$r2]) * 2; if (abs($new_diff) < abs($diff)) { // 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 = 61
Branch analysis from position: 61
2 jumps found. (Code = 46) Position 1 = 63, Position 2 = 65
Branch analysis from position: 63
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 16
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 60
Branch analysis from position: 42
2 jumps found. (Code = 46) Position 1 = 63, Position 2 = 65
Branch analysis from position: 63
Branch analysis from position: 65
Branch analysis from position: 60
Branch analysis from position: 65
filename:       /in/r4u5r
function name:  (null)
number of ops:  67
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                                                      ->61
    9    16    >   INIT_FCALL                                               'rand'
         17        SEND_VAL                                                 0
         18        SEND_VAL                                                 4
         19        DO_ICALL                                         $16     
         20        ASSIGN                                                   !3, $16
   10    21        INIT_FCALL                                               '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                                               $28, $29
         41      > JMPZ                                                     ~30, ->60
   17    42    >   FETCH_DIM_R                                      ~31     !0, 0
         43        FETCH_DIM_R                                      ~32     ~31, !3
         44        ASSIGN                                                   !6, ~32
   18    45        FETCH_DIM_R                                      ~36     !0, 1
         46        FETCH_DIM_R                                      ~37     ~36, !4
         47        FETCH_DIM_W                                      $34     !0, 0
         48        ASSIGN_DIM                                               $34, !3
         49        OP_DATA                                                  ~37
   19    50        FETCH_DIM_W                                      $38     !0, 1
         51        ASSIGN_DIM                                               $38, !4
         52        OP_DATA                                                  !6
   21    53        INIT_FCALL                                               'var_dump'
         54        INIT_FCALL                                               'abs'
         55        SEND_VAR                                                 !5
         56        DO_ICALL                                         $40     
         57        SEND_VAR                                                 $40
         58        DO_ICALL                                                 
   23    59        ASSIGN                                                   !1, !5
    7    60    >   PRE_INC                                                  !2
         61    >   IS_SMALLER                                       ~44     !2, 1000
         62      > JMPZ_EX                                          ~44     ~44, ->65
         63    >   IS_NOT_EQUAL                                     ~45     !1, 0
         64        BOOL                                             ~44     ~45
         65    > > JMPNZ                                                    ~44, ->16
   25    66    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.52 ms | 1400 KiB | 21 Q