// File: /workspace/github_cpp_makefile_star2_O3/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), %rcx
movq %rsi, 0x10(%rsp)
leaq (%rsi,%rsi,2), %rax
movq %rcx, (%rsp)
cmpl $0x0, 0xc(%rcx,%rax,8)
je 0xa13a7
movq %rdi, %r14
movq (%rsp), %rcx
leaq (%rcx,%rax,8), %r12
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
shlq $0x20, 0x10(%rsp)
movslq %edx, %rbp
xorl %r13d, %r13d
shlq $0x5, %rbp
incq %rax
movq %rax, 0x18(%rsp)
movq (%r12), %rcx
leaq (,%r13,4), %rbx
addq %r13, %rbx
movl 0xc(%rcx,%rbx,8), %edi
leaq (%rdi,%rdi,2), %rax
movq (%rsp), %rdx
movl 0xc(%rdx,%rax,8), %r8d
testq %r8, %r8
je 0xa129f
leaq (%rcx,%rbx,8), %rsi
movq (%rsi), %rdx
movq %rdx, %r9
shrq $0x20, %r9
movq (%rsp), %r10
leaq (%r10,%rax,8), %rax
movq %rax, 0x20(%rsp)
movq (%rax), %rax
shlq $0x3, %r8
leaq (%r8,%r8,4), %r10
xorl %r15d, %r15d
cmpl %r9d, 0xc(%rax,%r15)
jne 0xa128f
movq (%rax,%r15), %r8
movq %r8, %r11
shrq $0x20, %r11
cmpl %r11d, %edi
je 0xa129a
addq $0x28, %r15
cmpq %r15, %r10
jne 0xa1278
jmp 0xa129f
cmpl %edi, %r9d
jbe 0xa131c
movq (%r14), %rdx
movq (%rdx,%rbp), %rax
cmpq 0x8(%rdx,%rbp), %rax
jne 0xa12e3
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
leaq (%rdx,%rbp), %rax
movq %rsi, 0x8(%rdx,%rbp)
movq 0x10(%rax), %rdi
shlq $0x3, %rsi
callq 0x2370
movq (%r14), %rdx
movq %rax, 0x10(%rdx,%rbp)
movq (%rdx,%rbp), %rax
movq (%r12), %rcx
movq %r13, %rsi
orq 0x10(%rsp), %rsi
movq 0x10(%rdx,%rbp), %rdi
leaq 0x1(%rax), %r8
movq %r8, (%rdx,%rbp)
movq %rsi, (%rdi,%rax,8)
movq 0x18(%rsp), %rax
orq %rax, 0x18(%rcx,%rbx,8)
incq %r13
movl 0xc(%r12), %eax
cmpq %rax, %r13
jb 0xa122a
jmp 0xa13a7
cmpq $0x0, 0x18(%rcx,%rbx,8)
js 0xa1337
cmpq $0x0, 0x18(%rax,%r15)
js 0xa1337
movq $0x0, 0x8(%rsp)
jmp 0xa1341
movq 0x18(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movl 0x8(%rsi), %ecx
subl %edx, %ecx
movl 0x8(%rax,%r15), %edx
addq %r15, %rax
subl %r8d, %edx
cmpl %edx, %ecx
je 0xa1357
jbe 0xa135c
movq %rax, %rdi
jmp 0xa1362
movq %rsi, %rdi
movq %rax, %rsi
callq 0xa0cca
movq (%r12), %rax
movq 0x18(%rax,%rbx,8), %rcx
movabsq $0x7fffffffffffffff, %rdx # imm = 0x7FFFFFFFFFFFFFFF
andq %rdx, %rcx
movq 0x8(%rsp), %rsi
orq %rsi, %rcx
movq %rcx, 0x18(%rax,%rbx,8)
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax,%r15), %rcx
andq %rdx, %rcx
orq %rsi, %rcx
movq %rcx, 0x18(%rax,%r15)
jmp 0xa1306
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq