// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: renew_paf0(ma_hit_t_alloc*, unsigned long*, unsigned long, unsigned long*, unsigned long, asg64_v*)
void renew_paf0(ma_hit_t_alloc *paf, uint64_t *a0, uint64_t a0n, uint64_t *a1, uint64_t a1n, asg64_v *buf)
{
    if(a0n <= 1 && a1n <= 1) return;
    uint64_t qn = ((uint32_t)a0[0]), tn = ((uint32_t)a1[0]), i, k, sf = 0;
    ma_hit_t e01, e10; uint64_t qi, ti, *qa, *ta, qlen, tlen; buf->n = 0; ma_hit_t_alloc *qo, *to;
    if(qn == tn) sf = 1;
    qo = &(paf[qn]); qi = qo->length;
    for (i = qlen = 0, qa = NULL; i < qi; i++) {
        if(qo->buffer[i].tn == tn) kv_push(uint64_t, *buf, i);
    }
    qlen = buf->n; 

    to = &(paf[tn]); ti = to->length;
    for (i = tlen = 0, ta = NULL; i < ti; i++) {
        if(to->buffer[i].tn == qn) kv_push(uint64_t, *buf, i);
    }
    tlen = buf->n - qlen;
    assert(qlen && tlen);
    qa = buf->a; ta = buf->a + qlen;

    for (qi = 0; qi < qlen; qi++) {
        e01 = qo->buffer[qa[qi]];
        for (ti = 0; ti < tlen; ti++) {
            e10 = to->buffer[ta[ti]];

            for (i = 0; i < a0n; i++) {
                qn = ((uint32_t)a0[i]);
                for (k = 0; k < a1n; k++) {
                    if(i == 0 && k == 0) continue;
                    tn = ((uint32_t)a1[k]);

                    update_qtn(&e01, qn, tn); 
                    if((!sf) || (dup_paf_check(&(paf[qn]), &e01))) {
                        add_ma_hit_t_alloc(&(paf[qn]), &e01);
                    }

                    update_qtn(&e10, tn, qn); 
                    if((!sf) || (dup_paf_check(&(paf[tn]), &e10))) {
                        add_ma_hit_t_alloc(&(paf[tn]), &e10);
                    }
                }
            }
        }
    }
    
    /**
    idx = get_specific_overlap(&(paf[qn]), qn, tn);
    if(idx < 0) return;
    e01 = paf[qn].buffer[idx];
    idx = get_specific_overlap(&(paf[tn]), tn, qn);
    e10 = paf[tn].buffer[idx];

    for (i = 0; i < a0n; i++) {
        qn = ((uint32_t)a0[i]);
        for (k = 0; k < a1n; k++) {
            if(i == 0 && k == 0) continue;
            tn = ((uint32_t)a1[k]);
            if((qn == 5619628 && tn == 5619629) || (tn == 5619628 && qn == 5619629)) {
                fprintf(stderr, "[M::%s]\tqn::%lu(qg::%u)\ttn::%lu(tg::%u)\n", __func__, 
                qn, ((uint32_t)a0[0]), tn, ((uint32_t)a1[0]));
            }
            update_qtn(&e01, qn, tn); add_ma_hit_t_alloc(&(paf[qn]), &e01);
            update_qtn(&e10, tn, qn); add_ma_hit_t_alloc(&(paf[tn]), &e10);
        }
    }
    **/
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %r8, 0x78(%rsp)
movq %r8, %rax
movq %rdx, 0x68(%rsp)
orq %rdx, %rax
cmpq $0x2, %rax
jae 0x1daf8d
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r9, %r15
movq %rsi, 0x60(%rsp)
movl (%rsi), %eax
movq %rcx, 0x70(%rsp)
movq (%rcx), %rbx
andq $0x0, (%r9)
movl %ebx, %ecx
movq %rcx, 0x10(%rsp)
movq %rax, 0x18(%rsp)
imulq $0x18, %rax, %rax
leaq (%rdi,%rax), %rcx
movq %rcx, 0x28(%rsp)
movq %rdi, 0x8(%rsp)
movl 0xc(%rdi,%rax), %r14d
pushq $0xc
popq %r13
xorl %r12d, %r12d
pushq $0x2
popq %rbp
cmpq %r12, %r14
je 0x1db026
movq 0x28(%rsp), %rax
movq (%rax), %rax
cmpl %ebx, (%rax,%r13)
jne 0x1db01d
movq (%r15), %rcx
movq 0x10(%r15), %rax
cmpq 0x8(%r15), %rcx
jne 0x1db012
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %rbp, %rsi
movq %rsi, 0x8(%r15)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%r15)
movq (%r15), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r15)
movq %r12, (%rax,%rcx,8)
incq %r12
addq $0x28, %r13
jmp 0x1dafd0
movq (%r15), %rax
movq %rax, 0x20(%rsp)
imulq $0x18, 0x10(%rsp), %rax
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax), %rdx
movq %rdx, 0x30(%rsp)
movl 0xc(%rcx,%rax), %ebx
pushq $0xc
popq %r14
xorl %r12d, %r12d
cmpq %r12, %rbx
je 0x1db0a8
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rsp), %rcx
cmpl %ecx, (%rax,%r14)
jne 0x1db09f
movq (%r15), %rcx
movq 0x10(%r15), %rax
cmpq 0x8(%r15), %rcx
jne 0x1db094
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %rbp, %rsi
movq %rsi, 0x8(%r15)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%r15)
movq (%r15), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r15)
movq %r12, (%rax,%rcx,8)
incq %r12
addq $0x28, %r14
jmp 0x1db04d
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x1db281
movq (%r15), %rsi
cmpq %rax, %rsi
je 0x1db281
subq %rax, %rsi
movq 0x10(%r15), %rcx
movq %rcx, 0x38(%rsp)
leaq (%rcx,%rax,8), %rcx
movq %rcx, 0x48(%rsp)
xorl %ecx, %ecx
movq %rsi, 0x50(%rsp)
cmpq %rax, %rcx
je 0x1daf7b
movq 0x38(%rsp), %rax
movq %rcx, 0x40(%rsp)
imulq $0x28, (%rax,%rcx,8), %rax
movq 0x28(%rsp), %rcx
movq (%rcx), %rcx
movq 0x20(%rcx,%rax), %rdx
movq %rdx, 0xa0(%rsp)
movups (%rcx,%rax), %xmm0
movups 0x10(%rcx,%rax), %xmm1
movaps %xmm1, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
xorl %ecx, %ecx
cmpq %rsi, %rcx
je 0x1db26f
movq 0x48(%rsp), %rax
movq %rcx, 0x58(%rsp)
imulq $0x28, (%rax,%rcx,8), %rax
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
movq 0x20(%rcx,%rax), %rdx
movq %rdx, 0xd0(%rsp)
movups (%rcx,%rax), %xmm0
movups 0x10(%rcx,%rax), %xmm1
movaps %xmm1, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
xorl %r12d, %r12d
cmpq 0x68(%rsp), %r12
je 0x1db25d
movq 0x60(%rsp), %rax
movq (%rax,%r12,8), %rbx
movl %ebx, %eax
movq %rbx, %r13
shlq $0x20, %r13
imulq $0x18, %rax, %r15
addq 0x8(%rsp), %r15
xorl %r14d, %r14d
cmpq %r14, 0x78(%rsp)
je 0x1db255
movq %r14, %rax
orq %r12, %rax
je 0x1db24d
movl 0x80(%rsp), %eax
orq %r13, %rax
movq 0x70(%rsp), %rcx
movq (%rcx,%r14,8), %rbp
movq %rax, 0x80(%rsp)
movl %ebp, 0x8c(%rsp)
movq 0x10(%rsp), %rax
cmpl %eax, 0x18(%rsp)
jne 0x1db1f1
movq %r15, %rdi
leaq 0x80(%rsp), %rsi
callq 0x1df1f4
testq %rax, %rax
je 0x1db201
movq %r15, %rdi
leaq 0x80(%rsp), %rsi
callq 0x69052
movl %ebp, %ebp
movl %ebp, 0xb4(%rsp)
movl %ebx, 0xbc(%rsp)
movq 0x10(%rsp), %rax
cmpl %eax, 0x18(%rsp)
jne 0x1db237
imulq $0x18, %rbp, %rdi
addq 0x8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x1df1f4
testq %rax, %rax
je 0x1db24d
imulq $0x18, %rbp, %rdi
addq 0x8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x69052
incq %r14
jmp 0x1db198
incq %r12
jmp 0x1db16f
movq 0x58(%rsp), %rcx
incq %rcx
movq 0x50(%rsp), %rsi
jmp 0x1db126
movq 0x40(%rsp), %rcx
incq %rcx
movq 0x20(%rsp), %rax
jmp 0x1db0de
leaq 0x20f6c(%rip), %rdi     # 0x1fc1f4
leaq 0x1c24a(%rip), %rsi     # 0x1f74d9
leaq 0x20f6b(%rip), %rcx     # 0x1fc201
movl $0x42c8, %edx           # imm = 0x42C8
callq 0x2110