// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/hmmannot.c
// Function: hmm_annot_bed6_sname_add
void hmm_annot_bed6_sname_add(hmm_annot_bed6_db_t *annots, hmm_annot_db_t *annot_db, char *cname, 
        char *sname, uint32_t len, uint32_t beg, int rev, uint32_t offset, OG_TYPE_t og_type, double max_evalue)
{
    uint32_t i, n_annot, alifrom, alito, alilen, strand;
    int score;
    hmm_annot_t *annot;
    hmm_annot_db_sort(annot_db, ORDER_SID_CO);
    annot = hmm_annot_db_sname_query(annot_db, sname, &n_annot);
    for (i = 0; i < n_annot; ++i) {
        if (annot[i].og_type != (uint32_t) og_type ||
                annot[i].evalue > max_evalue) continue;
        alifrom = annot[i].alifrom;
        alito = annot[i].alito;
        if (alifrom > alito) continue; // this should never happend unless nhmmer bug
        alilen = alito - alifrom;
        strand = annot[i].strand;
        score = lround(annot[i].score);
        score = MIN(score, MAX_BED_SCORE);
        if (rev) {
            SWAP(alifrom, alito);
            alifrom = len - alifrom;
            alito = len - alito;
            strand = !strand;
        }
        alifrom = MAX(alifrom, beg);
        alito = MAX(alito, beg);
        alifrom -= beg;
        alito -= beg;
        // for annotation clipped at the ends
        // keep it only when at least [half] the sequence retained
        if ((alito - alifrom) < (double) alilen * .5)
            continue; 
        alifrom += offset;
        alito += offset;
            
        hmm_annot_bed6_t bed6 = {cname, annot[i].gname, strand? '-' : '+', alifrom, alito, score};
        kv_push(hmm_annot_bed6_t, *annots, bed6);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl $0x6, %esi
callq 0x5130
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x5770
movq %rax, -0x58(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x5e9c
movq -0x58(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl 0x48(%rax), %eax
shrl $0x1d, %eax
andl $0x3, %eax
cmpl 0x20(%rbp), %eax
jne 0x5c1d
movq -0x58(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movsd 0x30(%rax), %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x5c22
jmp 0x5e8e
movq -0x58(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x58(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jbe 0x5c57
jmp 0x5e8e
movl -0x40(%rbp), %eax
subl -0x3c(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x58(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl 0x48(%rax), %eax
shrl $0x1f, %eax
movl %eax, -0x48(%rbp)
movq -0x58(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movsd 0x38(%rax), %xmm0
callq 0x20e0
movl %eax, -0x4c(%rbp)
cmpl $0x3e8, -0x4c(%rbp)     # imm = 0x3E8
jge 0x5ca6
movl -0x4c(%rbp), %eax
movl %eax, -0x84(%rbp)
jmp 0x5cb3
movl $0x3e8, %eax            # imm = 0x3E8
movl %eax, -0x84(%rbp)
jmp 0x5cb3
movl -0x84(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, 0x10(%rbp)
je 0x5cf9
jmp 0x5cc4
movl -0x3c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x24(%rbp), %eax
subl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x24(%rbp), %eax
subl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x48(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x48(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jbe 0x5d0c
movl -0x3c(%rbp), %eax
movl %eax, -0x88(%rbp)
jmp 0x5d15
movl -0x28(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x28(%rbp), %eax
jbe 0x5d31
movl -0x40(%rbp), %eax
movl %eax, -0x8c(%rbp)
jmp 0x5d3a
movl -0x28(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x28(%rbp), %ecx
movl -0x3c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x3c(%rbp)
movl -0x28(%rbp), %ecx
movl -0x40(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl -0x3c(%rbp), %ecx
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
movl -0x44(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0x3842(%rip), %xmm2     # 0x95b8
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x5d85
jmp 0x5e8e
movl 0x18(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl 0x18(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x58(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movl -0x48(%rbp), %edx
movl $0x2b, %eax
movl $0x2d, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, -0x70(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x5e4d
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x5e0c
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x98(%rbp)
jmp 0x5e1a
movl $0x2, %eax
movq %rax, -0x98(%rbp)
jmp 0x5e1a
movq -0x98(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x5, %rsi
callq 0x22c0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
shlq $0x5, %rcx
addq %rcx, %rax
movq -0x80(%rbp), %rcx
movq %rcx, (%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x70(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x18(%rax)
jmp 0x5e8e
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5bdb
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)