// File: /workspace/github_c_makefile_star2_O3/c-zhou[P]oatk/path.c
// Function: path_add_hmm_annot_bed6
void path_add_hmm_annot_bed6(hmm_annot_bed6_db_t *bed_annots, hmm_annot_db_t *annot_db, asg_t *asg, path_t *path, 
        int id, int force_linear, int gap_size, OG_TYPE_t og_type, double max_evalue)
{
    uint32_t i, n, v, lo, n_gap;
    uint64_t l;
    asmg_t *g;
    asmg_arc_t *a;
    char *cname;
    
    n = path->nv;
    if (n == 0) return;

    cname = 0;
    if (path->sid) {
        cname = strdup(path->sid);
    } else {
        MYMALLOC(cname, 12);
        sprintf(cname, "ctg%06d%c", id, (force_linear || !path->circ)? 'l' : 'c');
    }
    
    if (bed_annots->n_seg == bed_annots->m_seg) {
        ++bed_annots->m_seg;
        kroundup32(bed_annots->m_seg);
        MYREALLOC(bed_annots->snames, bed_annots->m_seg);
    }
    bed_annots->snames[bed_annots->n_seg++] = cname;

    g = asg->asmg;
    l = 0;
    v = path->v[0];
    lo = (force_linear || !path->circ)? 0 : asmg_arc1(g, path->v[n-1], v)->ls;
    hmm_annot_bed6_sname_add(bed_annots, annot_db, cname, asg->seg[v>>1].name, asg->seg[v>>1].len, lo, v&1, l, og_type, max_evalue);
    l += asg->seg[v>>1].len - lo;

    n_gap = 0;
    for (i = 1; i < n; ++i) {
        v = path->v[i];
        a = asmg_arc1(g, path->v[i-1], v);
        if (!a) l += gap_size, ++n_gap;
        hmm_annot_bed6_sname_add(bed_annots, annot_db, cname, asg->seg[v>>1].name, asg->seg[v>>1].len, a->ls, v&1, l, og_type, max_evalue);
        l += asg->seg[v>>1].len - a->ls;
    }

    if (!path->circ || !force_linear)
        assert(l - (uint64_t) n_gap * gap_size == path->len);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movsd %xmm0, 0x28(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, 0x20(%rsp)
movl 0x8(%rcx), %ebx
movl %ebx, %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
je 0xa9cd
movl %r9d, %r14d
movq %rcx, %r12
movq %rdi, %r15
movq %rax, (%rsp)
movq (%rcx), %rdi
testq %rdi, %rdi
je 0xa76b
callq 0x3480
movq %rax, 0x8(%rsp)
jmp 0xa7a8
movl %r8d, %ebp
movl $0xc, %edi
callq 0x32f0
movq %rax, %rdi
xorl %eax, %eax
btl $0x1e, %ebx
setae %al
testl %r14d, %r14d
leal 0x63(%rax,%rax,8), %eax
movl $0x6c, %ecx
cmovel %eax, %ecx
leaq 0x10236(%rip), %rsi     # 0x1a9d0
movq %rdi, 0x8(%rsp)
movl %ebp, %edx
xorl %eax, %eax
callq 0x3420
movq 0x18(%r15), %rcx
cmpq 0x20(%r15), %rcx
jne 0xa806
movq %rcx, %rax
shrq %rax
orq %rcx, %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, %rax
shrq $0x10, %rax
orq %rcx, %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x20(%r15)
movq 0x28(%r15), %rdi
leaq 0x8(,%rax,8), %rsi
callq 0x3330
movq %rax, 0x28(%r15)
movq 0x18(%r15), %rcx
jmp 0xa80a
movq 0x28(%r15), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x18(%r15)
movq 0x8(%rsp), %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rbp
movq 0x10(%r12), %rcx
movl (%rcx), %eax
xorl %r13d, %r13d
testl %r14d, %r14d
jne 0xa874
testb $0x40, 0xb(%r12)
je 0xa874
movq (%rsp), %rdx
movl -0x4(%rcx,%rdx,4), %ecx
movq 0x28(%rbp), %rdx
movq 0x30(%rbp), %rsi
movq (%rsi,%rcx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
addq %rdx, %rcx
addq $0x20, %rcx
cmpq %rax, -0x18(%rcx)
jne 0xa86a
testb $0x40, 0x3(%rcx)
je 0xa870
addq $0x30, %rcx
jmp 0xa85e
movl -0x8(%rcx), %r13d
movl %r14d, 0x1c(%rsp)
movq 0x10(%rsp), %r14
movq 0x10(%r14), %rdx
movl %eax, %ecx
shrl %ecx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rbx
movq (%rdx,%rbx), %rcx
movl 0x10(%rdx,%rbx), %r8d
andl $0x1, %eax
subq $0x8, %rsp
movq %r15, %rdi
movq 0x28(%rsp), %rsi
movq 0x10(%rsp), %rdx
movl %r13d, %r9d
movsd 0x30(%rsp), %xmm0
movl 0x80(%rsp), %r10d
pushq %r10
pushq $0x0
pushq %rax
callq 0x18247
addq $0x20, %rsp
movq 0x10(%r14), %rax
movq %r15, %rdx
movl 0x10(%rax,%rbx), %r15d
subl %r13d, %r15d
movq (%rsp), %rcx
cmpl $0x1, %ecx
je 0xa9b0
movq %rdx, 0x30(%rsp)
cmpl $0x3, %ecx
movl $0x2, %edx
cmovael %ecx, %edx
movq %rdx, (%rsp)
movl $0x1, %r13d
movq 0x10(%r12), %rcx
movl -0x4(%rcx,%r13,4), %edx
movl (%rcx,%r13,4), %r10d
movq 0x28(%rbp), %rcx
movq 0x30(%rbp), %rsi
movq (%rsi,%rdx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rbx
addq $0x20, %rbx
cmpq %r10, -0x18(%rbx)
jne 0xa936
testb $0x40, 0x3(%rbx)
je 0xa93c
addq $0x30, %rbx
jmp 0xa92a
movl %r10d, %ecx
shrl %ecx
shlq $0x3, %rcx
movq %r12, %r14
leaq (%rcx,%rcx,2), %r12
movq (%rax,%r12), %rcx
movl 0x10(%rax,%r12), %r8d
movl -0x8(%rbx), %r9d
andl $0x1, %r10d
subq $0x8, %rsp
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x10(%rsp), %rdx
movsd 0x30(%rsp), %xmm0
movl 0x80(%rsp), %eax
pushq %rax
pushq %r15
pushq %r10
callq 0x18247
addq $0x20, %rsp
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
subq -0x8(%rbx), %r15
movl 0x10(%rax,%r12), %ecx
movq %r14, %r12
addq %rcx, %r15
incq %r13
cmpq (%rsp), %r13
jne 0xa900
cmpl $0x0, 0x1c(%rsp)
je 0xa9c3
movl $0x40000000, %eax       # imm = 0x40000000
andl 0x8(%r12), %eax
jne 0xa9cd
movl 0x18(%r12), %eax
cmpq %rax, %r15
jne 0xa9dc
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xffc0(%rip), %rdi      # 0x1a9a3
leaq 0xfc9b(%rip), %rsi      # 0x1a685
leaq 0xffe9(%rip), %rcx      # 0x1a9da
movl $0x791, %edx            # imm = 0x791
callq 0x3190