// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/levdist.c
// Function: wf_step_basic
static int wf_step_basic(wf_tb_t *tb, int32_t is_ext, int32_t bw, int32_t tl, const char *ts, int32_t ql, const char *qs, int32_t n, wf_diag1_t *a, int32_t *t_end, int32_t *q_end)
{
    int32_t j, st = 0, en = n + 2;
    wf_diag1_t *b = a + n + 2; // temporary array

    // wfa_extend
    *t_end = *q_end = -1;
    for (j = 0; j < n; ++j) {
        wf_diag1_t *p = &a[j];
        int32_t k = p->k;
        if (k >= tl || k + p->d >= ql) continue;
        k = wf_extend(tl, ts, ql, qs, p);
        if (k + p->d == ql - 1 || k == tl - 1) {
            if (is_ext || (k + p->d == ql - 1 && k == tl - 1)) {
                *t_end = k, *q_end = k + p->d;
                return -1;
            }
        }
        p->k = k;
    }

    // wfa_next
    b[0].d = a[0].d - 1;
    b[0].p = 1;
    b[0].k = a[0].k + 1;
    b[1].d = a[0].d;
    b[1].p =  n == 1 || a[0].k > a[1].k? 0 : 1;
    b[1].k = (n == 1 || a[0].k > a[1].k? a[0].k : a[1].k) + 1;
    if (tb) { // with traceback
        for (j = 1; j < n - 1; ++j) {
            int32_t k = a[j-1].k, p = -1;
            p = k > a[j].k + 1? p : 0;
            k = k > a[j].k + 1? k : a[j].k + 1;
            p = k > a[j+1].k + 1? p : 1;
            k = k > a[j+1].k + 1? k : a[j+1].k + 1;
            b[j+1].d = a[j].d, b[j+1].k = k, b[j+1].p = p;
        }
    } else { // simpler without traceback
        for (j = 1; j < n - 1; ++j) {
            int32_t k = a[j-1].k;
            k = k > a[j].k + 1? k : a[j].k + 1;
            k = k > a[j+1].k + 1? k : a[j+1].k + 1;
            b[j+1].d = a[j].d, b[j+1].k = k;
        }
    }
    if (n >= 2) {
        b[n].d = a[n-1].d;
        b[n].p = a[n-2].k > a[n-1].k + 1? -1 : 0;
        b[n].k = a[n-2].k > a[n-1].k + 1? a[n-2].k : a[n-1].k + 1;
    }
    b[n+1].d = a[n-1].d + 1;
    b[n+1].p = -1;
    b[n+1].k = a[n-1].k;

    if (bw < 0 || n < bw + bw + 1) {
        if (b[0].d < -tl) ++st;
        if (b[n+1].d > ql) --en;
    } else wf_prune_bw(tl, ql, is_ext, bw, &st, &en, b);
    if (tb) { // keep traceback information
        wf_tb1_t *q;
        wf_tb_add(tb, n + 2);
        q = &tb->a[tb->n - 1];
        q->d0 = b[st].d;
        for (j = 0; j < en - st; ++j)
            q->a[j>>5] |= (uint64_t)(b[j+st].p + 1) << (j&0x1f)*2;
    }
    memcpy(a, &b[st], (en - st) * sizeof(*a));
    return en - st;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl $0x0, -0x34(%rbp)
movl 0x18(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x38(%rbp)
movq 0x20(%rbp), %rax
movslq 0x18(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addq $0x18, %rax
movq %rax, -0x40(%rbp)
movq 0x30(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x28(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl 0x18(%rbp), %eax
jge 0x1e0f7
movq 0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1e054
movl -0x4c(%rbp), %eax
movq -0x48(%rbp), %rcx
addl (%rcx), %eax
cmpl -0x2c(%rbp), %eax
jl 0x1e059
jmp 0x1e0e9
movl -0x1c(%rbp), %edi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
movq 0x10(%rbp), %rcx
movq -0x48(%rbp), %r8
callq 0x1f590
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x48(%rbp), %rcx
addl (%rcx), %eax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x1e093
movl -0x4c(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1e0df
cmpl $0x0, -0x14(%rbp)
jne 0x1e0b9
movl -0x4c(%rbp), %eax
movq -0x48(%rbp), %rcx
addl (%rcx), %eax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1e0dd
movl -0x4c(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1e0dd
movl -0x4c(%rbp), %ecx
movq 0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
addl (%rax), %ecx
movq 0x30(%rbp), %rax
movl %ecx, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1e736
jmp 0x1e0df
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1e015
movq 0x20(%rbp), %rax
movl (%rax), %ecx
subl $0x1, %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movl $0x1, 0x8(%rax)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x4(%rax)
movq 0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0xc(%rax)
movb $0x1, %al
cmpl $0x1, 0x18(%rbp)
movb %al, -0x61(%rbp)
je 0x1e14e
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
movq 0x20(%rbp), %rcx
cmpl 0x10(%rcx), %eax
setg %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %dl
movl $0x1, %ecx
xorl %eax, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x14(%rax)
cmpl $0x1, 0x18(%rbp)
je 0x1e17b
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
movq 0x20(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jle 0x1e187
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x68(%rbp)
jmp 0x1e191
movq 0x20(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %ecx
addl $0x1, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x10(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x1e348
movl $0x1, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl 0x18(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1e343
movq 0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x50(%rbp)
movl $0xffffffff, -0x54(%rbp) # imm = 0xFFFFFFFF
movl -0x50(%rbp), %eax
movq 0x20(%rbp), %rcx
movslq -0x30(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1e206
movl -0x54(%rbp), %eax
movl %eax, -0x6c(%rbp)
jmp 0x1e20d
xorl %eax, %eax
movl %eax, -0x6c(%rbp)
jmp 0x1e20d
movl -0x6c(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x50(%rbp), %eax
movq 0x20(%rbp), %rcx
movslq -0x30(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1e237
movl -0x50(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0x1e24f
movq 0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq 0x20(%rbp), %rcx
movl -0x30(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1e27e
movl -0x54(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0x1e288
movl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x1e288
movl -0x74(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x50(%rbp), %eax
movq 0x20(%rbp), %rcx
movl -0x30(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1e2b7
movl -0x50(%rbp), %eax
movl %eax, -0x78(%rbp)
jmp 0x1e2d4
movq 0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x50(%rbp)
movq 0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x40(%rbp), %rax
movl -0x30(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x50(%rbp), %ecx
movq -0x40(%rbp), %rax
movl -0x30(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x54(%rbp), %ecx
movq -0x40(%rbp), %rax
movl -0x30(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1e1b0
jmp 0x1e459
movl $0x1, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl 0x18(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1e457
movq 0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq 0x20(%rbp), %rcx
movslq -0x30(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1e39e
movl -0x58(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0x1e3b6
movq 0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq 0x20(%rbp), %rcx
movl -0x30(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1e3e5
movl -0x58(%rbp), %eax
movl %eax, -0x80(%rbp)
jmp 0x1e402
movq 0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x58(%rbp)
movq 0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x40(%rbp), %rax
movl -0x30(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x58(%rbp), %ecx
movq -0x40(%rbp), %rax
movl -0x30(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1e34f
jmp 0x1e459
cmpl $0x2, 0x18(%rbp)
jl 0x1e565
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x40(%rbp), %rax
movslq 0x18(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %edx
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %esi
addl $0x1, %esi
xorl %ecx, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %esi, %edx
cmovgl %eax, %ecx
movq -0x40(%rbp), %rax
movslq 0x18(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq 0x20(%rbp), %rcx
movl 0x18(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1e52d
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x84(%rbp)
jmp 0x1e54d
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %ecx
movq -0x40(%rbp), %rax
movslq 0x18(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x40(%rbp), %rax
movl 0x18(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movl 0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0x40(%rbp), %rax
movl 0x18(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
cmpl $0x0, -0x18(%rbp)
jl 0x1e5f3
movl 0x18(%rbp), %eax
movl -0x18(%rbp), %ecx
addl -0x18(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1e631
movq -0x40(%rbp), %rax
movl (%rax), %eax
xorl %ecx, %ecx
subl -0x1c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1e60b
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x40(%rbp), %rax
movl 0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x2c(%rbp), %eax
jle 0x1e62f
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1e652
movl -0x1c(%rbp), %edi
movl -0x2c(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movq -0x40(%rbp), %rax
leaq -0x34(%rbp), %r8
leaq -0x38(%rbp), %r9
movq %rax, (%rsp)
callq 0x1f6d0
cmpq $0x0, -0x10(%rbp)
je 0x1e709
movq -0x10(%rbp), %rdi
movl 0x18(%rbp), %esi
addl $0x2, %esi
callq 0x1f800
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
subq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x4(%rax)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl -0x38(%rbp), %ecx
subl -0x34(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1e707
movq -0x40(%rbp), %rax
movl -0x30(%rbp), %ecx
addl -0x34(%rbp), %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movslq %eax, %rdx
movl -0x30(%rbp), %eax
andl $0x1f, %eax
shll %eax
movl %eax, %eax
movl %eax, %ecx
shlq %cl, %rdx
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x30(%rbp), %ecx
sarl $0x5, %ecx
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1e6aa
jmp 0x1e709
movq 0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
movslq -0x34(%rbp), %rax
imulq $0xc, %rax, %rax
addq %rax, %rsi
movl -0x38(%rbp), %eax
subl -0x34(%rbp), %eax
cltq
imulq $0xc, %rax, %rdx
callq 0x22c0
movl -0x38(%rbp), %eax
subl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)