// File: 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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
cmpq $0x1, -0x18(%rbp)
ja 0x376006
cmpq $0x1, -0x28(%rbp)
ja 0x376006
jmp 0x37650b
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl %eax, %eax
movq %rax, -0x40(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x376045
movq $0x1, -0x58(%rbp)
movq -0x8(%rbp), %rax
imulq $0x18, -0x38(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
movl 0xc(%rax), %eax
movq %rax, -0xb0(%rbp)
movq $0x0, -0xd0(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0xc0(%rbp)
movq -0x48(%rbp), %rax
cmpq -0xb0(%rbp), %rax
jae 0x376160
movq -0xe0(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x48(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
cmpq -0x40(%rbp), %rax
jne 0x37614d
jmp 0x3760b9
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x37612a
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x3760e9
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xf0(%rbp)
jmp 0x3760f7
movl $0x2, %eax
movq %rax, -0xf0(%rbp)
jmp 0x3760f7
movq -0xf0(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rdx
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x37614d
jmp 0x37614f
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x376087
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x8(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
movl 0xc(%rax), %eax
movq %rax, -0xb8(%rbp)
movq $0x0, -0xd8(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0xc8(%rbp)
movq -0x48(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jae 0x376289
movq -0xe8(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x48(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
cmpq -0x38(%rbp), %rax
jne 0x376276
jmp 0x3761e2
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x376253
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x376212
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xf8(%rbp)
jmp 0x376220
movl $0x2, %eax
movq %rax, -0xf8(%rbp)
jmp 0x376220
movq -0xf8(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rdx
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x376276
jmp 0x376278
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x3761b0
movq -0x30(%rbp), %rax
movq (%rax), %rax
subq -0xd0(%rbp), %rax
movq %rax, -0xd8(%rbp)
xorl %eax, %eax
cmpq $0x0, -0xd0(%rbp)
movb %al, -0xf9(%rbp)
je 0x3762c1
cmpq $0x0, -0xd8(%rbp)
setne %al
movb %al, -0xf9(%rbp)
movb -0xf9(%rbp), %al
testb $0x1, %al
jne 0x3762cd
jmp 0x3762cf
jmp 0x3762ee
leaq 0x24c47(%rip), %rdi     # 0x39af1d
leaq 0x1fedc(%rip), %rsi     # 0x3961b9
movl $0x42c8, %edx           # imm = 0x42C8
leaq 0x24c41(%rip), %rcx     # 0x39af2a
callq 0x2130
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xd0(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movq $0x0, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
cmpq -0xd0(%rbp), %rax
jae 0x37650b
movq -0xe0(%rbp), %rax
movq (%rax), %rsi
movq -0xc0(%rbp), %rax
movq -0xb0(%rbp), %rcx
imulq $0x28, (%rax,%rcx,8), %rax
addq %rax, %rsi
leaq -0x80(%rbp), %rdi
movl $0x28, %edx
callq 0x2180
movq $0x0, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
cmpq -0xd8(%rbp), %rax
jae 0x3764f2
movq -0xe8(%rbp), %rax
movq (%rax), %rsi
movq -0xc8(%rbp), %rax
movq -0xb8(%rbp), %rcx
imulq $0x28, (%rax,%rcx,8), %rax
addq %rax, %rsi
leaq -0xa8(%rbp), %rdi
movl $0x28, %edx
callq 0x2180
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x3764d9
movq -0x10(%rbp), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x3764c6
cmpq $0x0, -0x48(%rbp)
jne 0x376408
cmpq $0x0, -0x50(%rbp)
jne 0x376408
jmp 0x3764b5
movq -0x20(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0x80(%rbp), %rdi
callq 0x37dc20
cmpq $0x0, -0x58(%rbp)
je 0x37644d
movq -0x8(%rbp), %rdi
imulq $0x18, -0x38(%rbp), %rax
addq %rax, %rdi
leaq -0x80(%rbp), %rsi
callq 0x37dc70
cmpq $0x0, %rax
je 0x376462
movq -0x8(%rbp), %rdi
imulq $0x18, -0x38(%rbp), %rax
addq %rax, %rdi
leaq -0x80(%rbp), %rsi
callq 0xcd340
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0xa8(%rbp), %rdi
callq 0x37dc20
cmpq $0x0, -0x58(%rbp)
je 0x37649b
movq -0x8(%rbp), %rdi
imulq $0x18, -0x40(%rbp), %rax
addq %rax, %rdi
leaq -0xa8(%rbp), %rsi
callq 0x37dc70
cmpq $0x0, %rax
je 0x3764b3
movq -0x8(%rbp), %rdi
imulq $0x18, -0x40(%rbp), %rax
addq %rax, %rdi
leaq -0xa8(%rbp), %rsi
callq 0xcd340
jmp 0x3764b5
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x3763e7
jmp 0x3764c8
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x3763bf
jmp 0x3764db
movq -0xb8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb8(%rbp)
jmp 0x376372
jmp 0x3764f4
movq -0xb0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb0(%rbp)
jmp 0x376325
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)