// File: /workspace/github_c_makefile_star2_O2/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 $0x58, %rsp
movsd %xmm0, 0x40(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, 0x38(%rsp)
movl 0x8(%rcx), %r14d
movl %r14d, %r15d
andl $0x3fffffff, %r15d      # imm = 0x3FFFFFFF
je 0x8f81
movl %r9d, %r13d
movq %rcx, %r12
movq %rdi, (%rsp)
movq (%rcx), %rdi
testq %rdi, %rdi
je 0x8d1a
callq 0x3480
movq %rax, 0x8(%rsp)
jmp 0x8d54
movl %r8d, %ebx
pushq $0xc
popq %rdi
callq 0x32f0
movq %rax, %rdi
xorl %eax, %eax
btl $0x1e, %r14d
setae %al
testl %r13d, %r13d
leal 0x63(%rax,%rax,8), %eax
pushq $0x6c
popq %rcx
cmovel %eax, %ecx
leaq 0xdc9a(%rip), %rsi      # 0x169e0
movq %rdi, 0x8(%rsp)
movl %ebx, %edx
xorl %eax, %eax
callq 0x3420
movq (%rsp), %rdi
movq 0x18(%rdi), %rcx
cmpq 0x20(%rdi), %rcx
jne 0x8dbe
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(%rdi)
movq (%rsp), %rcx
movq 0x28(%rcx), %rdi
leaq 0x8(,%rax,8), %rsi
callq 0x3330
movq (%rsp), %rdi
movq %rax, 0x28(%rdi)
movq 0x18(%rdi), %rcx
jmp 0x8dc2
movq 0x28(%rdi), %rax
movl 0x90(%rsp), %ebp
leaq 0x1(%rcx), %rdx
movq %rdx, 0x18(%rdi)
movq 0x8(%rsp), %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x10(%r12), %rax
movl (%rax), %r10d
movq $0x0, 0x18(%rsp)
movl $0x0, %ebx
movl %r13d, 0x24(%rsp)
testl %r13d, %r13d
jne 0x8e2f
testb $0x40, 0xb(%r12)
je 0x8e2f
movl -0x4(%rax,%r15,4), %esi
movq 0x28(%rsp), %rdi
movq %r10, %rdx
movq %r10, %rbx
callq 0x703e
movq %rbx, %r10
movq (%rsp), %rdi
movl 0x18(%rax), %ebx
movq 0x10(%rsp), %r13
movq 0x10(%r13), %rax
movl %r10d, %ecx
shrl %ecx
imulq $0x18, %rcx, %r14
movq (%rax,%r14), %rcx
movl 0x10(%rax,%r14), %r8d
andl $0x1, %r10d
subq $0x8, %rsp
movq 0x40(%rsp), %rsi
movq 0x10(%rsp), %rdx
movl %ebx, %r9d
movsd 0x48(%rsp), %xmm0
movl 0xa0(%rsp), %eax
pushq %rax
pushq $0x0
pushq %r10
callq 0x13d83
addq $0x20, %rsp
movq 0x10(%r13), %r13
movl 0x10(%r13,%r14), %r14d
subl %ebx, %r14d
movslq %ebp, %rax
movq %rax, 0x30(%rsp)
movl %r15d, %eax
movq %rax, 0x50(%rsp)
pushq $0x1
popq %rbp
movq %r12, 0x48(%rsp)
cmpq 0x50(%rsp), %rbp
jae 0x8f57
movq 0x10(%r12), %rax
movl -0x4(%rax,%rbp,4), %esi
movl (%rax,%rbp,4), %r15d
movq 0x28(%rsp), %rdi
movq %r15, %rdx
callq 0x703e
movq %rax, %rbx
xorl %eax, %eax
testq %rbx, %rbx
sete %al
movl $0x0, %r12d
cmoveq 0x30(%rsp), %r12
movq 0x18(%rsp), %rcx
addl %eax, %ecx
movq %rcx, 0x18(%rsp)
addq %r14, %r12
movl %r15d, %eax
shrl %eax
imulq $0x18, %rax, %r14
movq (%r13,%r14), %rcx
movl 0x10(%r13,%r14), %r8d
movl 0x18(%rbx), %r9d
andl $0x1, %r15d
subq $0x8, %rsp
movq 0x8(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x10(%rsp), %rdx
movsd 0x48(%rsp), %xmm0
movl 0xa0(%rsp), %eax
pushq %rax
pushq %r12
pushq %r15
callq 0x13d83
addq $0x20, %rsp
movq 0x10(%rsp), %rax
movq 0x10(%rax), %r13
subq 0x18(%rbx), %r12
movl 0x10(%r13,%r14), %eax
addq %rax, %r12
incq %rbp
movq %r12, %r14
movq 0x48(%rsp), %r12
jmp 0x8e9e
cmpl $0x0, 0x24(%rsp)
je 0x8f6a
movl $0x40000000, %eax       # imm = 0x40000000
andl 0x8(%r12), %eax
jne 0x8f81
movl 0x18(%rsp), %eax
imulq 0x30(%rsp), %rax
subq %rax, %r14
movl 0x18(%r12), %eax
cmpq %rax, %r14
jne 0x8f90
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xda1c(%rip), %rdi      # 0x169b3
leaq 0xd6f7(%rip), %rsi      # 0x16695
leaq 0xda45(%rip), %rcx      # 0x169ea
movl $0x791, %edx            # imm = 0x791
callq 0x3190