// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: u2g_n_hybrid_thread(usg_t*, unsigned int, asg64_v*, asg64_v*)
uint32_t u2g_n_hybrid_thread(usg_t *ng, uint32_t no_inconsist, asg64_v *in, asg64_v *buf)
{
    if(in->n < 1) return 0;
    uint32_t k, i, v, w, in_n = in->n, mm, ov[2], kv[2], cnt = 0; uint64_t *a, a_n;
    for (k = 0; k < in->n; k++) {
        v = (uint32_t)in->a[k]; in_n = in->n;
        if(get_usg_unitig(ng, v^1, &w, NULL, NULL, NULL, NULL) == LOOP) continue;
        mm = get_junction_w(ng, v, w, no_inconsist, in);
        if(mm == (uint32_t)-1) {
            in->n = in_n; continue;
        }
        if(in->n == in_n) continue;

        ov[0] = ov[1] = 0; a = in->a + in_n; a_n = in->n - in_n;
        for (i = 0; i < a_n; i++) {
            if((a[i]>>32) == v) ov[0]++;
            if((a[i]>>32) == w) ov[1]++;
        }

        kv[0] = undel_arcs(ng, v, NULL); kv[1] = undel_arcs(ng, w, NULL);
        assert(ov[0] == ov[1] && ov[0] <= kv[0] && ov[1] <= kv[1]); 
        if((ov[0] == kv[0] && ov[1] < kv[1]) || (ov[0] < kv[0] && ov[1] == kv[1])) {
            in->n = in_n; continue;
        }
        
        for (i = 0; i < a_n; i += 2) {
            update_dual_junction(ng, a[i]>>32, (uint32_t)a[i], a[i+1]>>32, (uint32_t)a[i+1], buf);
        }
        cnt++; in->n = in_n;
    }

    return cnt;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, 0x2c(%rsp)
movq (%rdx), %rbp
testq %rbp, %rbp
je 0x2175ab
movq %rdx, %r13
movq %rdi, %r12
xorl %ebx, %ebx
movl $0x0, 0x4(%rsp)
movq %rcx, 0x30(%rsp)
movq %rdx, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
movq 0x10(%r13), %rax
movq (%rax,%rbx,8), %rsi
movl %esi, %eax
xorl $0x1, %eax
movq (%r12), %rcx
movl %eax, %r12d
movl %r12d, %edi
shrl %edi
movl %r12d, %r8d
andl $0x1, %r8d
imulq $0x78, %rdi, %r15
leaq (%rcx,%r15), %rdi
leaq (%r8,%r8,2), %r14
movl 0x10(%rdi,%r14,8), %r11d
testq %r11, %r11
je 0x2173f8
movq 0x20(%rdi,%r14,8), %rdi
shlq $0x5, %r11
xorl %r8d, %r8d
xorl %r9d, %r9d
movl 0xc(%rdi,%r8), %r10d
notl %r10d
shrl $0x1f, %r10d
addl %r10d, %r9d
addq $0x20, %r8
cmpq %r8, %r11
jne 0x21735c
cmpl $0x1, %r9d
jne 0x2173f8
xorl %r8d, %r8d
cmpl $0x0, 0xc(%rdi,%r8)
js 0x21738a
movl 0x8(%rdi,%r8), %edx
addq $0x20, %r8
cmpq %r8, %r11
jne 0x21737d
movl %edx, %r8d
notl %r8d
movl %edx, %edi
shrl %edi
andl $0x1, %r8d
imulq $0x78, %rdi, %rdi
addq %rcx, %rdi
leaq (%r8,%r8,2), %r8
movl 0x10(%rdi,%r8,8), %r11d
testq %r11, %r11
je 0x2173f8
movq 0x20(%rdi,%r8,8), %rdi
shlq $0x5, %r11
xorl %r8d, %r8d
xorl %r9d, %r9d
movl 0xc(%rdi,%r8), %r10d
notl %r10d
shrl $0x1f, %r10d
addl %r10d, %r9d
addq $0x20, %r8
cmpq %r8, %r11
jne 0x2173c5
cmpl $0x1, %r9d
jne 0x2173f8
movl %edx, %r12d
cmpl %eax, %edx
jne 0x217327
movq 0x8(%rsp), %r12
jmp 0x21759e
movq %rbx, 0x20(%rsp)
movq 0x8(%rsp), %rdi
movq %rsi, %rbx
movl %r12d, %edx
movl 0x2c(%rsp), %ecx
movq %r13, %r8
callq 0x2166ff
cmpl $-0x1, %eax
je 0x21743c
movq (%r13), %rax
movl %ebp, %ebp
movq %rbp, %rcx
movq %rax, %rbp
subq %rcx, %rbp
jne 0x21744d
movq %rax, %rbp
movq 0x8(%rsp), %r12
movq 0x20(%rsp), %rbx
jmp 0x21759e
movl %ebp, %ebp
movq 0x8(%rsp), %r12
movq 0x20(%rsp), %rbx
jmp 0x21759a
movq %r13, %rax
movq %rcx, 0x18(%rsp)
leaq (,%rcx,8), %r13
addq 0x10(%rax), %r13
movl %ebx, %edx
movl %r12d, %esi
xorl %edi, %edi
xorl %ecx, %ecx
xorl %eax, %eax
movq (%r13,%rdi,8), %r8
shrq $0x20, %r8
xorl %r9d, %r9d
cmpq %rdx, %r8
sete %r9b
addl %r9d, %ecx
xorl %r9d, %r9d
cmpq %rsi, %r8
sete %r9b
addl %r9d, %eax
incq %rdi
movl %edi, %r8d
cmpq %r8, %rbp
ja 0x21746c
movq 0x8(%rsp), %r12
movq (%r12), %rdi
movl %ebx, %edx
shrl %edx
andl $0x1, %ebx
imulq $0x78, %rdx, %r9
addq %rdi, %r9
leaq (%rbx,%rbx,2), %r10
movl 0x10(%r9,%r10,8), %r8d
xorl %edx, %edx
movl $0x0, %esi
testq %r8, %r8
je 0x2174ec
movq 0x20(%r9,%r10,8), %r9
shlq $0x5, %r8
xorl %r10d, %r10d
xorl %esi, %esi
movl 0xc(%r9,%r10), %r11d
notl %r11d
shrl $0x1f, %r11d
addl %r11d, %esi
addq $0x20, %r10
cmpq %r10, %r8
jne 0x2174d4
addq %r15, %rdi
movl 0x10(%rdi,%r14,8), %r8d
testq %r8, %r8
movq 0x20(%rsp), %rbx
je 0x217524
movq 0x20(%rdi,%r14,8), %rdi
shlq $0x5, %r8
xorl %r9d, %r9d
xorl %edx, %edx
movl 0xc(%rdi,%r9), %r10d
notl %r10d
shrl $0x1f, %r10d
addl %r10d, %edx
addq $0x20, %r9
cmpq %r9, %r8
jne 0x21750c
cmpl %eax, %ecx
movq 0x30(%rsp), %r15
jne 0x2175c6
cmpl %esi, %ecx
ja 0x2175c6
cmpl %edx, %eax
ja 0x2175c6
cmpl %esi, %eax
jne 0x217549
cmpl %edx, %eax
jb 0x217590
cmpl %esi, %eax
jae 0x217551
cmpl %edx, %eax
je 0x217590
movl $0x2, %r14d
xorl %eax, %eax
movq (%r13,%rax,8), %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
leal -0x1(%r14), %eax
movq (%r13,%rax,8), %r8
movq %r8, %rcx
shrq $0x20, %rcx
movq %r12, %rdi
movq %r15, %r9
callq 0x216de2
movl %r14d, %eax
addl $0x2, %r14d
cmpq %rax, %rbp
ja 0x217559
incl 0x4(%rsp)
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbp
movq %rbp, (%r13)
incl %ebx
cmpq %rbx, %rbp
ja 0x217313
jmp 0x2175b3
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x31117(%rip), %rdi     # 0x2486e4
leaq 0x2e035(%rip), %rsi     # 0x245609
leaq 0x3113c(%rip), %rcx     # 0x248717
movl $0x2dd2, %edx           # imm = 0x2DD2
callq 0x2110