// File: /workspace/github_cpp_makefile_star2_O1/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 %rcx, 0x20(%rsp)
movq (%rsi), %r14
movq %r14, %rcx
shrq $0x20, %rcx
movl %ecx, %r9d
xorl $0x1, %r9d
movq (%rdi), %rax
movq $0x0, (%rsp)
movl %r9d, %r10d
movl %r10d, %edi
movl %r10d, %r11d
shrl %r11d
movl %r10d, %ebx
andl $0x1, %ebx
imulq $0x78, %r11, %r15
addq %rax, %r15
leaq (%rbx,%rbx,2), %rbx
movl 0x10(%r15,%rbx,8), %r11d
movq 0x20(%r15,%rbx,8), %rbx
xorl %r15d, %r15d
testq %r11, %r11
je 0x20af3b
movq %r11, %r12
shlq $0x5, %r12
xorl %r13d, %r13d
movl 0xc(%rbx,%r13), %ebp
notl %ebp
shrl $0x1f, %ebp
addl %ebp, %r15d
addq $0x20, %r13
cmpq %r13, %r12
jne 0x20af1d
cmpl $0x1, %r15d
sete %r15b
incq (%rsp)
testb %r15b, %r15b
je 0x20afbe
testq %r11, %r11
je 0x20af66
shlq $0x5, %r11
xorl %r15d, %r15d
cmpl $0x0, 0xc(%rbx,%r15)
js 0x20af5d
movl 0x8(%rbx,%r15), %r10d
addq $0x20, %r15
cmpq %r15, %r11
jne 0x20af50
movl %r10d, %r11d
notl %r11d
movl %r10d, %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 0x20afbe
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 0x20af98
cmpl $0x1, %ebp
jne 0x20afbe
cmpl %r9d, %r10d
jne 0x20aee7
movl %edi, %r10d
movq (%rdx), %r9
movq %r9, %rdi
shrq $0x20, %rdi
cmpq %r10, %rdi
jne 0x20b1c2
movq 0x18(%rsi), %rsi
movq $0x0, 0x10(%rsp)
testl %esi, %esi
je 0x20b012
shrq $0x21, %r14
andl $0x1, %ecx
imulq $0x78, %r14, %r11
addq %rax, %r11
leaq (%rcx,%rcx,2), %rcx
movq %rsi, %r10
shrq $0x20, %r10
leaq (%r10,%r10,2), %r10
shlq $0x2, %r10
addq 0x50(%r11,%rcx,8), %r10
movq %r10, 0x8(%rsp)
jmp 0x20b01d
movq $0x0, 0x8(%rsp)
xorl %esi, %esi
movq 0x18(%rdx), %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rdx, %rcx
je 0x20b058
shrq $0x21, %r9
andl $0x1, %edi
imulq $0x78, %r9, %r9
addq %r9, %rax
leaq (%rdi,%rdi,2), %rdi
movq %rdx, %r9
shrq $0x20, %r9
leaq (%r9,%r9,2), %rbx
shlq $0x2, %rbx
addq 0x50(%rax,%rdi,8), %rbx
movq %rdx, 0x10(%rsp)
jmp 0x20b05a
xorl %ebx, %ebx
movq (%rsp), %rdi
testl %esi, %esi
je 0x20b19f
movl %esi, %eax
movq %rax, 0x28(%rsp)
shlq $0x2, %rcx
leaq (%rcx,%rcx,2), %r12
xorl %eax, %eax
xorl %ebp, %ebp
xorl %r14d, %r14d
movq %r8, 0x18(%rsp)
cmpl $0x0, 0x10(%rsp)
movq %rax, 0x30(%rsp)
je 0x20b18a
leaq (%rax,%rax,2), %rax
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,4), %r13
xorl %r15d, %r15d
movl 0x4(%r13), %eax
cmpl 0x4(%rbx,%r15), %eax
jne 0x20b17d
movl 0x8(%r13), %eax
leaq (%rdi,%rax), %rdx
movl 0x8(%rbx,%r15), %ecx
cmpq %rcx, %rdx
jne 0x20b110
testq %r8, %r8
je 0x20b176
movq 0x8(%r8), %rax
cmpq %rax, (%r8)
jne 0x20b102
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r8)
movq 0x10(%r8), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x18(%rsp), %r8
movq (%rsp), %rdi
movq %rax, 0x10(%r8)
movl 0x4(%r13), %eax
movl 0x8(%r13), %ecx
shlq $0x20, %rax
jmp 0x20b161
addq %rdi, %rcx
cmpq %rax, %rcx
jne 0x20b17b
testq %r8, %r8
je 0x20b176
movq 0x8(%r8), %rax
cmpq %rax, (%r8)
jne 0x20b154
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r8)
movq 0x10(%r8), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x18(%rsp), %r8
movq (%rsp), %rdi
movq %rax, 0x10(%r8)
movl 0x4(%r13), %eax
shlq $0x20, %rax
movl 0x8(%rbx,%r15), %ecx
orq %rax, %rcx
movq (%r8), %rax
movq 0x10(%r8), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, (%r8)
movq %rcx, (%rdx,%rax,8)
incl %r14d
jmp 0x20b17d
incl %ebp
addq $0xc, %r15
cmpq %r15, %r12
jne 0x20b0a1
movq 0x30(%rsp), %rax
incq %rax
cmpq 0x28(%rsp), %rax
jne 0x20b081
jmp 0x20b1a4
xorl %r14d, %r14d
xorl %ebp, %ebp
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x20b1b0
movl %ebp, (%rax)
movl %r14d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3106f(%rip), %rdi     # 0x23c238
leaq 0x2e155(%rip), %rsi     # 0x239325
leaq 0x31074(%rip), %rcx     # 0x23c24b
movl $0x2cda, %edx           # imm = 0x2CDA
callq 0x2110