3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); function twoSumMap(array $arr, int $target): array { $hash = []; foreach ($arr as $val) { if ($hash[$val] ?? false) { return [$val, $hash[$val]]; } $hash[$target - $val] = $val; } return []; } function main(): void { $arr = [8, 1, 7, 5, -9, -11, 3]; var_dump(twoSumMap($arr, 10)); } main();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/253rp
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'main'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   1

Function twosummap:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/253rp
function name:  twoSumMap
number of ops:  23
compiled vars:  !0 = $arr, !1 = $target, !2 = $hash, !3 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
    6     3      > FE_RESET_R                                       $5      !0, ->19
          4    > > FE_FETCH_R                                               $5, !3, ->19
    7     5    >   FETCH_DIM_IS                                     ~6      !2, !3
          6        COALESCE                                         ~7      ~6
          7        QM_ASSIGN                                        ~7      <false>
          8      > JMPZ                                                     ~7, ->15
    8     9    >   INIT_ARRAY                                       ~8      !3
         10        FETCH_DIM_R                                      ~9      !2, !3
         11        ADD_ARRAY_ELEMENT                                ~8      ~9
         12        VERIFY_RETURN_TYPE                                       ~8
         13        FE_FREE                                                  $5
         14      > RETURN                                                   ~8
   11    15    >   SUB                                              ~10     !1, !3
         16        ASSIGN_DIM                                               !2, ~10
         17        OP_DATA                                                  !3
    6    18      > JMP                                                      ->4
         19    >   FE_FREE                                                  $5
   14    20      > RETURN                                                   <array>
   15    21*       VERIFY_RETURN_TYPE                                       
         22*     > RETURN                                                   null

End of function twosummap

Function main:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/253rp
function name:  main
number of ops:  9
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'twosummap'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 10
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
   21     8      > RETURN                                                   null

End of function main

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.97 ms | 1007 KiB | 16 Q