// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: update_ma_hit_t_norm(void*, long, int)
static void update_ma_hit_t_norm(void *data, long i, int tid) // callback for kt_for()
{
	ma_hit_t_aux *sl = (ma_hit_t_aux *)data;
	ma_hit_t_alloc* src = sl->src;
	uint64_t z, qn, tn, is_del = 0; 
    int64_t idx, qLen_0, qLen_1;

    for (z = 0; z < src[i].length; z++) {
        qn = Get_qn(src[i].buffer[z]);
        tn = Get_tn(src[i].buffer[z]);
        is_del = 0; idx = get_specific_overlap(&(src[tn]), tn, qn);

        if(idx != -1 && qn <= tn) { ///qn must be not equal to tn
            if(src[i].buffer[z].del || src[tn].buffer[idx].del) is_del = 1;
            qLen_0 = Get_qe(src[i].buffer[z]) - Get_qs(src[i].buffer[z]);
            qLen_1 = Get_qe(src[tn].buffer[idx]) - Get_qs(src[tn].buffer[idx]);

            if(qLen_0 == qLen_1) {
                ///qn must be not equal to tn
                ///make sources[qn] = sources[tn] if qn > tn
                set_reverse_overlap(&(src[tn].buffer[idx]), &(src[i].buffer[z]));
            }
            else if(qLen_0 > qLen_1) {
                set_reverse_overlap(&(src[tn].buffer[idx]), &(src[i].buffer[z]));
            } else {
                set_reverse_overlap(&(src[i].buffer[z]), &(src[tn].buffer[idx]));
            }
            
            src[i].buffer[z].del = is_del; src[tn].buffer[idx].del = is_del;
        }
        else ///means this edge just occurs in one direction
        {
            tn = i; tn <<= 32; tn |= z;
            kv_push(uint64_t, sl->buf[tid].a, tn);
            src[i].buffer[z].del = 1;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0x8(%rdi), %r12
movq %rsi, (%rsp)
leaq (%rsi,%rsi,2), %rax
cmpl $0x0, 0xc(%r12,%rax,8)
je 0xa0c78
movq %rdi, %r14
leaq (%r12,%rax,8), %r11
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
shlq $0x20, (%rsp)
movslq %edx, %rbp
xorl %r13d, %r13d
shlq $0x5, %rbp
incq %rax
movq %rax, 0x10(%rsp)
movq %r11, 0x8(%rsp)
movq %rdi, 0x20(%rsp)
movq %r12, 0x18(%rsp)
movq (%r11), %rcx
leaq (,%r13,4), %rbx
addq %r13, %rbx
movq (%rcx,%rbx,8), %rax
movq %rax, %rdx
shrq $0x20, %rdx
movl 0xc(%rcx,%rbx,8), %esi
leaq (%rsi,%rsi,2), %rdi
leaq (%r12,%rdi,8), %r15
movl 0xc(%r15), %r8d
movq $-0x1, %rdi
testq %r8, %r8
je 0xa0b55
movq (%r15), %r9
xorl %r10d, %r10d
cmpl %edx, 0xc(%r9)
jne 0xa0b44
cmpl 0x4(%r9), %esi
je 0xa0b52
incq %r10
addq $0x28, %r9
cmpq %r10, %r8
jne 0xa0b38
jmp 0xa0b55
movq %r10, %rdi
cmpq $-0x1, %rdi
sete %r8b
cmpl %esi, %edx
seta %dl
orb %r8b, %dl
je 0xa0bdd
movq (%r14), %rax
movq 0x8(%rax,%rbp), %rcx
cmpq %rcx, (%rax,%rbp)
jne 0xa0bac
leaq (%rax,%rbp), %rdx
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rax,%rbp)
movq 0x8(%rdx), %rsi
movq 0x10(%rdx), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x8(%rsp), %r11
movq (%r14), %rcx
movq %rax, 0x10(%rcx,%rbp)
movq %r13, %rax
orq (%rsp), %rax
movq (%r14), %rcx
movq (%rcx,%rbp), %rdx
movq 0x10(%rcx,%rbp), %rsi
leaq 0x1(%rdx), %rdi
movq %rdi, (%rcx,%rbp)
movq %rax, (%rsi,%rdx,8)
movq (%r11), %rax
movq 0x10(%rsp), %rcx
orq %rcx, 0x18(%rax,%rbx,8)
jmp 0xa0c68
cmpq $0x0, 0x18(%rcx,%rbx,8)
leaq (%rdi,%rdi,4), %r14
js 0xa0bf9
movq (%r15), %rdx
cmpq $0x0, 0x18(%rdx,%r14,8)
js 0xa0bf9
xorl %r12d, %r12d
jmp 0xa0bfe
movq 0x10(%rsp), %r12
leaq (%rcx,%rbx,8), %rsi
movl 0x8(%rsi), %ecx
subl %eax, %ecx
movq (%r15), %rax
leaq (%rax,%r14,8), %rax
movl 0x8(%rax), %edx
subl (%rax), %edx
cmpl %edx, %ecx
je 0xa0c19
jbe 0xa0c1e
movq %rax, %rdi
jmp 0xa0c24
movq %rsi, %rdi
movq %rax, %rsi
callq 0xa052a
movq 0x8(%rsp), %r11
movq (%r11), %rax
movq 0x18(%rax,%rbx,8), %rcx
movabsq $0x7fffffffffffffff, %rdx # imm = 0x7FFFFFFFFFFFFFFF
andq %rdx, %rcx
orq %r12, %rcx
movq %rcx, 0x18(%rax,%rbx,8)
movq (%r15), %rax
movq 0x18(%rax,%r14,8), %rcx
andq %rdx, %rcx
orq %r12, %rcx
movq %rcx, 0x18(%rax,%r14,8)
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r12
incq %r13
movl 0xc(%r11), %eax
cmpq %rax, %r13
jb 0xa0afd
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq