// File: /workspace/github_cpp_makefile_star2_O1/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)
movl $0x0, 0xc(%rsp)
cmpq $0x0, (%rdx)
je 0x20c27c
movq %rdx, %r13
movq %rcx, 0x30(%rsp)
movq (%rdx), %r14
testq %r14, %r14
je 0x20c27c
movq %rdi, %r12
xorl %ebp, %ebp
movl $0x0, 0xc(%rsp)
movq %r13, 0x18(%rsp)
movq %rdi, (%rsp)
movq 0x10(%r13), %rax
movq (%rax,%rbp,8), %rcx
movq %rcx, %rax
movq %rcx, 0x20(%rsp)
xorl $0x1, %eax
movq (%r12), %rcx
movl %eax, %r12d
movl %r12d, %esi
shrl %esi
movl %r12d, %edi
andl $0x1, %edi
imulq $0x78, %rsi, %r15
leaq (%rcx,%r15), %rsi
leaq (%rdi,%rdi,2), %rbx
movl 0x10(%rsi,%rbx,8), %r8d
testq %r8, %r8
je 0x20c0c8
movq 0x20(%rsi,%rbx,8), %rsi
movq %r8, %rdi
shlq $0x5, %rdi
xorl %r9d, %r9d
xorl %r10d, %r10d
movl 0xc(%rsi,%r9), %r11d
notl %r11d
shrl $0x1f, %r11d
addl %r11d, %r10d
addq $0x20, %r9
cmpq %r9, %rdi
jne 0x20c032
cmpl $0x1, %r10d
jne 0x20c0c8
testq %r8, %r8
je 0x20c06e
xorl %r8d, %r8d
cmpl $0x0, 0xc(%rsi,%r8)
js 0x20c065
movl 0x8(%rsi,%r8), %edx
addq $0x20, %r8
cmpq %r8, %rdi
jne 0x20c058
movl %edx, %esi
notl %esi
movl %edx, %edi
shrl %edi
andl $0x1, %esi
imulq $0x78, %rdi, %rdi
addq %rcx, %rdi
leaq (%rsi,%rsi,2), %r8
movl 0x10(%rdi,%r8,8), %esi
testq %rsi, %rsi
je 0x20c0c8
movq 0x20(%rdi,%r8,8), %rdi
shlq $0x5, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
movl 0xc(%rdi,%r8), %r10d
notl %r10d
shrl $0x1f, %r10d
addl %r10d, %r9d
addq $0x20, %r8
cmpq %r8, %rsi
jne 0x20c09d
cmpl $0x1, %r9d
jne 0x20c0c8
movl %edx, %r12d
cmpl %eax, %edx
jne 0x20bffb
jmp 0x20c0f4
movq (%rsp), %rdi
movq 0x20(%rsp), %rsi
movl %r12d, %edx
movl 0x2c(%rsp), %ecx
movq %r13, %r8
callq 0x20b385
cmpl $-0x1, %eax
je 0x20c0fd
movq (%r13), %rax
movl %r14d, %edx
movq %rax, %r14
subq %rdx, %r14
jne 0x20c109
movq (%rsp), %r12
jmp 0x20c26d
movl %r14d, %eax
movq (%rsp), %r12
jmp 0x20c269
movq %r13, %rcx
movq %rdx, 0x10(%rsp)
leaq (,%rdx,8), %r13
addq 0x10(%rcx), %r13
movl 0x20(%rsp), %esi
movl %r12d, %edi
xorl %r8d, %r8d
xorl %edx, %edx
xorl %ecx, %ecx
movq (%r13,%r8,8), %r9
shrq $0x20, %r9
xorl %r10d, %r10d
cmpq %rsi, %r9
sete %r10b
addl %r10d, %edx
xorl %r10d, %r10d
cmpq %rdi, %r9
sete %r10b
addl %r10d, %ecx
incq %r8
movl %r8d, %r9d
cmpq %r9, %r14
ja 0x20c12b
movq (%rsp), %rsi
movq (%rsi), %r8
movq 0x20(%rsp), %rdi
movl %edi, %esi
shrl %esi
andl $0x1, %edi
imulq $0x78, %rsi, %r10
addq %r8, %r10
leaq (%rdi,%rdi,2), %r11
movl 0x10(%r10,%r11,8), %r9d
xorl %esi, %esi
movl $0x0, %edi
testq %r9, %r9
je 0x20c1ae
movq 0x20(%r10,%r11,8), %r10
shlq $0x5, %r9
xorl %r11d, %r11d
xorl %edi, %edi
movl 0xc(%r10,%r11), %r12d
notl %r12d
shrl $0x1f, %r12d
addl %r12d, %edi
addq $0x20, %r11
cmpq %r11, %r9
jne 0x20c196
addq %r15, %r8
movl 0x10(%r8,%rbx,8), %r9d
testq %r9, %r9
je 0x20c1e1
movq 0x20(%r8,%rbx,8), %r8
shlq $0x5, %r9
xorl %r10d, %r10d
xorl %esi, %esi
movl 0xc(%r8,%r10), %r11d
notl %r11d
shrl $0x1f, %r11d
addl %r11d, %esi
addq $0x20, %r10
cmpq %r10, %r9
jne 0x20c1c9
cmpl %ecx, %edx
jne 0x20c28f
cmpl %edi, %edx
ja 0x20c28f
cmpl %esi, %ecx
ja 0x20c28f
cmpl %edi, %edx
jne 0x20c20c
cmpl %esi, %ecx
jae 0x20c20c
movq 0x18(%rsp), %r13
movq (%rsp), %r12
jmp 0x20c264
cmpl %edi, %edx
movq (%rsp), %r12
jae 0x20c218
cmpl %esi, %ecx
je 0x20c25f
cmpq 0x10(%rsp), %rax
movq 0x30(%rsp), %r15
je 0x20c25b
movl $0x2, %ebx
xorl %eax, %eax
movq (%r13,%rax,8), %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
leal -0x1(%rbx), %eax
movq (%r13,%rax,8), %r8
movq %r8, %rcx
shrq $0x20, %rcx
movq %r12, %rdi
movq %r15, %r9
callq 0x20ba81
movl %ebx, %eax
addl $0x2, %ebx
cmpq %rax, %r14
ja 0x20c22b
incl 0xc(%rsp)
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %rax
movq %rax, (%r13)
incl %ebp
movq (%r13), %r14
cmpq %rbp, %r14
ja 0x20bfe1
movl 0xc(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3016a(%rip), %rdi     # 0x23c400
leaq 0x2d088(%rip), %rsi     # 0x239325
leaq 0x3018f(%rip), %rcx     # 0x23c433
movl $0x2dd2, %edx           # imm = 0x2DD2
callq 0x2110