// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movq %rdx, 0x10(%rsp)
movq %rsi, %r12
movq %rdi, %r13
movq 0x8(%rdi), %rbx
movq 0x8(%rsi), %rbp
movq %rbx, %r14
subq %rbp, %r14
jne 0xc2d9
testq %rbx, %rbx
je 0xc2d1
movq (%r12), %rsi
movq (%r13), %rdi
movq %rbx, %rdx
callq 0xb4b0
testl %eax, %eax
jne 0xc2e2
xorl %r15d, %r15d
jmp 0xc4c4
testq %rbx, %rbx
je 0xc48f
testq %rbp, %rbp
je 0xc48a
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0xc308
movq %r14, %r15
negq %r15
cmovsq %r14, %r15
cmpq %rax, %r15
jg 0xc4c4
leaq 0x1(%rbp), %r15
leaq 0x18(%rsp), %rdi
leaq 0x30(%rsp), %rdx
movq %r15, %rsi
callq 0xf242
leaq 0x30(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %r15, %rsi
callq 0xf242
movq 0x18(%rsp), %rdi
testq %rbp, %rbp
jle 0xc3cb
andq $-0x2, %r15
leaq -0x1(%rbp), %rax
movq %rax, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x1ccb8(%rip), %xmm1    # 0x29010
xorl %eax, %eax
movdqa 0x1ccbe(%rip), %xmm2    # 0x29020
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x1ccbe(%rip), %xmm4    # 0x29030
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %ecx
notl %ecx
testb $0x1, %cl
je 0xc3a7
movq %rax, (%rdi,%rax,8)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %ecx
testb $0x1, %cl
je 0xc3be
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rdi,%rax,8)
addq $0x2, %rax
paddq %xmm4, %xmm1
cmpq %rax, %r15
jne 0xc372
movq 0x20(%rsp), %rax
subq %rdi, %rax
sarq $0x3, %rax
movq 0x30(%rsp), %rcx
movq (%r13), %rdx
movq (%r12), %rsi
movq 0x10(%rsp), %r13
leaq 0x1(%r13), %r15
xorl %r9d, %r9d
testq %rbx, %rbx
cmovleq %r9, %rbx
cmpq %rbx, %r9
je 0xc494
leaq 0x1(%r9), %r8
movq %r8, (%rcx)
testq %rbp, %rbp
jle 0xc450
movq %r8, %r10
xorl %r11d, %r11d
movb (%rdx,%r9), %r12b
xorl %r14d, %r14d
cmpb (%rsi,%r11), %r12b
setne %r14b
movq 0x8(%rdi,%r11,8), %r12
addq (%rdi,%r11,8), %r14
cmpq %r12, %r14
jle 0xc435
incq %r12
movq %r12, %r14
incq %r10
cmpq %r10, %r14
cmovlq %r14, %r10
movq %r10, 0x8(%rcx,%r11,8)
leaq 0x1(%r11), %r14
movq %r14, %r11
cmpq %r14, %rbp
jne 0xc412
testq %rax, %rax
jle 0xc47e
xorl %r9d, %r9d
movq %r15, %r10
movq (%rcx,%r9,8), %r11
cmpq %r10, %r11
cmovlq %r11, %r10
movq %r11, (%rdi,%r9,8)
incq %r9
cmpq %r9, %rax
jne 0xc45b
movq %r8, %r9
cmpq %r13, %r10
jle 0xc3f7
movq 0x30(%rsp), %rax
testq %rax, %rax
jne 0xc49d
jmp 0xc4b2
movq %rbx, %r15
jmp 0xc4c4
movq %rbp, %r15
jmp 0xc4c4
movq 0x30(%rsp), %rax
movq (%rax,%rbp,8), %r15
movq 0x40(%rsp), %rsi
subq %rax, %rsi
movq %rax, %rdi
callq 0xb480
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xc4c4
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0xb480
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xc4f0
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0xb480
movq %rbx, %rdi
callq 0xb7d0