// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: get_num_edges2existing_nodes_advance_by_broken_bub(ma_ug_t*, asg_t*, ma_hit_t_alloc*, ma_sub_t*, R_to_U*, unsigned char*, int, int, unsigned int, unsigned int*, unsigned char*, unsigned int)
inline uint32_t get_num_edges2existing_nodes_advance_by_broken_bub(ma_ug_t *ug, asg_t *g, 
ma_hit_t_alloc* sources, ma_sub_t *coverage_cut, R_to_U* ruIndex, uint8_t* expect_vis, 
int max_hang, int min_ovlp, uint32_t query, uint32_t* oLen, uint8_t* utg_vis, 
uint32_t ignore_trio_flag)
{
    (*oLen) = 0;
    uint32_t qn = query>>1, is_first = 1;;
    int32_t r;
    asg_arc_t t;
    ma_hit_t *h = NULL;
    ma_sub_t *sq = NULL;
    ma_sub_t *st = NULL;
    ma_hit_t_alloc* x = &(sources[qn]);
    uint32_t i, occ = 0, uId, is_Unitig;

    uint32_t trio_flag = R_INF.trio_flag[qn], non_trio_flag = (uint32_t)-1;
    if(ignore_trio_flag == 0)
    {
        if(trio_flag == FATHER) non_trio_flag = MOTHER;
        if(trio_flag == MOTHER) non_trio_flag = FATHER;
    }



    for (i = 0; i < x->length; i++)
    {
        h = &(x->buffer[i]);
        sq = &(coverage_cut[Get_qn(*h)]);
        st = &(coverage_cut[Get_tn(*h)]);
        ///sq has already been removed
        ///st must not be removed
        ///g-seq must not be removed
        if(st->del || g->seq[Get_tn(*h)].del) continue;
        if(R_INF.trio_flag[Get_tn(*h)] == non_trio_flag) continue;

        r = ma_hit2arc(h, sq->e - sq->s, st->e - st->s, max_hang, 
                                asm_opt.max_hang_rate, min_ovlp, &t);
        
        ///if it is a contained read, skip
        if(r < 0) continue;

        if((t.ul>>32) != query) continue;
        get_R_to_U(ruIndex, t.v>>1, &uId, &is_Unitig);
        if(uId == (uint32_t)-1 || is_Unitig == 0 || ug->g->seq[uId].del) continue;
        if(expect_vis[t.v>>1] == 0) continue;

        if(is_first && utg_vis) memset(utg_vis, 0, ug->g->n_seq);
        if(utg_vis == NULL || (utg_vis && utg_vis[uId] == 0)) occ++;
        ////fprintf(stderr, "found-utg%.6ul, occ: %u\n", uId+1, occ);
        if(utg_vis) utg_vis[uId] = 1;

        (*oLen) += t.ol;
        is_first = 0;
    }

    return occ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r15
movq %rsi, %r13
movq 0xb8(%rsp), %rcx
movl 0xb0(%rsp), %eax
movl $0x0, (%rcx)
movl %eax, %esi
shrl %esi
leaq (%rsi,%rsi,2), %rcx
leaq 0x18f34e(%rip), %r10    # 0x296230
movq 0x28(%r10), %r10
movb (%r10,%rsi), %sil
xorl %r10d, %r10d
cmpb $0x1, %sil
sete %r10b
leal (%r10,%r10,2), %r10d
decl %r10d
cmpb $0x2, %sil
movl $0x1, %esi
cmovel %esi, %r10d
movl %r10d, 0x34(%rsp)
movl 0xc(%rdx,%rcx,8), %r10d
testl %r10d, %r10d
je 0x107292
movl $0x1, 0x28(%rsp)
movq %rdi, 0x50(%rsp)
movq %r8, 0x58(%rsp)
movq %r9, 0x48(%rsp)
movl 0xc8(%rsp), %r8d
leaq (%rdx,%rcx,8), %r12
movl %eax, %eax
movq %rax, 0x60(%rsp)
movq $0x0, 0x38(%rsp)
movl $0x18, %ebx
xorl %r14d, %r14d
movl $0x0, 0x1c(%rsp)
movq %r12, 0x10(%rsp)
movq %r13, 0x20(%rsp)
movq %r15, 0x40(%rsp)
movq (%r12), %r11
movl -0xc(%r11,%rbx), %edx
leaq (%rdx,%rdx,2), %rcx
movl (%r15,%rcx,4), %eax
testl %eax, %eax
js 0x1070e3
movq 0x20(%r13), %rsi
cmpl $0x0, (%rsi,%rdx,8)
js 0x1070e3
movq -0x18(%r11,%rbx), %rdi
testl %r8d, %r8d
jne 0x106fb8
leaq 0x18f28a(%rip), %rsi    # 0x296230
movq 0x28(%rsi), %rsi
movzbl (%rsi,%rdx), %esi
cmpl %esi, 0x34(%rsp)
je 0x1070e3
movl %r10d, 0xc(%rsp)
leaq (%r15,%rcx,4), %rcx
movl 0x4(%rcx), %r8d
subl %eax, %r8d
testb $-0x80, 0x3(%r11,%rbx)
jne 0x106fe8
movq %r13, %rbp
movl -0x8(%r11,%rbx), %eax
movl -0x4(%r11,%rbx), %r10d
subl %r10d, %r8d
movl %r8d, %r9d
movl %eax, %r8d
jmp 0x106ffb
movq %r13, %rbp
movl -0x8(%r11,%rbx), %eax
movl -0x4(%r11,%rbx), %r10d
subl %r10d, %r8d
movl %eax, %r9d
movq %rdi, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%r15,%rcx,4), %rcx
movl 0x4(%rcx), %r13d
movl (%rcx), %ecx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl %esi, %ecx
subl %ecx, %r13d
cmpl %edi, %r8d
movl %edi, %esi
cmovll %r8d, %esi
movl -0x10(%r11,%rbx), %r11d
movl %r13d, 0x30(%rsp)
subl %r11d, %r13d
cmpl %r9d, %r13d
movl %r9d, %ecx
cmovll %r13d, %ecx
movl 0xa0(%rsp), %r12d
cmpl %r12d, %esi
jg 0x107094
cmpl %r12d, %ecx
jg 0x107094
movl %r11d, %r12d
subl %edi, %r12d
cvtsi2ss %r12, %xmm1
addl %esi, %r12d
addl %ecx, %r12d
cvtsi2ss %r12, %xmm2
leaq 0x18e6ef(%rip), %r15    # 0x295758
movss 0x158(%r15), %xmm0
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
jbe 0x1070a6
movq 0x20(%rsp), %r13
movl 0xc8(%rsp), %r8d
movq 0x10(%rsp), %r12
movq 0x40(%rsp), %r15
jmp 0x1070de
movl 0xc8(%rsp), %r8d
movq 0x10(%rsp), %r12
movq %rbp, %r13
jmp 0x1070de
subl %eax, %r10d
xorps %xmm1, %xmm1
cvtsi2ss %r10, %xmm1
addl %esi, %ecx
addl %r10d, %ecx
xorps %xmm2, %xmm2
cvtsi2ss %rcx, %xmm2
mulss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
movq 0x40(%rsp), %r15
jbe 0x1070fb
movq 0x20(%rsp), %r13
movl 0xc8(%rsp), %r8d
movq 0x10(%rsp), %r12
movl 0xc(%rsp), %r10d
incq %r14
movl %r10d, %eax
addq $0x28, %rbx
cmpq %rax, %r14
jb 0x106f6e
jmp 0x10729a
cmpl %r9d, %r13d
setl %al
setg %r10b
cmpl %r8d, %edi
setg %r13b
setl %sil
orb %r10b, %r13b
cmpb $0x1, %r13b
jne 0x1070cc
orb %al, %sil
movl 0xc(%rsp), %r10d
je 0x10721b
movl 0xa8(%rsp), %eax
cmpl %eax, %r12d
jl 0x10721b
cmpl %eax, %ecx
movq 0x20(%rsp), %r13
movq 0x10(%rsp), %r12
jl 0x107271
addl %r11d, %r9d
movl 0x30(%rsp), %ebp
movl %ebp, %esi
subl %r9d, %esi
xorl %eax, %eax
movl %edi, %r9d
subl %r8d, %r9d
setle %cl
cmovlel %esi, %r9d
testl %r9d, %r9d
js 0x107271
movb %cl, %al
shrq $0x1f, %rdi
andl $-0x2, %edi
orq %rax, %rdi
cmpl 0x60(%rsp), %edi
jne 0x107271
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq 0x58(%rsp), %rax
cmpq %rdx, (%rax)
jbe 0x107271
movq 0x8(%rax), %rax
movl (%rax,%rdx,4), %esi
cmpl $-0x2, %esi
jg 0x107271
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq 0x50(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rcx
cmpl $0x0, (%rcx,%rsi,8)
js 0x107271
movq 0x48(%rsp), %rcx
cmpb $0x0, (%rcx,%rdx)
je 0x107271
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
sete %cl
cmpl $0x0, 0x28(%rsp)
sete %dl
orb %cl, %dl
jne 0x107232
movl 0x14(%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %rsi, 0x28(%rsp)
xorl %esi, %esi
movl %r9d, 0xc(%rsp)
callq 0x20e0
movq 0x28(%rsp), %rsi
movl 0xc(%rsp), %r9d
movq 0xc0(%rsp), %rdi
jmp 0x107237
movq 0x20(%rsp), %r13
movl 0xc8(%rsp), %r8d
movq 0x10(%rsp), %r12
jmp 0x1070e3
testq %rdi, %rdi
je 0x10727e
xorl %eax, %eax
cmpb $0x0, (%rdi,%rsi)
sete %al
movb $0x1, (%rdi,%rsi)
movq 0xb8(%rsp), %rcx
movl (%rcx), %edx
subl %r9d, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
addl %ebp, %edx
addl %eax, 0x1c(%rsp)
movq %rdx, 0x38(%rsp)
movl %edx, (%rcx)
movl 0xc(%r12), %r10d
movl $0x0, 0x28(%rsp)
movl 0xc8(%rsp), %r8d
jmp 0x1070e3
movl $0x1, %eax
movq 0xb8(%rsp), %rcx
movq 0x38(%rsp), %rdx
jmp 0x10724e
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq