// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/levdist.c
// Function: wf_ed
uint32_t *wf_ed(int32_t tl, const char *ts, int32_t ql, const char *qs, int32_t is_ext, int32_t bw, int32_t *score, int32_t *t_endl, int32_t *q_endl, int32_t *n_cigar)
{
    int32_t s = 0, n = 1, t_end = -1, q_end = -1, i;
    wf_diag1_t *a;
    uint32_t *cigar = 0;
    wf_tb_t tb = {0, 0, 0};
    assert(tl > 0 && ql > 0);
    MYMALLOC(a, 2 * (tl + ql + 2)); // without CIGAR, this would be all the memory needed
    a[0].d = 0, a[0].k = -1;
    while (1) {
        n = wf_step_basic(n_cigar? &tb : 0, is_ext, bw, tl, ts, ql, qs, n, a, &t_end, &q_end);
        if (n < 0) break;
        ++s;
    }
    free(a);
    if (n_cigar) { // generate CIGAR
        cigar = wf_traceback(t_end, ts, q_end, qs, &tb, n_cigar);
        for (i = 0; i < tb.n; ++i) free(tb.a[i].a);
        free(tb.a);
    }
    *score = s, *t_endl = t_end + 1, *q_endl = q_end + 1;
    return cigar;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xa0, %rsp
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0x14(%rbp)
movq %rsi, -0x20(%rbp)
movl %edx, -0x24(%rbp)
movq %rcx, -0x30(%rbp)
movl %r8d, -0x34(%rbp)
movl %r9d, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x1, -0x40(%rbp)
movl $0xffffffff, -0x44(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x48(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x60(%rbp)
leaq -0x78(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x21f0
cmpl $0x0, -0x14(%rbp)
jle 0x1ea86
cmpl $0x0, -0x24(%rbp)
jle 0x1ea86
jmp 0x1eaa5
leaq 0xfec3(%rip), %rdi      # 0x2e950
leaq 0xfecd(%rip), %rsi      # 0x2e961
movl $0x13e, %edx            # imm = 0x13E
leaq 0xfecb(%rip), %rcx      # 0x2e96b
callq 0x21e0
movl -0x14(%rbp), %eax
addl -0x24(%rbp), %eax
addl $0x2, %eax
shll %eax
cltq
imulq $0xc, %rax, %rdi
callq 0x2320
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movl $0x0, (%rax)
movq -0x58(%rbp), %rax
movl $0xffffffff, 0x4(%rax)  # imm = 0xFFFFFFFF
cmpq $0x0, 0x28(%rbp)
je 0x1eae5
leaq -0x78(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x1eaed
xorl %eax, %eax
movq %rax, -0x80(%rbp)
jmp 0x1eaed
movq -0x80(%rbp), %rdi
movl -0x34(%rbp), %esi
movl -0x38(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %r8
movl -0x24(%rbp), %r9d
movq -0x30(%rbp), %r14
movl -0x40(%rbp), %ebx
movq -0x58(%rbp), %r11
leaq -0x44(%rbp), %r10
leaq -0x48(%rbp), %rax
movq %r14, (%rsp)
movl %ebx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x1dfa0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jge 0x1eb3c
jmp 0x1eb47
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1ead4
movq -0x58(%rbp), %rdi
callq 0x2060
cmpq $0x0, 0x28(%rbp)
je 0x1ebb3
movl -0x44(%rbp), %edi
movq -0x20(%rbp), %rsi
movl -0x48(%rbp), %edx
movq -0x30(%rbp), %rcx
movq 0x28(%rbp), %r9
leaq -0x78(%rbp), %r8
callq 0x1e750
movq %rax, -0x60(%rbp)
movl $0x0, -0x4c(%rbp)
movslq -0x4c(%rbp), %rax
cmpq -0x70(%rbp), %rax
jae 0x1ebaa
movq -0x68(%rbp), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x2060
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1eb7d
movq -0x68(%rbp), %rdi
callq 0x2060
movl -0x3c(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movq 0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x48(%rbp), %ecx
addl $0x1, %ecx
movq 0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x60(%rbp), %rax
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopw %cs:(%rax,%rax)