// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/syncasm.c
// Function: find_lcs
static uint64_t *find_lcs(uint64_t *s_scm, int s_n, uint64_t *u_scm, int u_n, int offset, int max_d, int *n_block)
{
    int i, j, start, s_end, u_end;
    lcs_block_t blocks;

    kv_init(blocks);
    *n_block = 0;

    start = 0;
    s_end = s_n - 1;
    u_end = u_n - 1;

    // trim off the matching syncmers at the beginning and end
    while (start < s_n && start < u_n && (s_scm[start] >> 1) == (u_scm[start] >> 1)) { ++start; }
    while (start <= s_end && start <= u_end && (s_scm[s_end] >> 1) == (u_scm[u_end] >> 1)) { --s_end; --u_end; }

    if (start > 0)
        kv_push(uint64_t, blocks, (uint64_t) offset << 32 | start);

    s_scm = &s_scm[start];
    u_scm = &u_scm[start];
    s_end = s_end - start + 1;
    u_end = u_end - start + 1;

    // core LCS
    int *D, **L;
    MYCALLOC(D, (s_end + 1) * (u_end + 1));
    MYMALLOC(L, s_end + 1);
    L[0] = D;
    for (i = 1; i <= s_end; ++i) {
        L[i] = &L[i - 1][u_end + 1];
        for (j = 1; j <= u_end; ++j) {
            if ((s_scm[i - 1] >> 1) == (u_scm[j - 1] >> 1))
                L[i][j] = L[i - 1][j - 1] + 1;
            else
                L[i][j] = MAX(L[i - 1][j], L[i][j - 1]);
        }
    }

    // LCS backtrace
    uint32_t n_b = blocks.n;
    lcs_backtrace(L, s_scm - 1, s_end, u_scm - 1, u_end, offset + start, &blocks);
    free(D);
    free(L);

    // reverse backtrace array
    array_reverse(&blocks.a[n_b], blocks.n - n_b);

    if (start + s_end < s_n)
        kv_push(uint64_t, blocks, (uint64_t) (offset + start + s_end) << 32 | (s_n - start - s_end));

    // merge LCS blocks
    lcs_block_merge(&blocks);

#ifdef DEBUG_LCS_BLOCK
    size_t k;
    for (k = 0; k < blocks.n; ++k)
        fprintf(stderr, "[DEBUG_LCS_BLOCK::%s] LCS_MATCH_BLOCK_%lu: %lu %u\n",
                __func__, k, blocks.a[k]>>32, (uint32_t) blocks.a[k]);
#endif

    *n_block = blocks.n;

    return blocks.a;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x30(%rbp)
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x30(%rbp), %ecx
xorl %eax, %eax
cmpl -0xc(%rbp), %ecx
movb %al, -0x81(%rbp)
jge 0x10a1a
movl -0x30(%rbp), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0x81(%rbp)
jge 0x10a1a
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq %rax
movq -0x18(%rbp), %rcx
movslq -0x30(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
cmpq %rcx, %rax
sete %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x10a26
jmp 0x10a31
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x109d0
jmp 0x10a33
movl -0x30(%rbp), %ecx
xorl %eax, %eax
cmpl -0x34(%rbp), %ecx
movb %al, -0x82(%rbp)
jg 0x10a7d
movl -0x30(%rbp), %ecx
xorl %eax, %eax
cmpl -0x38(%rbp), %ecx
movb %al, -0x82(%rbp)
jg 0x10a7d
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq %rax
movq -0x18(%rbp), %rcx
movslq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
cmpq %rcx, %rax
sete %al
movb %al, -0x82(%rbp)
movb -0x82(%rbp), %al
testb $0x1, %al
jne 0x10a89
jmp 0x10a9d
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x10a33
cmpl $0x0, -0x30(%rbp)
jle 0x10b1c
jmp 0x10aa5
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x10af4
cmpq $0x0, -0x48(%rbp)
je 0x10ac6
movq -0x48(%rbp), %rax
shlq %rax
movq %rax, -0x90(%rbp)
jmp 0x10ad4
movl $0x2, %eax
movq %rax, -0x90(%rbp)
jmp 0x10ad4
movq -0x90(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, -0x40(%rbp)
movslq -0x20(%rbp), %rdx
shlq $0x20, %rdx
movslq -0x30(%rbp), %rax
orq %rax, %rdx
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x50(%rbp)
movq %rdx, (%rax,%rcx,8)
jmp 0x10b1c
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x18(%rbp), %rax
movslq -0x30(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movl -0x34(%rbp), %eax
subl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %eax
subl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
movslq %eax, %rdi
movl $0x4, %esi
callq 0x2250
movq %rax, -0x58(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x2320
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0x10cfb
movq -0x60(%rbp), %rax
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movl -0x38(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x2, %rax
addq %rax, %rdx
movq -0x60(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jg 0x10ceb
movq -0x8(%rbp), %rax
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
shrq %rax
movq -0x18(%rbp), %rcx
movl -0x2c(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
cmpq %rcx, %rax
jne 0x10c52
movq -0x60(%rbp), %rax
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movq -0x60(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x10cdb
movq -0x60(%rbp), %rax
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x60(%rbp), %rcx
movslq -0x28(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl -0x2c(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0x10ca4
movq -0x60(%rbp), %rax
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x94(%rbp)
jmp 0x10cc2
movq -0x60(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %edx
movq -0x60(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x10cdd
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x10be1
jmp 0x10ced
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x10ba2
movq -0x50(%rbp), %rax
movl %eax, -0x64(%rbp)
movq -0x60(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $-0x8, %rsi
movl -0x34(%rbp), %edx
movq -0x18(%rbp), %rcx
addq $-0x8, %rcx
movl -0x38(%rbp), %r8d
movl -0x20(%rbp), %r9d
addl -0x30(%rbp), %r9d
leaq -0x50(%rbp), %rax
movq %rax, (%rsp)
callq 0x10ec0
movq -0x58(%rbp), %rdi
callq 0x2060
movq -0x60(%rbp), %rdi
callq 0x2060
movq -0x50(%rbp), %rax
movl -0x64(%rbp), %ecx
subq %rcx, %rax
cmpq $0x0, %rax
jbe 0x10dfb
movq $0x0, -0x70(%rbp)
movq -0x50(%rbp), %rax
movl -0x64(%rbp), %ecx
subq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
jae 0x10df9
movq -0x40(%rbp), %rax
movl -0x64(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x80(%rbp)
movq -0x40(%rbp), %rax
movl -0x64(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x40(%rbp), %rax
movl -0x64(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq -0x70(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x80(%rbp), %rdx
movq -0x40(%rbp), %rax
movl -0x64(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq -0x78(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
movq -0x78(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x10d72
jmp 0x10dfb
jmp 0x10dfd
movl -0x30(%rbp), %eax
addl -0x34(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x10e94
jmp 0x10e0e
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x10e5d
cmpq $0x0, -0x48(%rbp)
je 0x10e2f
movq -0x48(%rbp), %rax
shlq %rax
movq %rax, -0xa0(%rbp)
jmp 0x10e3d
movl $0x2, %eax
movq %rax, -0xa0(%rbp)
jmp 0x10e3d
movq -0xa0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, -0x40(%rbp)
movl -0x20(%rbp), %eax
addl -0x30(%rbp), %eax
addl -0x34(%rbp), %eax
movslq %eax, %rdx
shlq $0x20, %rdx
movl -0xc(%rbp), %eax
subl -0x30(%rbp), %eax
subl -0x34(%rbp), %eax
cltq
orq %rax, %rdx
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x50(%rbp)
movq %rdx, (%rax,%rcx,8)
jmp 0x10e94
leaq -0x50(%rbp), %rdi
callq 0x11070
movq -0x50(%rbp), %rax
movl %eax, %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)