// File: /workspace/github_c_makefile_star2_O1/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, 0x48(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, 0x40(%rsp)
movl 0x8(%rcx), %ebx
movl %ebx, %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
je 0xa4fe
movl %r9d, %r12d
movq %rcx, %r13
movq %rdi, %r14
movq %rax, 0x8(%rsp)
movq (%rcx), %rdi
testq %rdi, %rdi
je 0xa24e
callq 0x3480
movq %rax, 0x10(%rsp)
jmp 0xa28b
movl %r8d, %ebp
movl $0xc, %edi
callq 0x32f0
movq %rax, %rdi
xorl %eax, %eax
btl $0x1e, %ebx
setae %al
testl %r12d, %r12d
leal 0x63(%rax,%rax,8), %eax
movl $0x6c, %ecx
cmovel %eax, %ecx
leaq 0xf743(%rip), %rsi      # 0x199c0
movq %rdi, 0x10(%rsp)
movl %ebp, %edx
xorl %eax, %eax
callq 0x3420
movq 0x20(%r14), %rax
cmpq %rax, 0x18(%r14)
jne 0xa2e3
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, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x20(%r14)
movq 0x28(%r14), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x3330
movq %rax, 0x28(%r14)
movl 0x90(%rsp), %ebx
movq 0x18(%r14), %rax
movq 0x28(%r14), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x18(%r14)
movq 0x10(%rsp), %rdx
movq %rdx, (%rcx,%rax,8)
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x10(%r13), %rcx
movl (%rcx), %eax
xorl %ebp, %ebp
testl %r12d, %r12d
movq %r14, 0x38(%rsp)
jne 0xa368
testb $0x40, 0xb(%r13)
je 0xa368
movq 0x8(%rsp), %rdx
movl -0x4(%rcx,%rdx,4), %ecx
movq 0x28(%rsp), %rsi
movq 0x28(%rsi), %rdx
movq 0x30(%rsi), %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 0xa35f
testb $0x40, 0x3(%rcx)
je 0xa365
addq $0x30, %rcx
jmp 0xa353
movl -0x8(%rcx), %ebp
movq 0x18(%rsp), %r15
movq 0x10(%r15), %rdx
movl %eax, %ecx
shrl %ecx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %r14
movq (%rdx,%r14), %rcx
movl 0x10(%rdx,%r14), %r8d
andl $0x1, %eax
subq $0x8, %rsp
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %ebp, %r9d
movsd 0x50(%rsp), %xmm0
movl 0xa0(%rsp), %r10d
pushq %r10
pushq $0x0
pushq %rax
callq 0x16940
addq $0x20, %rsp
movq 0x10(%r15), %rax
movl 0x10(%rax,%r14), %eax
subl %ebp, %eax
xorl %r15d, %r15d
movslq %ebx, %rcx
movq %rcx, 0x30(%rsp)
movq 0x8(%rsp), %rcx
cmpl $0x1, %ecx
je 0xa4dc
movl %r12d, 0x24(%rsp)
cmpl $0x3, %ecx
movl $0x2, %edx
cmovael %ecx, %edx
movq %rdx, 0x8(%rsp)
movl $0x1, %r12d
movq %r13, 0x50(%rsp)
movq 0x18(%rsp), %rbp
movq 0x10(%r13), %rcx
movl -0x4(%rcx,%r12,4), %edx
movl (%rcx,%r12,4), %r10d
movq 0x28(%rsp), %rsi
movq 0x28(%rsi), %rcx
movq 0x30(%rsi), %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 0xa43e
testb $0x40, 0x3(%rbx)
je 0xa444
addq $0x30, %rbx
jmp 0xa432
xorl %edx, %edx
testq %rcx, %rcx
movl $0x0, %r14d
cmoveq 0x30(%rsp), %r14
sete %dl
addl %edx, %r15d
addq %rax, %r14
movq 0x10(%rbp), %rax
movl %r10d, %ecx
shrl %ecx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %r13
movq (%rax,%r13), %rcx
movl 0x10(%rax,%r13), %r8d
movl -0x8(%rbx), %r9d
andl $0x1, %r10d
subq $0x8, %rsp
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x18(%rsp), %rdx
movsd 0x50(%rsp), %xmm0
movl 0xa0(%rsp), %eax
pushq %rax
pushq %r14
pushq %r10
callq 0x16940
addq $0x20, %rsp
movq 0x10(%rbp), %rax
movl 0x10(%rax,%r13), %ecx
movq 0x50(%rsp), %r13
subq -0x8(%rbx), %r14
movq %r14, %rax
addq %rcx, %rax
incq %r12
cmpq 0x8(%rsp), %r12
jne 0xa404
movl %r15d, %r15d
movl 0x24(%rsp), %r12d
testl %r12d, %r12d
je 0xa4ec
movl $0x40000000, %ecx       # imm = 0x40000000
andl 0x8(%r13), %ecx
jne 0xa4fe
imulq 0x30(%rsp), %r15
subq %r15, %rax
movl 0x18(%r13), %ecx
cmpq %rcx, %rax
jne 0xa50d
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf47f(%rip), %rdi      # 0x19993
leaq 0xf15a(%rip), %rsi      # 0x19675
leaq 0xf4a8(%rip), %rcx      # 0x199ca
movl $0x791, %edx            # imm = 0x791
callq 0x3190