// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
movq %rdi, 0x20(%rsp)
movq 0x8(%rdi), %rcx
imulq $0x18, %rsi, %r8
movq %rcx, 0x30(%rsp)
addq %rcx, %r8
shlq $0x20, %rsi
movq %rsi, 0x28(%rsp)
movslq %edx, %r12
xorl %r14d, %r14d
shlq $0x5, %r12
incq %rax
movq %rax, 0x10(%rsp)
xorl %r9d, %r9d
movq %r8, (%rsp)
movq %r12, 0x18(%rsp)
movl 0xc(%r8), %eax
cmpq %rax, %r9
jae 0x69c66
movq %r9, 0x8(%rsp)
movq (%r8), %r15
movq (%r15,%r14), %rbx
movq %rbx, %r13
shrq $0x20, %r13
movl 0xc(%r15,%r14), %ebp
imulq $0x18, %rbp, %r12
addq 0x30(%rsp), %r12
movq %r12, %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0x696ab
cmpq $-0x1, %rax
je 0x69b6a
cmpl %ebp, %r13d
ja 0x69b6a
cmpq $0x0, 0x18(%r15,%r14)
movq (%r12), %rcx
js 0x69bbe
imulq $0x28, %rax, %rdx
cmpq $0x0, 0x18(%rcx,%rdx)
js 0x69bbe
xorl %r13d, %r13d
jmp 0x69bc3
movq 0x20(%rsp), %rdx
movq (%rdx), %rcx
movq 0x18(%rsp), %r12
movq (%rcx,%r12), %rax
cmpq 0x8(%rcx,%r12), %rax
jne 0x69bea
leaq (%rax,%rax), %rsi
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %rsi
leaq (%rcx,%r12), %rax
movq %rsi, 0x8(%rcx,%r12)
movq 0x10(%rax), %rdi
shlq $0x3, %rsi
movq %rdx, %rbx
callq 0x2370
movq (%rbx), %rcx
movq %rax, 0x10(%rcx,%r12)
movq (%rcx,%r12), %rax
movq (%rsp), %r8
movq (%r8), %r15
jmp 0x69bee
movq 0x10(%rsp), %r13
movl 0x8(%r15,%r14), %edx
addq %r14, %r15
subl %ebx, %edx
imulq $0x28, %rax, %rbx
leaq (%rcx,%rbx), %rsi
movl 0x8(%rcx,%rbx), %eax
subl (%rcx,%rbx), %eax
cmpl %eax, %edx
je 0x69be2
jbe 0x69c18
movq %rsi, %rdi
movq %r15, %rsi
jmp 0x69c1b
movq (%rsp), %r8
movq 0x8(%rsp), %r9
movq %r9, %rdx
orq 0x28(%rsp), %rdx
movq 0x10(%rcx,%r12), %rsi
leaq 0x1(%rax), %rdi
movq %rdi, (%rcx,%r12)
movq %rdx, (%rsi,%rax,8)
movq 0x10(%rsp), %rax
orq %rax, 0x18(%r15,%r14)
jmp 0x69c5a
movq %r15, %rdi
callq 0x696da
movq (%rsp), %r8
movq (%r8), %rax
movq 0x18(%rax,%r14), %rcx
movabsq $0x7fffffffffffffff, %rdx # imm = 0x7FFFFFFFFFFFFFFF
andq %rdx, %rcx
orq %r13, %rcx
movq %rcx, 0x18(%rax,%r14)
movq (%r12), %rax
movq 0x18(%rax,%rbx), %rcx
andq %rdx, %rcx
orq %r13, %rcx
movq %rcx, 0x18(%rax,%rbx)
movq 0x8(%rsp), %r9
incq %r9
addq $0x28, %r14
jmp 0x69b07
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq