             yAxisPointer = UnsafeMutablePointer(mutating: _from)
             xAxisCount = _to.count
             yAxisCount = _from.count
-            ctl = Ctl(reverse: true, path: [], pathPosition: [:])
+            ctl = Ctl(reverse: true, path: UnsafeMutablePointer<Int>.allocate(capacity: 0), pathPosition: [:])
         } else {
             xAxisPointer = UnsafeMutablePointer(mutating: _from)
             yAxisPointer = UnsafeMutablePointer(mutating: _to)
             xAxisCount = _from.count
             yAxisCount = _to.count
-            ctl = Ctl(reverse: false, path: [], pathPosition: [:])
+            ctl = Ctl(reverse: false, path: UnsafeMutablePointer<Int>.allocate(capacity: 0), pathPosition: [:])
         }
         let offset = xAxisCount + 1
         let delta = yAxisCount - xAxisCount
+        let tailIdx = delta + offset
         let size = xAxisCount + yAxisCount + 3
-        var fp = Array(repeating: -1, count: size)
-        ctl.path = Array(repeating: -1, count: size)
+        
+        let fpBuffer = UnsafeMutablePointer<Int>.allocate(capacity: size)
+        fpBuffer.initialize(to: -1, count: size)
+        
+        ctl.path = UnsafeMutablePointer<Int>.allocate(capacity: size)
+        ctl.path.initialize(to: -1, count: size)
         ctl.pathPosition = [:]
 
         

            if -p <= delta {
                for k in -p..<delta {
                    ctl.path[k + offset] = ctl.pathPosition.count
                    let kRes = calcFootPrint(ctl: ctl, fp: fp, index: k + offset)
                    
                    (fp[k + offset], ctl.pathPosition[ctl.pathPosition.count]) = snake(xAxis: xAxisPointer, yAxis: yAxisPointer, xAxisCount: xAxisCount, yAxisCount: yAxisCount, k: k, y: kRes.y, r: kRes.r)
                }
            }
            
            if delta <= delta + p {
                for k in stride(from: delta + p, to: delta, by: -1) {
                    ctl.path[k + offset] = ctl.pathPosition.count
                    let kRes = calcFootPrint(ctl: ctl, fp: fp, index: k + offset)
                    
                    (fp[k + offset], ctl.pathPosition[ctl.pathPosition.count]) = snake(xAxis: xAxisPointer, yAxis: yAxisPointer, xAxisCount: xAxisCount, yAxisCount: yAxisCount, k: k, y: kRes.y, r: kRes.r)
                }
            }
            
            ctl.path[delta + offset] = ctl.pathPosition.count
            let deltaResult = calcFootPrint(ctl: ctl, fp: fp, index: delta + offset)
            
            (fp[delta + offset], ctl.pathPosition[ctl.pathPosition.count]) = snake(xAxis: xAxisPointer, yAxis: yAxisPointer, xAxisCount: xAxisCount, yAxisCount: yAxisCount, k: delta, y: deltaResult.y, r: deltaResult.r)
            
            if fp[delta + offset] >= yAxisCount {
                break
            }
            
            p += 1
        }
        
        var r = ctl.path[delta + offset]
        var epc = [Int: Point]()
        while (r != -1) {
            epc[epc.count] = Point(x: ctl.pathPosition[r]!.x, y: ctl.pathPosition[r]!.y, k: -1)


private struct Ctl {
    let reverse: Bool
    var path : UnsafeMutablePointer<Int>
    var pathPosition: [Int: Point]
}
