// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: update_poa_dp(poa_g_t*, unsigned int, ma_ug_t*)
uint32_t update_poa_dp(poa_g_t *g, uint32_t debug_qid, ma_ug_t *debug_ug)
{
    uint32_t is_srt = 0/**, is_up_aln = 0**/, k, is_circle = 0;
    if(g->seq.n > g->update_seq || g->arc.n > g->update_arc) {
        if(g->seq.n > g->update_seq) {
            kv_resize(uint32_t, g->srt_b.res, g->seq.n);
            kv_resize(uint32_t, g->srt_b.res2nid, g->seq.n);
            // kv_resize(uint64_t, g->srt_b.aln, g->seq.n); g->srt_b.aln.n = g->seq.n;
            g->srt_b.res.n = g->srt_b.res2nid.n = g->seq.n;
            for (k = g->update_seq; k < g->seq.n; k++) {
                g->srt_b.res.a[k] = g->srt_b.res2nid.a[k] = k;
                // g->srt_b.aln.a[k] = (((uint64_t)(g->seq.a[k].nid))<<32)+k;
                // if(k > 0 && is_up_aln == 0) {
                //     if((g->srt_b.aln.a[k]>>32) < (g->srt_b.aln.a[k-1]>>32)) is_up_aln = 1;
                // }
            }
        }
        if(g->arc.n > g->update_arc) { ///check if it is necessary to resort
            for (k = g->update_arc; k < g->arc.n; k++) {
                if((g->arc.a[k].ul>>32)&1) continue;
                if(g->srt_b.res2nid.a[g->arc.a[k].ul>>33] >= g->srt_b.res2nid.a[g->arc.a[k].v>>1]) break;
            }
            if(k < g->arc.n) is_srt = 1;
        }
        // fprintf(stderr, "[M::%s::] is_srt::%u\n", __func__, is_srt);
        clean_poa_g_t(g); 
        if(is_srt) {
            is_circle = 1 - topo_srt_gen(g, debug_qid, debug_ug);
        } 
        // else if(is_up_aln) {
        //     radix_sort_srt64(g->srt_b.aln.a, g->srt_b.aln.a + g->srt_b.aln.n);
        // }
    }

    return is_circle;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rax
movl 0x48(%rdi), %ecx
cmpq %rcx, %rax
jbe 0x1f833e
cmpq %rax, 0x88(%rbx)
jae 0x1f82a2
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x88(%rbx)
movq 0x90(%rbx), %rdi
leaq 0x4(,%rcx,4), %rsi
callq 0x2370
movq %rax, 0x90(%rbx)
movq (%rbx), %rax
cmpq %rax, 0xa0(%rbx)
jae 0x1f8308
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0xa0(%rbx)
movq 0xa8(%rbx), %rdi
leaq 0x4(,%rcx,4), %rsi
callq 0x2370
movq %rax, 0xa8(%rbx)
movq (%rbx), %rax
movq %rax, 0x98(%rbx)
movq %rax, 0x80(%rbx)
movl 0x48(%rbx), %ecx
cmpq %rcx, %rax
jbe 0x1f8350
movq 0x90(%rbx), %rdx
movq 0xa8(%rbx), %rsi
movl %ecx, (%rsi,%rcx,4)
movl %ecx, (%rdx,%rcx,4)
incl %ecx
cmpq %rcx, %rax
ja 0x1f832f
jmp 0x1f8350
movl 0x4c(%rbx), %edx
cmpq %rdx, 0x18(%rbx)
jbe 0x1f83aa
cmpq %rcx, %rax
ja 0x1f823f
movq 0x18(%rbx), %rax
movl 0x4c(%rbx), %ecx
cmpq %rcx, %rax
jbe 0x1f83a2
seta %bpl
jbe 0x1f83a2
movq 0x28(%rbx), %rdx
leal 0x1(%rcx), %esi
shlq $0x4, %rcx
movq (%rdx,%rcx), %rdi
btq $0x20, %rdi
jb 0x1f8395
addq %rdx, %rcx
movq 0xa8(%rbx), %r8
shrq $0x21, %rdi
movl (%r8,%rdi,4), %edi
movl 0x8(%rcx), %ecx
shrl %ecx
cmpl (%r8,%rcx,4), %edi
jae 0x1f83b3
movl %esi, %ecx
incl %esi
cmpq %rcx, %rax
seta %bpl
ja 0x1f8369
movq %rbx, %rdi
callq 0x1f6ab3
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
callq 0x1f6ab3
testb $0x1, %bpl
je 0x1f83aa
movq %rbx, %rdi
callq 0x1f7ad8
xorl $0x1, %eax
jmp 0x1f83ac