// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: usg_topocut_aux(ul_resolve_t*, ma_ug_t*, unsigned int, int, int, asg64_v*, asg64_v*)
int32_t usg_topocut_aux(ul_resolve_t *uidx, ma_ug_t *ug, uint32_t v, int32_t max_ext, int32_t max_ext_hifi, asg64_v *b, asg64_v *ub)
{
    int32_t n_ext; asg_arc_t *av; uint32_t w = v, nv, i, kv, ul_occ, pn = b->n;
    for (n_ext = 0; n_ext < max_ext; v = w) {
        av = asg_arc_a(ug->g, v^1); nv = asg_arc_n(ug->g, v^1);
        for (i = kv = 0; i < nv && kv <= 1; i++) {
            if (av[i].del) continue;
            kv++; 
        }
        if(kv!=1) break;
        get_iug_u_raw_occ(uidx, v>>1, &ul_occ, NULL); n_ext += ul_occ; kv_push(uint64_t, *b, v);

        av = asg_arc_a(ug->g, v); nv = asg_arc_n(ug->g, v);
        for (i = kv = 0; i < nv && kv <= 1; i++) {
            if (av[i].del) continue;
            kv++; w = av[i].v;
        }
        if(kv!=1) break;
    }

    if(n_ext < max_ext) {
        if(get_remove_hifi_occ(uidx, max_ext_hifi, b->a + pn, b->n - pn, ub, NULL)) {
            b->n = pn;
            return 1;
        }
    }

    b->n = pn;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movl %r8d, 0xc(%rsp)
movl %ecx, %r12d
movl %edx, %r14d
movq %rsi, %r13
movq %rdi, %r15
movl (%r9), %eax
movq %rax, 0x10(%rsp)
xorl %ebp, %ebp
cmpl %r12d, %ebp
jge 0x201497
movq 0x18(%r13), %rcx
movq 0x28(%rcx), %rax
movl %r14d, %edx
xorl $0x1, %edx
movq (%rax,%rdx,8), %rax
testl %eax, %eax
je 0x201497
movq 0x8(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %rcx
addq $0xc, %rcx
xorl %esi, %esi
movl $0x1, %edx
movl %esi, %edi
movl (%rcx), %esi
notl %esi
shrl $0x1f, %esi
addl %edi, %esi
cmpl %eax, %edx
jae 0x2013e2
incl %edx
addq $0x18, %rcx
cmpl $0x2, %esi
jb 0x2013c8
cmpl $0x1, %esi
jne 0x201497
movl %r14d, %eax
shrl %eax
movq 0x258(%r15), %rcx
addl (%rcx,%rax,4), %ebp
movq 0x8(%rbx), %rax
cmpq %rax, (%rbx)
jne 0x201428
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x10(%rbx)
movl %r14d, %eax
movq (%rbx), %rcx
movq 0x10(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx)
movq %rax, (%rdx,%rcx,8)
movq 0x18(%r13), %rdx
movq 0x28(%rdx), %rcx
movq (%rcx,%rax,8), %rcx
xorl %eax, %eax
testl %ecx, %ecx
je 0x20148f
movq 0x8(%rdx), %rdx
movq %rcx, %rsi
shrq $0x20, %rsi
movl %ecx, %ecx
leaq (%rsi,%rsi,2), %rsi
leaq (%rdx,%rsi,8), %rdx
addq $0xc, %rdx
movl $0x1, %esi
cmpl $0x0, (%rdx)
js 0x201478
incl %eax
movl -0x4(%rdx), %r14d
cmpq %rcx, %rsi
jae 0x201489
addq $0x18, %rdx
incq %rsi
cmpl $0x2, %eax
jb 0x20146d
cmpl $0x1, %eax
sete %al
testb %al, %al
jne 0x201387
cmpl %r12d, %ebp
movq 0x10(%rsp), %r14
jge 0x2014d5
movslq 0xc(%rsp), %rsi
leaq (,%r14,8), %rdx
addq 0x10(%rbx), %rdx
movq (%rbx), %rcx
subq %r14, %rcx
movq %r15, %rdi
movq 0x50(%rsp), %r8
xorl %r9d, %r9d
callq 0x22129a
movq %rax, %rcx
movl $0x1, %eax
testq %rcx, %rcx
jne 0x2014d7
xorl %eax, %eax
movq %r14, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq