// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movq %r8, %r14
movq (%rsi), %r9
movq %r9, %r8
shrq $0x20, %r8
movl %r8d, %r10d
xorl $0x1, %r10d
movq (%rdi), %rax
movq $0x0, (%rsp)
movl %r10d, %edi
movl %edi, %r13d
movl %edi, %r11d
shrl %r11d
movl %edi, %r15d
andl $0x1, %r15d
imulq $0x78, %r11, %rbx
addq %rax, %rbx
leaq (%r15,%r15,2), %r15
movl 0x10(%rbx,%r15,8), %r11d
testq %r11, %r11
je 0x21631c
movq 0x20(%rbx,%r15,8), %rbx
shlq $0x5, %r11
xorl %r15d, %r15d
xorl %ebp, %ebp
movl 0xc(%rbx,%r15), %r12d
notl %r12d
shrl $0x1f, %r12d
addl %r12d, %ebp
addq $0x20, %r15
cmpq %r15, %r11
jne 0x216289
incq (%rsp)
cmpl $0x1, %ebp
jne 0x216320
xorl %r15d, %r15d
cmpl $0x0, 0xc(%rbx,%r15)
js 0x2162ba
movl 0x8(%rbx,%r15), %edi
addq $0x20, %r15
cmpq %r15, %r11
jne 0x2162ad
movl %edi, %r11d
notl %r11d
movl %edi, %ebx
shrl %ebx
andl $0x1, %r11d
imulq $0x78, %rbx, %rbx
addq %rax, %rbx
leaq (%r11,%r11,2), %r15
movl 0x10(%rbx,%r15,8), %r11d
testq %r11, %r11
je 0x216320
movq 0x20(%rbx,%r15,8), %rbx
shlq $0x5, %r11
xorl %r15d, %r15d
xorl %ebp, %ebp
movl 0xc(%rbx,%r15), %r12d
notl %r12d
shrl $0x1f, %r12d
addl %r12d, %ebp
addq $0x20, %r15
cmpq %r15, %r11
jne 0x2162f4
cmpl $0x1, %ebp
jne 0x216320
cmpl %r10d, %edi
jne 0x216252
jmp 0x216320
incq (%rsp)
movq (%rdx), %rdi
movq %rdi, %r10
shrq $0x20, %r10
cmpl %r13d, %r10d
jne 0x216545
movq 0x18(%rsi), %rsi
movq $0x0, 0x10(%rsp)
testl %esi, %esi
je 0x216372
shrq $0x21, %r9
andl $0x1, %r8d
imulq $0x78, %r9, %r9
addq %rax, %r9
leaq (%r8,%r8,2), %r8
movq %rsi, %r10
shrq $0x20, %r10
leaq (%r10,%r10,2), %r10
shlq $0x2, %r10
addq 0x50(%r9,%r8,8), %r10
movq %r10, 0x8(%rsp)
jmp 0x21637d
movq $0x0, 0x8(%rsp)
xorl %esi, %esi
movq 0x18(%rdx), %r8
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %r8, %rdx
je 0x2163bc
movl %r13d, %r9d
shrq $0x21, %rdi
andl $0x1, %r9d
imulq $0x78, %rdi, %rdi
addq %rdi, %rax
leaq (%r9,%r9,2), %r9
movq %r8, %rdi
shrq $0x20, %rdi
leaq (%rdi,%rdi,2), %rbx
shlq $0x2, %rbx
addq 0x50(%rax,%r9,8), %rbx
movq %r8, 0x10(%rsp)
jmp 0x2163be
xorl %ebx, %ebx
movq (%rsp), %r8
movq %rcx, 0x20(%rsp)
testl %esi, %esi
je 0x216522
movl %esi, %eax
movq %rax, 0x28(%rsp)
shlq $0x2, %rdx
leaq (%rdx,%rdx,2), %r12
xorl %eax, %eax
xorl %ebp, %ebp
xorl %r13d, %r13d
cmpl $0x0, 0x10(%rsp)
movq %rax, 0x30(%rsp)
je 0x21650d
leaq (%rax,%rax,2), %rax
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,4), %r11
movl 0x4(%r11), %ecx
xorl %r15d, %r15d
movq %r11, 0x18(%rsp)
cmpl 0x4(%rbx,%r15), %ecx
jne 0x216500
movl 0x8(%r11), %esi
leaq (%r8,%rsi), %rax
movl 0x8(%rbx,%r15), %edx
cmpq %rdx, %rax
jne 0x216490
testq %r14, %r14
je 0x2164f9
movq (%r14), %rdx
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rdx
jne 0x216479
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x18(%rsp), %r11
movq (%rsp), %r8
movq %rax, 0x10(%r14)
movl 0x4(%r11), %ecx
movl 0x8(%r11), %esi
movq (%r14), %rdx
movq %rcx, %rdi
shlq $0x20, %rdi
orq %rsi, %rdi
leaq 0x1(%rdx), %rsi
movq %rsi, (%r14)
movq %rdi, (%rax,%rdx,8)
jmp 0x2164f9
leaq (%r8,%rdx), %rax
cmpq %rsi, %rax
jne 0x2164fe
testq %r14, %r14
je 0x2164f9
movq (%r14), %rdi
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rdi
jne 0x2164e4
leaq (%rdi,%rdi), %rsi
testq %rdi, %rdi
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x18(%rsp), %r11
movq (%rsp), %r8
movq %rax, 0x10(%r14)
movl 0x4(%r11), %ecx
movl 0x8(%rbx,%r15), %edx
movq (%r14), %rdi
movq %rcx, %rsi
shlq $0x20, %rsi
orq %rdx, %rsi
leaq 0x1(%rdi), %rdx
movq %rdx, (%r14)
movq %rsi, (%rax,%rdi,8)
incl %r13d
jmp 0x216500
incl %ebp
addq $0xc, %r15
cmpq %r15, %r12
jne 0x21640e
movq 0x30(%rsp), %rax
incq %rax
cmpq 0x28(%rsp), %rax
jne 0x2163e5
jmp 0x216527
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x216533
movl %ebp, (%rax)
movl %r13d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x31fd0(%rip), %rdi     # 0x24851c
leaq 0x2f0b6(%rip), %rsi     # 0x245609
leaq 0x31fd5(%rip), %rcx     # 0x24852f
movl $0x2cda, %edx           # imm = 0x2CDA
callq 0x2110