// File: /workspace/github_cpp_makefile_star2_O2/ParkerLab[P]cta/src/cta.cpp
// Function: levenshtein_distance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, long long)
long long int levenshtein_distance(const std::string& s1, const std::string& s2, long long int maximum = 0) {
    // shortcuts
    if (s1 == s2) return 0;

    long long int s1_length = s1.size();
    long long int s2_length = s2.size();

    if (s1_length == 0) {
        return s2_length;
    }

    if (s2_length == 0) {
        return s1_length;
    }

    if (maximum) {
        long long int minimum_distance = llabs(s1_length - s2_length);
        if (maximum < minimum_distance) {
            return minimum_distance;
        }
    }

    // ok, not getting out of the work that easily
    std::vector<long long int> v1(s2_length + 1);
    std::vector<long long int> v2(s2_length + 1);

    for (long long int i = 0; i < s2_length; i++) {
        v1[i] = i;
    }

    long long int v1_size = v1.size();
    for (long long int i = 0; i < s1_length; i++) {
        v2[0] = i + 1;

        for (long long int j = 0; j < s2_length; j++) {
            int cost = s1[i] == s2[j] ? 0 : 1;
            v2[j + 1] = std::min(v2[j] + 1, std::min(v1[j + 1] + 1, v1[j] + cost));
        }

        long long int minimum = maximum + 1;
        for (long long int j = 0; j < v1_size; j++) {
            if (v2[j] < minimum) {
                minimum = v2[j];
            }
            v1[j] = v2[j];
        }
        if (minimum > maximum) {
            // abort early
            return maximum + 1;
        }
    }

    return v2[s2_length];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r15
callq 0xee63
testb %al, %al
je 0xceff
xorl %eax, %eax
jmp 0xd08f
movq 0x8(%r15), %rax
movq 0x8(%r13), %rcx
testq %rax, %rax
je 0xcf87
movq %rax, %rbp
testq %rcx, %rcx
je 0xd05e
testq %rbx, %rbx
je 0xcf36
movq %rbp, %rdx
subq %rcx, %rdx
movq %rdx, %rax
negq %rax
cmovsq %rdx, %rax
cmpq %rbx, %rax
jg 0xd08f
leaq 0x1(%rcx), %r12
leaq 0x28(%rsp), %rdi
leaq 0x40(%rsp), %rdx
movq %r12, %rsi
movq %rcx, %r14
callq 0xee8c
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %r12, %rsi
callq 0xee8c
movq 0x28(%rsp), %rcx
xorl %edx, %edx
testq %r14, %r14
movl $0x0, %eax
movq %r14, 0x18(%rsp)
cmovgq %r14, %rax
cmpq %rdx, %rax
je 0xcf8f
movq %rdx, (%rcx,%rdx,8)
incq %rdx
jmp 0xcf79
movq %rcx, %rax
jmp 0xd08f
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movq 0x40(%rsp), %rsi
xorl %r8d, %r8d
testq %rdx, %rdx
cmovleq %r8, %rdx
leaq 0x1(%rbx), %r11
testq %rbp, %rbp
cmovleq %r8, %rbp
movq %rbp, 0x20(%rsp)
movq %r11, 0x10(%rsp)
cmpq 0x20(%rsp), %r8
je 0xd063
movq %rbx, %r14
leaq 0x1(%r8), %rdi
movq %rdi, (%rsi)
movq %r15, %r12
movq (%r15), %r9
movq %r13, %r15
movq (%r13), %r10
movq %rdi, %r11
xorl %r13d, %r13d
cmpq %r13, %rax
je 0xd026
movb (%r9,%r8), %bpl
xorl %ebx, %ebx
cmpb (%r10,%r13), %bpl
setne %bl
movq 0x8(%rcx,%r13,8), %rbp
addq (%rcx,%r13,8), %rbx
cmpq %rbp, %rbx
jle 0xd012
incq %rbp
movq %rbp, %rbx
incq %r11
cmpq %r11, %rbx
cmovlq %rbx, %r11
movq %r11, 0x8(%rsi,%r13,8)
incq %r13
jmp 0xcfec
movq 0x10(%rsp), %r9
xorl %r8d, %r8d
movq %r14, %rbx
movq %r15, %r13
movq %r12, %r15
cmpq %r8, %rdx
je 0xd050
movq (%rsi,%r8,8), %r10
cmpq %r9, %r10
cmovlq %r10, %r9
movq %r10, (%rcx,%r8,8)
incq %r8
jmp 0xd037
movq %rdi, %r8
cmpq %rbx, %r9
jle 0xcfc4
jmp 0xd076
movq %rbp, %rax
jmp 0xd08f
movq 0x40(%rsp), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x1d052
leaq 0x28(%rsp), %rdi
callq 0x1d052
movq 0x10(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x1d052
movq %rbx, %rdi
callq 0xc820