// File: /workspace/github_cpp_makefile_star2_O2/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 $0x48, %rsp
movl %esi, 0x2c(%rsp)
movq (%rdx), %r14
testq %r14, %r14
je 0x1c9195
movq %rdx, %r13
movq %rdi, %rbx
movq $0x0, 0x20(%rsp)
xorl %ebp, %ebp
movq %rcx, 0x40(%rsp)
movq %rdx, 0x30(%rsp)
movq %rdi, 0x18(%rsp)
movl %ebp, %ebp
cmpq %rbp, %r14
jbe 0x1c918e
movq 0x10(%r13), %rax
movq (%rax,%rbp,8), %r15
movl %r15d, %esi
xorl $0x1, %esi
andq $0x0, (%rsp)
movq %rbx, %rdi
leaq 0x14(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1dee72
cmpl $0x7, %eax
jne 0x1c903b
movq (%r13), %r14
jmp 0x1c9187
movl 0x14(%rsp), %edx
movq %rbx, %rdi
movl %r15d, %esi
movl 0x2c(%rsp), %ecx
movq %r13, %r8
callq 0x1c852c
cmpl $-0x1, %eax
je 0x1c906d
movq (%r13), %rax
movl %r14d, %r14d
movq %rax, %rbx
subq %r14, %rbx
jne 0x1c9079
movq %rax, %r14
jmp 0x1c9182
movl %r14d, %r14d
movq %r14, (%r13)
jmp 0x1c9187
movl %r15d, %eax
movq %r14, 0x38(%rsp)
leaq (,%r14,8), %r14
addq 0x10(%r13), %r14
movl 0x14(%rsp), %ecx
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %edx, %edx
movl %edx, %edx
cmpq %rdx, %rbx
jbe 0x1c90c4
movq (%r14,%rdx,8), %rsi
shrq $0x20, %rsi
xorl %edi, %edi
cmpq %rax, %rsi
sete %dil
addl %edi, %r13d
xorl %edi, %edi
cmpq %rcx, %rsi
sete %dil
addl %edi, %r12d
incl %edx
jmp 0x1c9099
movq 0x18(%rsp), %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x1df024
movl %eax, %r15d
movl 0x14(%rsp), %esi
movq 0x18(%rsp), %rdi
xorl %edx, %edx
callq 0x1df024
cmpl %r12d, %r13d
jne 0x1c91a6
cmpl %r15d, %r13d
ja 0x1c91a6
cmpl %eax, %r12d
ja 0x1c91a6
cmpl %r15d, %r12d
sete %cl
cmpl %eax, %r12d
setb %dl
testb %dl, %cl
jne 0x1c9121
cmpl %r15d, %r12d
setb %cl
cmpl %eax, %r12d
sete %al
testb %al, %cl
je 0x1c9128
movq 0x30(%rsp), %r13
jmp 0x1c9179
pushq $0x1
popq %rax
movl %eax, %r15d
movq 0x40(%rsp), %r12
movq 0x30(%rsp), %r13
leal -0x1(%r15), %eax
cmpq %rax, %rbx
jbe 0x1c916d
movq (%r14,%rax,8), %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
movl %r15d, %eax
movq (%r14,%rax,8), %r8
movq %r8, %rcx
shrq $0x20, %rcx
movq 0x18(%rsp), %rdi
movq %r12, %r9
callq 0x1c8b60
addl $0x2, %r15d
jmp 0x1c9138
movq 0x20(%rsp), %rax
incl %eax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %r14
movq %r14, (%r13)
movq 0x18(%rsp), %rbx
incl %ebp
jmp 0x1c8ffa
movq 0x20(%rsp), %rax
jmp 0x1c9197
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x314f6(%rip), %rdi     # 0x1fa6a3
leaq 0x2e325(%rip), %rsi     # 0x1f74d9
leaq 0x3151b(%rip), %rcx     # 0x1fa6d6
movl $0x2dd2, %edx           # imm = 0x2DD2
callq 0x2110