3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a='5465574541345268975564654'; $b='2514523656557987'; echo "Normal sum : ".($a +$b); echo "\n"; $main_loop = strlen($a); if(strlen($a) < strlen($b)){ $main_loop = strlen($b); $a = str_pad($a,strlen($b),"0",STR_PAD_LEFT); } else { $b = str_pad($b,strlen($a),"0",STR_PAD_LEFT); } $carry = 0; $str = ""; $new_sum = ""; for($i = $main_loop-1;$i>=0;$i--) { $char_a = isset($a[$i])?$a[$i]:0; $char_b = isset($b[$i])?$b[$i]:0; $sum_char =(string)($char_a + $char_b + $carry); $carry = 0; $str = (string)$sum_char[0]; if(strlen($sum_char) > 1) { $carry = $sum_char[0]; $str = $sum_char[1]; } $new_sum .= $str; } $new_sum = strrev($new_sum); echo $new_sum;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 37
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 42
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 49
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 66
Branch analysis from position: 62
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 37
Branch analysis from position: 70
Branch analysis from position: 37
Branch analysis from position: 66
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 66
Branch analysis from position: 62
Branch analysis from position: 66
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 49
Branch analysis from position: 46
Branch analysis from position: 49
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
filename:       /in/mgSBn
function name:  (null)
number of ops:  76
compiled vars:  !0 = $a, !1 = $b, !2 = $main_loop, !3 = $carry, !4 = $str, !5 = $new_sum, !6 = $i, !7 = $char_a, !8 = $char_b, !9 = $sum_char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '5465574541345268975564654'
    4     1        ASSIGN                                                   !1, '2514523656557987'
    5     2        ADD                                              ~12     !0, !1
          3        CONCAT                                           ~13     'Normal+sum+%3A+', ~12
          4        ECHO                                                     ~13
    6     5        ECHO                                                     '%0A'
    7     6        STRLEN                                           ~14     !0
          7        ASSIGN                                                   !2, ~14
    8     8        STRLEN                                           ~16     !0
          9        STRLEN                                           ~17     !1
         10        IS_SMALLER                                               ~16, ~17
         11      > JMPZ                                                     ~18, ->23
    9    12    >   STRLEN                                           ~19     !1
         13        ASSIGN                                                   !2, ~19
   10    14        INIT_FCALL                                               'str_pad'
         15        SEND_VAR                                                 !0
         16        STRLEN                                           ~21     !1
         17        SEND_VAL                                                 ~21
         18        SEND_VAL                                                 '0'
         19        SEND_VAL                                                 0
         20        DO_ICALL                                         $22     
         21        ASSIGN                                                   !0, $22
    8    22      > JMP                                                      ->31
   14    23    >   INIT_FCALL                                               'str_pad'
         24        SEND_VAR                                                 !1
         25        STRLEN                                           ~24     !0
         26        SEND_VAL                                                 ~24
         27        SEND_VAL                                                 '0'
         28        SEND_VAL                                                 0
         29        DO_ICALL                                         $25     
         30        ASSIGN                                                   !1, $25
   16    31    >   ASSIGN                                                   !3, 0
   17    32        ASSIGN                                                   !4, ''
   18    33        ASSIGN                                                   !5, ''
   19    34        SUB                                              ~30     !2, 1
         35        ASSIGN                                                   !6, ~30
         36      > JMP                                                      ->68
   22    37    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !6
         38      > JMPZ                                                     ~32, ->42
         39    >   FETCH_DIM_R                                      ~33     !0, !6
         40        QM_ASSIGN                                        ~34     ~33
         41      > JMP                                                      ->43
         42    >   QM_ASSIGN                                        ~34     0
         43    >   ASSIGN                                                   !7, ~34
   23    44        ISSET_ISEMPTY_DIM_OBJ                         0          !1, !6
         45      > JMPZ                                                     ~36, ->49
         46    >   FETCH_DIM_R                                      ~37     !1, !6
         47        QM_ASSIGN                                        ~38     ~37
         48      > JMP                                                      ->50
         49    >   QM_ASSIGN                                        ~38     0
         50    >   ASSIGN                                                   !8, ~38
   24    51        ADD                                              ~40     !7, !8
         52        ADD                                              ~41     ~40, !3
         53        CAST                                          6  ~42     ~41
         54        ASSIGN                                                   !9, ~42
   25    55        ASSIGN                                                   !3, 0
   26    56        FETCH_DIM_R                                      ~45     !9, 0
         57        CAST                                          6  ~46     ~45
         58        ASSIGN                                                   !4, ~46
   28    59        STRLEN                                           ~48     !9
         60        IS_SMALLER                                               1, ~48
         61      > JMPZ                                                     ~49, ->66
   30    62    >   FETCH_DIM_R                                      ~50     !9, 0
         63        ASSIGN                                                   !3, ~50
   31    64        FETCH_DIM_R                                      ~52     !9, 1
         65        ASSIGN                                                   !4, ~52
   33    66    >   ASSIGN_OP                                     8          !5, !4
   19    67        PRE_DEC                                                  !6
         68    >   IS_SMALLER_OR_EQUAL                                      0, !6
         69      > JMPNZ                                                    ~56, ->37
   35    70    >   INIT_FCALL                                               'strrev'
         71        SEND_VAR                                                 !5
         72        DO_ICALL                                         $57     
         73        ASSIGN                                                   !5, $57
   36    74        ECHO                                                     !5
         75      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.78 ms | 1016 KiB | 15 Q