// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: get_break_point_cov_advance(unsigned int, long long, asg_t*, All_reads*, ma_hit_t_alloc*, R_to_U*, unsigned char*, kvec_t_u64_warp*, long long, unsigned int, unsigned int*)
void get_break_point_cov_advance(uint32_t v, long long c_beg, asg_t* read_g, All_reads *RNF, 
ma_hit_t_alloc* sources, R_to_U* ruIndex, uint8_t* r_flag, kvec_t_u64_warp* depth, long long utg_len, 
uint32_t is_circle, uint32_t* uID)
{
    uint32_t i, tn, is_Unitig;
    long long v_beg, v_end, w_beg, w_end;
    
    v_beg = 0; v_end = Get_READ_LENGTH((*RNF), (v>>1)) - 1;
    if(uID && (r_flag[v>>1]&1) && (!(r_flag[v>>1]&2)))
    {
        if(push_cov_interval_advance(depth, v_beg+c_beg, v_end+c_beg, utg_len, is_circle)) r_flag[v>>1] |= 2;
        return;    
    } 
    

    ma_hit_t_alloc* x = &(sources[v>>1]);
    ma_hit_t *h = NULL;
    long long qs, qe, ts, te;
    ///[v_beg, v_end] must be the end of read, which means v_beg = 0 or v_end = Get_READ_LENGTH((*RNF), (v>>1)) - 1
    for (i = 0; i < x->length; i++)
    {
        h = &(x->buffer[i]);
        tn = Get_tn((*h));
        if(read_g->seq[tn].del == 1)
        {
            ///get the id of read that contains it 
            get_R_to_U(ruIndex, tn, &tn, &is_Unitig);
            if(tn == (uint32_t)-1 || is_Unitig == 1 || read_g->seq[tn].del == 1) continue;
        }
        if(read_g->seq[tn].del == 1) continue;
        if(!(r_flag[tn]&1)) continue;
        tn = Get_tn((*h));///must!!!!
        
        if(r_flag[tn]&2) continue;

        qs = Get_qs((*h)); qe = Get_qe((*h)) - 1;
        ts = Get_ts((*h)); te = Get_te((*h)) - 1;
        if(h->rev)
        {
            ts = (long long)(Get_READ_LENGTH((*RNF), tn)) - ((long long)(Get_te((*h))) - 1) - 1;
            te = (long long)(Get_READ_LENGTH((*RNF), tn)) - (long long)(Get_ts((*h))) - 1;
        }
        ts = qs - ts;
        te = qe + ((long long)(Get_READ_LENGTH((*RNF), tn)) - te - 1);
        w_beg = ts; w_end = te;

        if(v&1)
        {
            ts = (long long)(Get_READ_LENGTH((*RNF), v>>1)) - ts - 1;
            te = (long long)(Get_READ_LENGTH((*RNF), v>>1)) - te - 1;
            w_beg = te; w_end = ts;
        }

        if(push_cov_interval_advance(depth, w_beg+c_beg, w_end+c_beg, utg_len, is_circle)) r_flag[tn] |= 2;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r12
movq %r8, %rbp
movq %rcx, 0x10(%rsp)
movq %rdx, %r15
movq %rsi, 0x18(%rsp)
movq 0x60(%rsp), %rsi
movl %edi, 0xc(%rsp)
movl %edi, %ecx
shrl %ecx
cmpq $0x0, 0x80(%rsp)
je 0x7e3f0
movb (%rsi,%rcx), %al
andb $0x3, %al
cmpb $0x1, %al
jne 0x7e3f0
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq %rcx, %rbx
movq (%rax,%rcx,8), %rax
movq 0x18(%rsp), %rsi
leaq -0x1(%rsi,%rax), %rdx
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rcx
movl 0x78(%rsp), %r8d
callq 0x7e29c
movq 0x60(%rsp), %rcx
testl %eax, %eax
je 0x7e3e1
orb $0x2, (%rcx,%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, 0x20(%rsp)
imulq $0x18, %rcx, %rax
addq %rax, %rbp
pushq $0x18
popq %rbx
xorl %r14d, %r14d
movl 0xc(%rbp), %eax
cmpq %rax, %r14
jae 0x7e3e1
movq (%rbp), %rax
movl -0xc(%rax,%rbx), %r13d
movq 0x20(%r15), %rcx
cmpl $0x0, (%rcx,%r13,8)
movq %r13, %rdx
js 0x7e456
testb $0x1, (%rsi,%rdx)
je 0x7e4f8
testb $0x2, (%rsi,%r13)
jne 0x7e4f8
movl -0x8(%rax,%rbx), %edi
movl -0x4(%rax,%rbx), %edx
testb $-0x80, 0x3(%rax,%rbx)
movq 0x10(%rsp), %rcx
movq 0x18(%rcx), %rcx
jne 0x7e47a
decl %edx
movq (%rcx,%r13,8), %r8
jmp 0x7e490
cmpq %r13, (%r12)
jbe 0x7e4f8
movq 0x8(%r12), %rdx
movslq (%rdx,%r13,4), %rdx
testq %rdx, %rdx
js 0x7e4f8
cmpl $0x0, (%rcx,%rdx,8)
jns 0x7e421
jmp 0x7e4f8
movq (%rcx,%r13,8), %r8
movq %r8, %rsi
subq %rdx, %rsi
notq %rdi
movq %rdi, %rdx
addq %r8, %rdx
movq %rsi, %rdi
movl -0x18(%rax,%rbx), %esi
movl -0x10(%rax,%rbx), %eax
subq %rdi, %rsi
decl %eax
addq %r8, %rax
notq %rdx
addq %rax, %rdx
testb $0x1, 0xc(%rsp)
je 0x7e4cb
movq 0x20(%rsp), %rax
movq (%rcx,%rax,8), %rax
notq %rsi
addq %rax, %rsi
notq %rdx
movq %rdx, %rcx
addq %rax, %rcx
movq %rsi, %rdx
movq %rcx, %rsi
movq 0x18(%rsp), %rax
addq %rax, %rsi
addq %rax, %rdx
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rcx
movl 0x78(%rsp), %r8d
callq 0x7e29c
testl %eax, %eax
movq 0x60(%rsp), %rsi
je 0x7e4f8
orb $0x2, (%rsi,%r13)
incq %r14
addq $0x28, %rbx
jmp 0x7e402