// File: 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
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x30(%rbp), %rax
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x4(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, 0x30(%rbp)
je 0xf274d
movq 0x10(%rbp), %rax
movl -0x4(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xf274d
movq 0x10(%rbp), %rax
movl -0x4(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0xf274d
movq 0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
addq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq -0x10(%rbp), %rdx
movq 0x20(%rbp), %rcx
movl 0x28(%rbp), %r8d
callq 0xf2510
cmpl $0x0, %eax
je 0xf2748
movq 0x10(%rbp), %rax
movl -0x4(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %edx
orl $0x2, %edx
movb %dl, (%rax,%rcx)
jmp 0xf29ea
movq -0x28(%rbp), %rax
movl -0x4(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x68(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0xf29ea
movq -0x68(%rbp), %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x38(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0xf27f4
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %esi
leaq -0x38(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
callq 0xd3d50
cmpl $-0x1, -0x38(%rbp)
je 0xf27ed
cmpl $0x1, -0x3c(%rbp)
je 0xf27ed
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x38(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0xf27f2
jmp 0xf29dc
jmp 0xf27f4
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x38(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0xf280f
jmp 0xf29dc
movq 0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0xf2827
jmp 0xf29dc
movq -0x70(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x38(%rbp)
movq 0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xf2849
jmp 0xf29dc
movq -0x70(%rbp), %rax
movq (%rax), %rax
movl %eax, %eax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
movl %eax, %eax
movq %rax, -0x80(%rbp)
movq -0x70(%rbp), %rax
movl 0x10(%rax), %eax
movq %rax, -0x88(%rbp)
movq -0x70(%rbp), %rax
movl 0x14(%rax), %eax
subl $0x1, %eax
movl %eax, %eax
movq %rax, -0x90(%rbp)
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x1f, %rax
andq $0x1, %rax
cmpl $0x0, %eax
je 0xf28e8
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x38(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq -0x70(%rbp), %rcx
movl 0x14(%rcx), %ecx
subq $0x1, %rcx
subq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x38(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq -0x70(%rbp), %rcx
movl 0x10(%rcx), %ecx
subq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x90(%rbp)
movq -0x78(%rbp), %rax
subq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl -0x38(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
subq -0x90(%rbp), %rcx
subq $0x1, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x4(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xf29a3
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x4(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
subq -0x88(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x4(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
subq -0x90(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x60(%rbp)
movq 0x18(%rbp), %rdi
movq -0x58(%rbp), %rsi
addq -0x10(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq -0x10(%rbp), %rdx
movq 0x20(%rbp), %rcx
movl 0x28(%rbp), %r8d
callq 0xf2510
cmpl $0x0, %eax
je 0xf29da
movq 0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
movzbl (%rax,%rcx), %edx
orl $0x2, %edx
movb %dl, (%rax,%rcx)
jmp 0xf29dc
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xf2772
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)