3v4l.org

run code in 300+ PHP versions simultaneously
<?php function edit_distance_ond($str1 ,$str2){ $array = array(); $x = 0; $y = 0; $offset = count($str1); $array[$offset + 1] = 0; for($D = 0; $D <= count($str1) + count($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 < count($str1) && $y < count($str2) && $str1[$x] == $str2[$y]){ $x++; $y++; } $array[$k+$offset] = $x; if($x >= count($str1) && $y >= count($str2)) return $D; } } return -1; } $a = array(); $a[0] = "aaa"; $a[1] = "bbb"; $a[2] = "ccc"; $b = array(); $b[0] = "aaa"; $b[1] = "bbb"; $b[2] = "cc"; echo edit_distance_ond($a,$b); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/okbq0
function name:  (null)
number of ops:  20
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, <array>
   27     1        ASSIGN_DIM                                               !0, 0
          2        OP_DATA                                                  'aaa'
   28     3        ASSIGN_DIM                                               !0, 1
          4        OP_DATA                                                  'bbb'
   29     5        ASSIGN_DIM                                               !0, 2
          6        OP_DATA                                                  'ccc'
   30     7        ASSIGN                                                   !1, <array>
   31     8        ASSIGN_DIM                                               !1, 0
          9        OP_DATA                                                  'aaa'
   32    10        ASSIGN_DIM                                               !1, 1
         11        OP_DATA                                                  'bbb'
   33    12        ASSIGN_DIM                                               !1, 2
         13        OP_DATA                                                  'cc'
   34    14        INIT_FCALL                                               'edit_distance_ond'
         15        SEND_VAR                                                 !0
         16        SEND_VAR                                                 !1
         17        DO_FCALL                                      0  $10     
         18        ECHO                                                     $10
   35    19      > RETURN                                                   1

Function edit_distance_ond:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 12
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 15
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 12
Branch analysis from position: 77
Branch analysis from position: 12
Branch analysis from position: 15
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 29
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 46) Position 1 = 48, Position 2 = 51
Branch analysis from position: 48
2 jumps found. (Code = 46) Position 1 = 52, Position 2 = 56
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 43
Branch analysis from position: 57
2 jumps found. (Code = 46) Position 1 = 63, Position 2 = 66
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 68
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 15
Branch analysis from position: 71
Branch analysis from position: 15
Branch analysis from position: 66
Branch analysis from position: 43
2 jumps found. (Code = 46) Position 1 = 48, Position 2 = 51
Branch analysis from position: 48
Branch analysis from position: 51
Branch analysis from position: 56
Branch analysis from position: 51
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 28
Branch analysis from position: 29
filename:       /in/okbq0
function name:  edit_distance_ond
number of ops:  79
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        COUNT                                            ~11     !0
          6        ASSIGN                                                   !5, ~11
    7     7        ADD                                              ~13     !5, 1
          8        ASSIGN_DIM                                               !2, ~13
          9        OP_DATA                                                  0
    8    10        ASSIGN                                                   !6, 0
         11      > JMP                                                      ->72
    9    12    >   MUL                                              ~16     !6, -1
         13        ASSIGN                                                   !7, ~16
         14      > JMP                                                      ->69
   10    15    >   MUL                                              ~18     !6, -1
         16        IS_EQUAL                                         ~19     !7, ~18
         17      > JMPNZ_EX                                         ~19     ~19, ->29
         18    >   IS_NOT_EQUAL                                     ~20     !7, !6
         19      > JMPZ_EX                                          ~20     ~20, ->28
         20    >   SUB                                              ~21     !7, 1
         21        ADD                                              ~22     ~21, !5
         22        FETCH_DIM_R                                      ~23     !2, ~22
         23        ADD                                              ~24     !7, 1
         24        ADD                                              ~25     ~24, !5
         25        FETCH_DIM_R                                      ~26     !2, ~25
         26        IS_SMALLER                                       ~27     ~23, ~26
         27        BOOL                                             ~20     ~27
         28    >   BOOL                                             ~19     ~20
         29    > > JMPZ                                                     ~19, ->35
   11    30    >   ADD                                              ~28     !7, 1
         31        ADD                                              ~29     ~28, !5
         32        FETCH_DIM_R                                      ~30     !2, ~29
         33        ASSIGN                                                   !3, ~30
         34      > JMP                                                      ->40
   13    35    >   SUB                                              ~32     !7, 1
         36        ADD                                              ~33     ~32, !5
         37        FETCH_DIM_R                                      ~34     !2, ~33
         38        ADD                                              ~35     ~34, 1
         39        ASSIGN                                                   !3, ~35
   14    40    >   SUB                                              ~37     !3, !7
         41        ASSIGN                                                   !4, ~37
   15    42      > JMP                                                      ->45
   16    43    >   PRE_INC                                                  !3
   17    44        PRE_INC                                                  !4
   15    45    >   COUNT                                            ~41     !0
         46        IS_SMALLER                                       ~42     !3, ~41
         47      > JMPZ_EX                                          ~42     ~42, ->51
         48    >   COUNT                                            ~43     !1
         49        IS_SMALLER                                       ~44     !4, ~43
         50        BOOL                                             ~42     ~44
         51    > > JMPZ_EX                                          ~42     ~42, ->56
         52    >   FETCH_DIM_R                                      ~45     !0, !3
         53        FETCH_DIM_R                                      ~46     !1, !4
         54        IS_EQUAL                                         ~47     ~45, ~46
         55        BOOL                                             ~42     ~47
         56    > > JMPNZ                                                    ~42, ->43
   19    57    >   ADD                                              ~48     !7, !5
         58        ASSIGN_DIM                                               !2, ~48
         59        OP_DATA                                                  !3
   20    60        COUNT                                            ~50     !0
         61        IS_SMALLER_OR_EQUAL                              ~51     ~50, !3
         62      > JMPZ_EX                                          ~51     ~51, ->66
         63    >   COUNT                                            ~52     !1
         64        IS_SMALLER_OR_EQUAL                              ~53     ~52, !4
         65        BOOL                                             ~51     ~53
         66    > > JMPZ                                                     ~51, ->68
   21    67    > > RETURN                                                   !6
    9    68    >   ASSIGN_OP                                     1          !7, 2
         69    >   IS_SMALLER_OR_EQUAL                                      !7, !6
         70      > JMPNZ                                                    ~55, ->15
    8    71    >   PRE_INC                                                  !6
         72    >   COUNT                                            ~57     !0
         73        COUNT                                            ~58     !1
         74        ADD                                              ~59     ~57, ~58
         75        IS_SMALLER_OR_EQUAL                                      !6, ~59
         76      > JMPNZ                                                    ~60, ->12
   24    77    > > RETURN                                                   -1
   25    78*     > RETURN                                                   null

End of function edit_distance_ond

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.24 ms | 1406 KiB | 14 Q