3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class ArrayUtils { public static function containsSum($data, $sum) { $max = count($data); for ($i = 0; $i < $max; $i += 1) { $v1 = $data[$i]; for ($j = $i + 1; $j < $max; $j += 1) { $v2 = $data[$j]; if ($v1 + $v2 === $sum) { return true; } } } return false; } } $data = range(0, 9999); shuffle($data); var_dump(ArrayUtils::containsSum($data, 1220)); var_dump(ArrayUtils::containsSum($data, -7));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bSlKb
function name:  (null)
number of ops:  23
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 9999
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   23     5        INIT_FCALL                                               'shuffle'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                                 
   24     8        INIT_FCALL                                               'var_dump'
          9        INIT_STATIC_METHOD_CALL                                  'ArrayUtils', 'containsSum'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 1220
         12        DO_FCALL                                      0  $4      
         13        SEND_VAR                                                 $4
         14        DO_ICALL                                                 
   25    15        INIT_FCALL                                               'var_dump'
         16        INIT_STATIC_METHOD_CALL                                  'ArrayUtils', 'containsSum'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 -7
         19        DO_FCALL                                      0  $6      
         20        SEND_VAR                                                 $6
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Class ArrayUtils:
Function containssum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 6
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 11
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 6
Branch analysis from position: 23
Branch analysis from position: 6
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 11
Branch analysis from position: 20
Branch analysis from position: 11
filename:       /in/bSlKb
function name:  containsSum
number of ops:  25
compiled vars:  !0 = $data, !1 = $sum, !2 = $max, !3 = $i, !4 = $v1, !5 = $j, !6 = $v2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        COUNT                                            ~7      !0
          3        ASSIGN                                                   !2, ~7
    9     4        ASSIGN                                                   !3, 0
          5      > JMP                                                      ->21
   10     6    >   FETCH_DIM_R                                      ~10     !0, !3
          7        ASSIGN                                                   !4, ~10
   11     8        ADD                                              ~12     !3, 1
          9        ASSIGN                                                   !5, ~12
         10      > JMP                                                      ->18
   12    11    >   FETCH_DIM_R                                      ~14     !0, !5
         12        ASSIGN                                                   !6, ~14
   13    13        ADD                                              ~16     !4, !6
         14        IS_IDENTICAL                                             !1, ~16
         15      > JMPZ                                                     ~17, ->17
   14    16    > > RETURN                                                   <true>
   11    17    >   ASSIGN_OP                                     1          !5, 1
         18    >   IS_SMALLER                                               !5, !2
         19      > JMPNZ                                                    ~19, ->11
    9    20    >   ASSIGN_OP                                     1          !3, 1
         21    >   IS_SMALLER                                               !3, !2
         22      > JMPNZ                                                    ~21, ->6
   18    23    > > RETURN                                                   <false>
   19    24*     > RETURN                                                   null

End of function containssum

End of class ArrayUtils.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.07 ms | 1400 KiB | 19 Q