// File: /workspace/github_c_makefile_star2_O3/c-zhou[P]oatk/levdist.c
// Function: wf_print_alignment
void wf_print_alignment(char *ts, int tl, char *qs, int ql, uint32_t *cigar, int32_t n_cigar, int lwd, FILE *fo)
{
    if (!cigar || !n_cigar)
        return;
    
    int32_t i, ti, qi;
    uint32_t cl, l;
    uint8_t c;
    kstring_t t_seq = {0, 0, 0}, q_seq = {0, 0, 0}, a_seq = {0, 0, 0};
    ti = qi = l = 0;
    for (i = 0; i < n_cigar; ++i) {
        c = "MIDNSHP=XB"[cigar[i]&0xf];
        cl = cigar[i]>>4;
        switch (c) {
            case 'I':
                kputcn_('-', cl, &t_seq);
                kputsn_(&qs[qi], cl, &q_seq);
                kputcn_(' ', cl, &a_seq);
                qi += cl;
                break;
            case 'D':
                kputsn_(&ts[ti], cl, &t_seq);
                kputcn_('-', cl, &q_seq);
                kputcn_(' ', cl, &a_seq);
                ti += cl;
                break;
            case 'M':
            case '=':
            case 'X':
                kputsn_(&ts[ti], cl, &t_seq);
                if (c == 'M')
                    for (l = 0; l < cl; ++l)
                        kputc_(ts[ti+l] == qs[qi+l]? '|' : '*', &a_seq);
                else
                    kputcn_(c == '='? '|' : '*', cl, &a_seq);
                kputsn_(&qs[qi], cl, &q_seq);
                ti += cl;
                qi += cl;
                break;
            default:
                fprintf(stderr, "[E::%s] unsupported cigar element '%c'\n", __func__, c);
                goto do_clean;
        }
    }

    if (lwd <= 0) {
        fprintf(fo, "target: %.*s\n", (int) t_seq.l, t_seq.s);
        fprintf(fo, "        %.*s\n", (int) a_seq.l, a_seq.s);
        fprintf(fo, " query: %.*s\n", (int) q_seq.l, q_seq.s);
    } else {
        uint32_t j, t_beg, t_end, q_beg, q_end;
        int b = 0;
        l = t_seq.l;
        while (l > 0) { l /= 10; ++b; }
        kstring_t pad = {0, 0, 0};
        kputcn_(' ', b + b + 14, &pad);
        l = 0;
        t_beg = q_beg = 0;
        while (l < t_seq.l) {
            cl = l;
            l += lwd;
            if (l > t_seq.l)
                l = t_seq.l;
            t_end = t_beg + l - cl;
            q_end = q_beg + l - cl;
            for (j = cl; j < l; ++j) {
                t_end -= (t_seq.s[j] == '-');
                q_end -= (q_seq.s[j] == '-');
            }
            fprintf(fo, "target [%*.u - %-*.u]: %.*s\n", b, t_beg + 1, b, t_end, (int) (l - cl), &t_seq.s[cl]);
            fprintf(fo, "%.*s%.*s\n", (int) pad.l, pad.s, (int) (l - cl), &a_seq.s[cl]);
            fprintf(fo, " query [%*.u - %-*.u]: %.*s\n", b, q_beg + 1, b, q_end, (int) (l - cl), &q_seq.s[cl]);
            fputc('\n', fo);
            t_beg = t_end;
            q_beg = q_end;
        }
        free(pad.s);
    }

do_clean:
    free(t_seq.s); free(q_seq.s); free(a_seq.s);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, 0x70(%rsp)
movq %rdi, 0x68(%rsp)
movq %r8, 0x98(%rsp)
testq %r8, %r8
sete %al
testl %r9d, %r9d
sete %cl
orb %al, %cl
jne 0x156dc
movq 0xe8(%rsp), %rax
movq %rax, 0x78(%rsp)
movl 0xe0(%rsp), %eax
movq %rax, 0x80(%rsp)
testl %r9d, %r9d
jle 0x156ee
movl %r9d, %eax
movq %rax, 0x90(%rsp)
xorl %ebp, %ebp
movl $0x0, 0x2c(%rsp)
xorl %r12d, %r12d
xorl %edi, %edi
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x48(%rsp)
movq $0x0, 0x20(%rsp)
xorl %r8d, %r8d
movq $0x0, 0x40(%rsp)
xorl %r9d, %r9d
movq 0x98(%rsp), %rax
movl (%rax,%rbp,4), %r13d
movl %r13d, %r14d
andl $0xf, %r14d
leaq 0xbb03(%rip), %rax      # 0x20b1d
movzbl (%r14,%rax), %ecx
movl %r13d, %r15d
shrl $0x4, %r15d
cmpl $0x48, %ecx
movl %r12d, 0x58(%rsp)
jle 0x150af
cmpl $0x58, %ecx
je 0x151a2
cmpl $0x4d, %ecx
je 0x151a2
cmpl $0x49, %ecx
jne 0x1597c
leaq (%r9,%r15), %rax
cmpq 0x40(%rsp), %rax
jbe 0x15565
movq %rdi, %r14
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %r8, %rdi
movq %rsi, 0x40(%rsp)
movq %r9, %rbx
callq 0x2350
movq %rbx, %r9
movq %rax, %r8
jmp 0x15568
cmpl $0x3d, %ecx
je 0x151a2
cmpl $0x44, %ecx
jne 0x1597c
movq %r15, 0x50(%rsp)
movl %r15d, %ebx
leaq (%r9,%rbx), %rax
cmpq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rdi, %r15
jbe 0x15129
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %r8, %rdi
movq %rsi, 0x40(%rsp)
movq %r9, %r14
callq 0x2350
movq %r14, %r9
movq %rax, %r8
movslq %r12d, %rsi
addq 0x68(%rsp), %rsi
movq %r8, 0x38(%rsp)
addq %r8, %r9
movq %r9, %rdi
movq %rbx, %rdx
callq 0x22b0
movq 0x20(%rsp), %rax
addq %rbx, %rax
cmpq 0x48(%rsp), %rax
jbe 0x15481
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq 0x18(%rsp), %rdi
movq %rsi, 0x48(%rsp)
callq 0x2350
jmp 0x15486
movq %rdi, 0x60(%rsp)
movl %r15d, %ebx
leaq (%r9,%rbx), %rax
cmpq 0x40(%rsp), %rax
movq %rbx, 0x30(%rsp)
movq %rax, 0xa0(%rsp)
jbe 0x15220
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %r8, %rdi
movq %rsi, 0x40(%rsp)
movl %r12d, %ebx
movq %r13, %r12
movq %r9, %r13
callq 0x2350
movq %r13, %r9
movq %r12, %r13
movl %ebx, %r12d
movq 0x30(%rsp), %rbx
movq %rax, %r8
movslq %r12d, %rsi
addq 0x68(%rsp), %rsi
movq %r8, 0x38(%rsp)
addq %r8, %r9
movq %r9, %rdi
movq %rbx, %rdx
callq 0x22b0
testl %r14d, %r14d
movq %rbp, 0x88(%rsp)
movq %r15, 0x50(%rsp)
je 0x152f5
movq 0x8(%rsp), %rdx
leaq (%rdx,%rbx), %rax
cmpq 0x10(%rsp), %rax
movq 0x60(%rsp), %rdi
jbe 0x152af
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x10(%rsp)
callq 0x2350
movq 0x8(%rsp), %rdx
movq %rax, %rdi
cmpl $0x10, %r13d
jb 0x152eb
movq %rdi, %r15
addq %rdx, %rdi
movq 0x50(%rsp), %rax
leal -0x1(%rax), %ebx
leaq 0x1(%rbx), %rdx
cmpl $0x7, %r14d
movl $0x2a, %esi
movl $0x7c, %eax
cmovel %eax, %esi
callq 0x21e0
movq 0x8(%rsp), %rdx
movq %r15, %rdi
addq %rbx, %rdx
incq %rdx
movq 0x10(%rsp), %rbp
jmp 0x153b7
cmpl $0x10, %r13d
movq 0x60(%rsp), %rdi
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rbp
jb 0x153b7
movq %rbx, %r14
movl %r12d, %r15d
movl 0x2c(%rsp), %ebx
movq %rdx, %r12
movl %r15d, %eax
movq 0x68(%rsp), %rcx
movb (%rcx,%rax), %sil
movl %ebx, %eax
movq 0x70(%rsp), %rcx
movb (%rcx,%rax), %al
leaq 0x1(%r12), %rdx
cmpq %rbp, %rdx
jbe 0x15392
movb %al, 0x10(%rsp)
movq %r12, %rax
shrq %rax
orq %r12, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rbp
shrq $0x10, %rbp
orq %rcx, %rbp
incq %rbp
movb %sil, 0x8(%rsp)
movq %rbp, %rsi
movq %rdx, %r13
callq 0x2350
movb 0x8(%rsp), %sil
movq %r13, %rdx
movq %rax, %rdi
movb 0x10(%rsp), %al
cmpb %al, %sil
movl $0x2a, %eax
movl $0x7c, %ecx
cmovel %ecx, %eax
movb %al, (%rdi,%r12)
incl %ebx
incl %r15d
movq %rdx, %r12
decq %r14
jne 0x1531b
movq %rdi, %r14
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
leaq (%rax,%rcx), %rbx
cmpq 0x48(%rsp), %rbx
movq %rbp, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
jbe 0x15422
leaq -0x1(%rbx), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq 0x18(%rsp), %rdi
movq %rsi, 0x48(%rsp)
callq 0x2350
jmp 0x15427
movq 0x18(%rsp), %rax
movq 0x88(%rsp), %rbp
movl 0x58(%rsp), %r12d
movl 0x2c(%rsp), %r15d
movslq %r15d, %rsi
addq 0x70(%rsp), %rsi
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rdi
addq %rax, %rdi
movq 0x30(%rsp), %rdx
callq 0x22b0
movq 0x50(%rsp), %rax
addl %eax, %r12d
addl %r15d, %eax
movq 0xa0(%rsp), %r9
movq %rbx, 0x20(%rsp)
movl %eax, 0x2c(%rsp)
movq %r14, %rdi
movq 0x38(%rsp), %r8
jmp 0x156c9
movq 0x18(%rsp), %rax
cmpl $0x10, %r13d
movq %rax, 0x18(%rsp)
jb 0x154bc
movq 0x20(%rsp), %r12
leaq (%rax,%r12), %rdi
movq 0x50(%rsp), %rax
leal -0x1(%rax), %r14d
leaq 0x1(%r14), %rdx
movl $0x2d, %esi
callq 0x21e0
addq %r14, %r12
incq %r12
movq %r12, 0x20(%rsp)
movq %r15, %rdi
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rax
addq %rcx, %rbx
cmpq %rax, %rbx
jbe 0x1551a
decq %rbx
movq %rbx, %rax
shrq %rax
orq %rbx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x10(%rsp)
callq 0x2350
movq 0x8(%rsp), %rcx
movq %rax, %rdi
movq 0x50(%rsp), %r15
cmpl $0x10, %r13d
jb 0x1554e
movq %rdi, %r14
addq %rcx, %rdi
leal -0x1(%r15), %ebx
leaq 0x1(%rbx), %rdx
movl $0x20, %esi
movq %rcx, %r12
callq 0x21e0
movq %r14, %rdi
addq %rbx, %r12
incq %r12
movq %r12, 0x8(%rsp)
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %r9
addl 0x58(%rsp), %r15d
movl %r15d, %r12d
jmp 0x156c9
movq %rdi, %r14
cmpl $0x10, %r13d
movq %r8, 0x38(%rsp)
jb 0x15593
leaq (%r8,%r9), %rdi
leal -0x1(%r15), %ebx
leaq 0x1(%rbx), %rdx
movl $0x2d, %esi
movq %r9, %r12
callq 0x21e0
leaq (%rbx,%r12), %r9
incq %r9
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rax
leaq (%rax,%r15), %rbx
cmpq 0x48(%rsp), %rbx
movq %r9, 0x30(%rsp)
jbe 0x155f5
leaq -0x1(%rbx), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rdx, %rdi
movq %rsi, 0x48(%rsp)
callq 0x2350
movq %rax, %rdx
movslq 0x2c(%rsp), %rsi
addq 0x70(%rsp), %rsi
movq %rdx, 0x18(%rsp)
movq 0x20(%rsp), %rdi
addq %rdx, %rdi
movq %r15, %rdx
callq 0x22b0
movq 0x8(%rsp), %rcx
leaq (%rcx,%r15), %rax
cmpq 0x10(%rsp), %rax
jbe 0x15672
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %r14, %rdi
movq %rsi, 0x10(%rsp)
callq 0x2350
movq 0x8(%rsp), %rcx
movq %rax, %rdi
jmp 0x15675
movq %r14, %rdi
cmpl $0x10, %r13d
jb 0x156ab
movq %r15, %r12
movq %rdi, %r15
addq %rcx, %rdi
leal -0x1(%r12), %r14d
leaq 0x1(%r14), %rdx
movl $0x20, %esi
movq %rcx, %r13
callq 0x21e0
movq %r15, %rdi
movq %r12, %r15
addq %r14, %r13
incq %r13
movq %r13, 0x8(%rsp)
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %r9
addl 0x2c(%rsp), %r15d
movq %rbx, 0x20(%rsp)
movl %r15d, 0x2c(%rsp)
movl 0x58(%rsp), %r12d
incq %rbp
cmpq 0x90(%rsp), %rbp
jne 0x15000
jmp 0x15711
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r9d, %r9d
xorl %r8d, %r8d
movq $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
xorl %edi, %edi
cmpl $0x0, 0x80(%rsp)
jle 0x1574e
testl %r9d, %r9d
movq %r8, 0x38(%rsp)
movq %r9, 0x30(%rsp)
movq %rdi, 0x60(%rsp)
je 0x157ac
xorl %ebx, %ebx
movl $0xcccccccd, %eax       # imm = 0xCCCCCCCD
movl %r9d, %ecx
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x23, %rdx
incl %ebx
cmpl $0x9, %ecx
movl %edx, %ecx
ja 0x15739
jmp 0x157ae
leaq 0xb40e(%rip), %rsi      # 0x20b63
movq %rdi, %rbx
movq 0x78(%rsp), %r14
movq %r14, %rdi
movl %r9d, %edx
movq %r8, %rcx
xorl %eax, %eax
movq %r8, %r15
callq 0x2280
leaq 0xb3fa(%rip), %rsi      # 0x20b71
movq %r14, %rdi
movq 0x8(%rsp), %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2280
leaq 0xb3ef(%rip), %rsi      # 0x20b7f
movq %r14, %rdi
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %r14
movq %r14, %rcx
xorl %eax, %eax
callq 0x2280
jmp 0x15953
xorl %ebx, %ebx
leal 0xd(,%rbx,2), %eax
movl %eax, %ecx
shrl %ecx
orl %eax, %ecx
movl %ecx, %eax
shrl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
shrl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
shrl $0x8, %eax
orl %ecx, %eax
movl %eax, %edi
shrl $0x10, %edi
orl %eax, %edi
incq %rdi
callq 0x2310
movq %rbx, 0x20(%rsp)
leal 0xe(,%rbx,2), %edx
movq %rax, 0x10(%rsp)
movq %rax, %rdi
movl $0x20, %esi
movq %rdx, 0x58(%rsp)
callq 0x21e0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1593a
xorl %ebx, %ebx
xorl %eax, %eax
xorl %ebp, %ebp
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x20(%rsp), %r12
movq 0x80(%rsp), %rsi
addl %edx, %esi
cmpq %rsi, %rdi
cmovbl %edi, %esi
leal (%rcx,%rax), %r13d
addl %esi, %r13d
addl %ebp, %eax
addl %esi, %eax
movl %esi, %r14d
movq %rsi, 0x70(%rsp)
movl %esi, %r15d
subl %edx, %r14d
jbe 0x1587a
movl %edx, %edx
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %r8
xorl %esi, %esi
cmpb $0x2d, (%r8,%rdx)
sete %sil
subl %esi, %r13d
xorl %esi, %esi
cmpb $0x2d, (%rdi,%rdx)
sete %sil
subl %esi, %eax
incq %rdx
cmpq %rdx, %r15
jne 0x15856
jmp 0x1587f
movq 0x38(%rsp), %r8
movl %eax, 0x68(%rsp)
incl %ecx
leaq (%r8,%rbx), %r10
movq 0x78(%rsp), %rdi
leaq 0xb2f8(%rip), %rsi      # 0x20b8d
movl %r12d, %edx
movl %r12d, %r8d
movl %r13d, %r9d
xorl %eax, %eax
pushq %r10
pushq %r14
movq %r14, 0x18(%rsp)
callq 0x2280
addq $0x10, %rsp
movq 0x60(%rsp), %rax
leaq (%rax,%rbx), %r9
movq 0x78(%rsp), %rdi
leaq 0xb2e3(%rip), %rsi      # 0x20baa
movq 0x58(%rsp), %rdx
movq 0x10(%rsp), %rcx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x2280
incl %ebp
addq 0x18(%rsp), %rbx
movq 0x78(%rsp), %r14
movq %r14, %rdi
leaq 0xb2c3(%rip), %rsi      # 0x20bb4
movl %r12d, %edx
movl %ebp, %ecx
movl %r12d, %r8d
movl 0x68(%rsp), %ebp
movl %ebp, %r9d
xorl %eax, %eax
pushq %rbx
pushq 0x10(%rsp)
callq 0x2280
addq $0x10, %rsp
movl $0xa, %edi
movq %r14, %rsi
callq 0x2210
movq 0x70(%rsp), %rdx
movl %edx, %eax
negl %eax
movq %r15, %rbx
movl %r13d, %ecx
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
ja 0x1581f
movq 0x10(%rsp), %rdi
callq 0x2060
movq 0x60(%rsp), %rbx
movq 0x18(%rsp), %r14
movq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0x2060
movq %r14, %rdi
callq 0x2060
movq %rbx, %rdi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2060
movq 0x1066d(%rip), %rax     # 0x25ff0
movq %rdi, %rbx
movq (%rax), %rdi
leaq 0xb198(%rip), %rsi      # 0x20b28
leaq 0xb1b9(%rip), %rdx      # 0x20b50
xorl %eax, %eax
movq %r8, %r15
callq 0x2280
movq 0x18(%rsp), %r14
jmp 0x15953