3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getCombinedSum($digits, $sum) { if(!is_int($digits) || !is_int($sum) || $digits<1 || $sum<0) { throw new InvalidArgumentException('Invalid numeric format'); } if($sum>9*$digits) { throw new LogicException('Sum out of range'); } if($digits==1) { return $sum; } $result = []; for($digit=0; $digit<10; $digit++) { if($sum-$digit>0) { $result[] = $digit.getCombinedSum($digits-1, $sum-$digit); } else { break; } } return $result; } var_dump(getCombinedSum(3, 4));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P7KgU
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'getcombinedsum'
          2        SEND_VAL                                                 3
          3        SEND_VAL                                                 4
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function getcombinedsum:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 47) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 108) 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
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 32
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 45
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 32
Branch analysis from position: 49
Branch analysis from position: 32
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 14
Branch analysis from position: 11
Branch analysis from position: 8
filename:       /in/P7KgU
function name:  getCombinedSum
number of ops:  51
compiled vars:  !0 = $digits, !1 = $sum, !2 = $result, !3 = $digit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        TYPE_CHECK                                   16  ~4      !0
          3        BOOL_NOT                                         ~5      ~4
          4      > JMPNZ_EX                                         ~5      ~5, ->8
          5    >   TYPE_CHECK                                   16  ~6      !1
          6        BOOL_NOT                                         ~7      ~6
          7        BOOL                                             ~5      ~7
          8    > > JMPNZ_EX                                         ~5      ~5, ->11
          9    >   IS_SMALLER                                       ~8      !0, 1
         10        BOOL                                             ~5      ~8
         11    > > JMPNZ_EX                                         ~5      ~5, ->14
         12    >   IS_SMALLER                                       ~9      !1, 0
         13        BOOL                                             ~5      ~9
         14    > > JMPZ                                                     ~5, ->19
    7    15    >   NEW                                              $10     'InvalidArgumentException'
         16        SEND_VAL_EX                                              'Invalid+numeric+format'
         17        DO_FCALL                                      0          
         18      > THROW                                         0          $10
    9    19    >   MUL                                              ~12     !0, 9
         20        IS_SMALLER                                               ~12, !1
         21      > JMPZ                                                     ~13, ->26
   11    22    >   NEW                                              $14     'LogicException'
         23        SEND_VAL_EX                                              'Sum+out+of+range'
         24        DO_FCALL                                      0          
         25      > THROW                                         0          $14
   13    26    >   IS_EQUAL                                                 !0, 1
         27      > JMPZ                                                     ~16, ->29
   15    28    > > RETURN                                                   !1
   17    29    >   ASSIGN                                                   !2, <array>
   18    30        ASSIGN                                                   !3, 0
         31      > JMP                                                      ->47
   20    32    >   SUB                                              ~19     !1, !3
         33        IS_SMALLER                                               0, ~19
         34      > JMPZ                                                     ~20, ->45
   22    35    >   INIT_FCALL_BY_NAME                                       'getCombinedSum'
         36        SUB                                              ~22     !0, 1
         37        SEND_VAL_EX                                              ~22
         38        SUB                                              ~23     !1, !3
         39        SEND_VAL_EX                                              ~23
         40        DO_FCALL                                      0  $24     
         41        CONCAT                                           ~25     !3, $24
         42        ASSIGN_DIM                                               !2
         43        OP_DATA                                                  ~25
         44      > JMP                                                      ->46
   26    45    > > JMP                                                      ->49
   18    46    >   PRE_INC                                                  !3
         47    >   IS_SMALLER                                               !3, 10
         48      > JMPNZ                                                    ~27, ->32
   29    49    > > RETURN                                                   !2
   30    50*     > RETURN                                                   null

End of function getcombinedsum

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.63 ms | 1403 KiB | 16 Q