// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: usg_arc_mm_consist(usg_t*, usg_arc_t*, usg_arc_t*, unsigned int*, asg64_v*)
uint32_t usg_arc_mm_consist(usg_t *g, usg_arc_t *v, usg_arc_t *w, uint32_t *inconsist, asg64_v *b)
{
    usg_arc_mm_t *v_a = NULL, *w_a = NULL; uint32_t v_n, w_n, v_k, w_k, occ = 0, n_occ = 0, cov; uint64_t l = 0;
    get_usg_unitig(g, (v->ul>>32)^1, &cov, NULL, NULL, &l, NULL); assert(cov == (w->ul>>32));
    
    v_n = get_usg_arc_mm(g, v, &v_a); w_n = get_usg_arc_mm(g, w, &w_a);
    // if((v->ul>>33) == 257 || (v->ul>>33) == 256) {
    //     fprintf(stderr, "****[M::%s::] v>>1::%u, v&1::%u, v->des::%u, v_n::%u, v_ou::%u, w>>1::%u, w&1::%u, w->des::%u, w_n::%u, w_ou::%u\n", 
    //     __func__, (uint32_t)(v->ul>>33), (uint32_t)(v->ul>>32)&1, v->v>>1, v_n, v->ou, cov>>1, cov&1, w->v>>1, w_n, w->ou);
    // }

    for (v_k = 0; v_k < v_n; v_k++) {
        for (w_k = 0; w_k < w_n; w_k++) {
            // if((v->ul>>33) == 257 || (v->ul>>33) == 256) {
            //     fprintf(stderr, "[M::%s::] v_a->uid::%u, v_a->off::%u, w_a->uid::%u, w_a->off::%u\n", 
            //     __func__, v_a[v_k].uid, v_a[v_k].off, w_a[w_k].uid, w_a[w_k].off);
            // }
            if(v_a[v_k].uid != w_a[w_k].uid) continue;
            if(v_a[v_k].off + l == w_a[w_k].off) {
                if(b) kv_push(uint64_t, *b, (((uint64_t)v_a[v_k].uid)<<32)|((uint64_t)v_a[v_k].off));
                occ++; 
            } else if(v_a[v_k].off == w_a[w_k].off + l) {
                if(b) kv_push(uint64_t, *b, (((uint64_t)v_a[v_k].uid)<<32)|((uint64_t)w_a[w_k].off));
                occ++;
            } else {
                n_occ++;
            }
        }
    }

    if(inconsist) (*inconsist) = n_occ;
    return occ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %r14
movq %rcx, 0x18(%rsp)
andq $0x0, 0x10(%rsp)
movq %rdx, %r12
andq $0x0, 0x48(%rsp)
leaq 0x40(%rsp), %r9
andq $0x0, (%r9)
movq %rsi, %rbp
movq %rdi, %r13
movl 0x4(%rsi), %esi
xorl $0x1, %esi
andq $0x0, (%rsp)
xorl %r15d, %r15d
leaq 0x54(%rsp), %rbx
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x1dee72
movl 0x4(%r12), %eax
cmpl (%rbx), %eax
jne 0x1c8460
leaq 0x10(%rsp), %rdx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1c8206
movl %eax, %ebp
leaq 0x48(%rsp), %rbx
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1c8206
leaq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x20(%rsp)
movq (%rbx), %rbx
movl %ebp, %ecx
movq %rcx, 0x28(%rsp)
movl %eax, %eax
imulq $0xc, %rax, %r9
xorl %eax, %eax
xorl %r8d, %r8d
movq %r9, 0x8(%rsp)
cmpq 0x28(%rsp), %rax
je 0x1c8441
movq %rax, 0x30(%rsp)
imulq $0xc, %rax, %rax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax), %r12
addq %rcx, %rax
addq $0x4, %rax
movq %rax, 0x38(%rsp)
xorl %ebp, %ebp
cmpq %rbp, %r9
je 0x1c8434
movl 0x4(%r12), %ecx
cmpl 0x4(%rbx,%rbp), %ecx
jne 0x1c842b
movl 0x8(%r12), %edx
movq 0x40(%rsp), %rax
leaq (%rax,%rdx), %rdi
movl 0x8(%rbx,%rbp), %esi
cmpq %rsi, %rdi
jne 0x1c83b6
testq %r14, %r14
je 0x1c8423
movq (%r14), %rdi
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rdi
jne 0x1c83a2
leaq (%rdi,%rdi), %rsi
testq %rdi, %rdi
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x3, %rsi
movq %rax, %rdi
movq %r15, %r13
movl %r8d, %r15d
callq 0x2370
movq 0x8(%rsp), %r9
movl %r15d, %r8d
movq %r13, %r15
movq %rax, 0x10(%r14)
movl 0x4(%r12), %ecx
movl 0x8(%r12), %edx
movq (%r14), %rdi
shlq $0x20, %rcx
orq %rdx, %rcx
leaq 0x1(%rdi), %rdx
movq %rdx, (%r14)
movq %rcx, (%rax,%rdi,8)
jmp 0x1c8423
addq %rsi, %rax
cmpq %rdx, %rax
jne 0x1c8428
testq %r14, %r14
je 0x1c8423
movq (%r14), %rdx
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rdx
jne 0x1c8411
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x3, %rsi
movq %rax, %rdi
movq %r15, %r13
movl %r8d, %r15d
callq 0x2370
movq 0x8(%rsp), %r9
movl %r15d, %r8d
movq %r13, %r15
movq %rax, 0x10(%r14)
movq 0x38(%rsp), %rcx
movl (%rcx), %ecx
movl 0x8(%rbx,%rbp), %esi
movq (%r14), %rdx
shlq $0x20, %rcx
orq %rsi, %rcx
leaq 0x1(%rdx), %rsi
movq %rsi, (%r14)
movq %rcx, (%rax,%rdx,8)
incl %r15d
jmp 0x1c842b
incl %r8d
addq $0xc, %rbp
jmp 0x1c831d
movq 0x30(%rsp), %rax
incq %rax
jmp 0x1c82f2
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0x1c844e
movl %r8d, (%rax)
movl %r15d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x32074(%rip), %rdi     # 0x1fa4db
leaq 0x2f06b(%rip), %rsi     # 0x1f74d9
leaq 0x32079(%rip), %rcx     # 0x1fa4ee
movl $0x2cda, %edx           # imm = 0x2CDA
callq 0x2110