3v4l.org

run code in 300+ PHP versions simultaneously
<?php function edit_distance_ond($str1 ,$str2){ $array = array(); $x = 0; $y = 0; $offset = mb_strlen($str1); $array[$offset + 1] = 0; for($D = 0; $D <= mb_strlen($str1) + mb_strlen($str2); $D++){ for($k = -$D; $k <= $D; $k += 2){ if($k == -$D || $k != $D && $array[$k-1+$offset] < $array[$k+1+$offset]) $x = $array[$k+1+$offset]; else $x = $array[$k-1+$offset] + 1; $y = $x - $k; while($x < mb_strlen($str1) && $y < mb_strlen($str2) && $str1[$x] == $str2[$y]){ $x++; $y++; } $array[$k+$offset] = $x; if($x >= mb_strlen($str1) && $y >= mb_strlen($str2)) return $D; } } return -1; } echo edit_distance_ond("abc","abd"); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uSjuD
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'edit_distance_ond'
          1        SEND_VAL                                                 'abc'
          2        SEND_VAL                                                 'abd'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
   27     5      > RETURN                                                   1

Function edit_distance_ond:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 82
Branch analysis from position: 82
2 jumps found. (Code = 44) Position 1 = 91, Position 2 = 14
Branch analysis from position: 91
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
2 jumps found. (Code = 44) Position 1 = 81, Position 2 = 17
Branch analysis from position: 81
2 jumps found. (Code = 44) Position 1 = 91, Position 2 = 14
Branch analysis from position: 91
Branch analysis from position: 14
Branch analysis from position: 17
2 jumps found. (Code = 47) Position 1 = 20, Position 2 = 31
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 30
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 37
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
2 jumps found. (Code = 46) Position 1 = 52, Position 2 = 57
Branch analysis from position: 52
2 jumps found. (Code = 46) Position 1 = 58, Position 2 = 62
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 45
Branch analysis from position: 63
2 jumps found. (Code = 46) Position 1 = 71, Position 2 = 76
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 78
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 78
2 jumps found. (Code = 44) Position 1 = 81, Position 2 = 17
Branch analysis from position: 81
Branch analysis from position: 17
Branch analysis from position: 76
Branch analysis from position: 45
2 jumps found. (Code = 46) Position 1 = 52, Position 2 = 57
Branch analysis from position: 52
Branch analysis from position: 57
Branch analysis from position: 62
Branch analysis from position: 57
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 30
Branch analysis from position: 31
filename:       /in/uSjuD
function name:  edit_distance_ond
number of ops:  93
compiled vars:  !0 = $str1, !1 = $str2, !2 = $array, !3 = $x, !4 = $y, !5 = $offset, !6 = $D, !7 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        ASSIGN                                                   !2, <array>
    4     3        ASSIGN                                                   !3, 0
    5     4        ASSIGN                                                   !4, 0
    6     5        INIT_FCALL                                               'mb_strlen'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $11     
          8        ASSIGN                                                   !5, $11
    7     9        ADD                                              ~13     !5, 1
         10        ASSIGN_DIM                                               !2, ~13
         11        OP_DATA                                                  0
    8    12        ASSIGN                                                   !6, 0
         13      > JMP                                                      ->82
    9    14    >   MUL                                              ~16     !6, -1
         15        ASSIGN                                                   !7, ~16
         16      > JMP                                                      ->79
   10    17    >   MUL                                              ~18     !6, -1
         18        IS_EQUAL                                         ~19     !7, ~18
         19      > JMPNZ_EX                                         ~19     ~19, ->31
         20    >   IS_NOT_EQUAL                                     ~20     !7, !6
         21      > JMPZ_EX                                          ~20     ~20, ->30
         22    >   SUB                                              ~21     !7, 1
         23        ADD                                              ~22     ~21, !5
         24        FETCH_DIM_R                                      ~23     !2, ~22
         25        ADD                                              ~24     !7, 1
         26        ADD                                              ~25     ~24, !5
         27        FETCH_DIM_R                                      ~26     !2, ~25
         28        IS_SMALLER                                       ~27     ~23, ~26
         29        BOOL                                             ~20     ~27
         30    >   BOOL                                             ~19     ~20
         31    > > JMPZ                                                     ~19, ->37
   11    32    >   ADD                                              ~28     !7, 1
         33        ADD                                              ~29     ~28, !5
         34        FETCH_DIM_R                                      ~30     !2, ~29
         35        ASSIGN                                                   !3, ~30
         36      > JMP                                                      ->42
   13    37    >   SUB                                              ~32     !7, 1
         38        ADD                                              ~33     ~32, !5
         39        FETCH_DIM_R                                      ~34     !2, ~33
         40        ADD                                              ~35     ~34, 1
         41        ASSIGN                                                   !3, ~35
   14    42    >   SUB                                              ~37     !3, !7
         43        ASSIGN                                                   !4, ~37
   15    44      > JMP                                                      ->47
   16    45    >   PRE_INC                                                  !3
   17    46        PRE_INC                                                  !4
   15    47    >   INIT_FCALL                                               'mb_strlen'
         48        SEND_VAR                                                 !0
         49        DO_ICALL                                         $41     
         50        IS_SMALLER                                       ~42     !3, $41
         51      > JMPZ_EX                                          ~42     ~42, ->57
         52    >   INIT_FCALL                                               'mb_strlen'
         53        SEND_VAR                                                 !1
         54        DO_ICALL                                         $43     
         55        IS_SMALLER                                       ~44     !4, $43
         56        BOOL                                             ~42     ~44
         57    > > JMPZ_EX                                          ~42     ~42, ->62
         58    >   FETCH_DIM_R                                      ~45     !0, !3
         59        FETCH_DIM_R                                      ~46     !1, !4
         60        IS_EQUAL                                         ~47     ~45, ~46
         61        BOOL                                             ~42     ~47
         62    > > JMPNZ                                                    ~42, ->45
   19    63    >   ADD                                              ~48     !7, !5
         64        ASSIGN_DIM                                               !2, ~48
         65        OP_DATA                                                  !3
   20    66        INIT_FCALL                                               'mb_strlen'
         67        SEND_VAR                                                 !0
         68        DO_ICALL                                         $50     
         69        IS_SMALLER_OR_EQUAL                              ~51     $50, !3
         70      > JMPZ_EX                                          ~51     ~51, ->76
         71    >   INIT_FCALL                                               'mb_strlen'
         72        SEND_VAR                                                 !1
         73        DO_ICALL                                         $52     
         74        IS_SMALLER_OR_EQUAL                              ~53     $52, !4
         75        BOOL                                             ~51     ~53
         76    > > JMPZ                                                     ~51, ->78
   21    77    > > RETURN                                                   !6
    9    78    >   ASSIGN_OP                                     1          !7, 2
         79    >   IS_SMALLER_OR_EQUAL                                      !7, !6
         80      > JMPNZ                                                    ~55, ->17
    8    81    >   PRE_INC                                                  !6
         82    >   INIT_FCALL                                               'mb_strlen'
         83        SEND_VAR                                                 !0
         84        DO_ICALL                                         $57     
         85        INIT_FCALL                                               'mb_strlen'
         86        SEND_VAR                                                 !1
         87        DO_ICALL                                         $58     
         88        ADD                                              ~59     $57, $58
         89        IS_SMALLER_OR_EQUAL                                      !6, ~59
         90      > JMPNZ                                                    ~60, ->14
   24    91    > > RETURN                                                   -1
   25    92*     > RETURN                                                   null

End of function edit_distance_ond

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.48 ms | 1407 KiB | 16 Q