// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: dedup_exact_ug(dedup_idx_t*, dedup_idx_t*, ma_sub_t*, ma_hit_t_alloc*, R_to_U*, unsigned char*, unsigned char)
uint64_t dedup_exact_ug(dedup_idx_t *ref, dedup_idx_t *qry, ma_sub_t *cov, ma_hit_t_alloc *src, R_to_U *rui, uint8_t *ff, uint8_t trio_f)
{
    // fprintf(stderr, "[M::%s] Start\n", __func__);
    uint64_t k, n_base = 0; int64_t f;
    for (k = 0; k < qry->ug->u.n; k++) {
        if((qry->ug->u.a[k].n == 0) || (qry->ug->u.a[k].m == 0) || (qry->ug->g->seq[k].del)) continue;
        if(if_primary_unitig(&(qry->ug->u.a[k]), qry->rg, cov, src, rui, ff)) continue;
        f = cal_exact_ug_o(ref, &(qry->ug->u.a[k]), trio_f);
        if(f == INT32_MIN) continue;
        if(f == -1) {///delete qry
            delete_ug_node(qry->ug, k); n_base += qry->ug->u.a[k].len;
        } else if(f >= 0) {///delete ref
            delete_ug_node(ref->ug, f); n_base += ref->ug->u.a[f].len;
        }
    }
    // fprintf(stderr, "[M::%s] End\n", __func__);
    return n_base;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb 0x10(%rbp), %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpq (%rcx), %rax
jae 0x126054
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
cmpl $0x0, 0x10(%rax)
je 0x125f57
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
je 0x125f57
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x125f5c
jmp 0x126043
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rdi
imulq $0x28, -0x38(%rbp), %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
callq 0x1185a0
cmpb $0x0, %al
je 0x125f95
jmp 0x126043
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rsi
imulq $0x28, -0x38(%rbp), %rax
addq %rax, %rsi
movzbl 0x10(%rbp), %eax
movl %eax, %edx
callq 0x125740
movq %rax, -0x48(%rbp)
cmpq $-0x80000000, -0x48(%rbp) # imm = 0x80000000
jne 0x125fc7
jmp 0x126043
cmpq $-0x1, -0x48(%rbp)
jne 0x126004
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x125e20
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x126041
cmpq $0x0, -0x48(%rbp)
jl 0x12603f
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rsi
callq 0x125e20
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x48(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x126041
jmp 0x126043
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x125ef3
movq -0x40(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nop