// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
movq %rdi, %rbx
movq (%rdi), %rax
movl 0x48(%rdi), %ecx
cmpq %rcx, %rax
jbe 0x1b7bb3
cmpq %rax, 0x88(%rbx)
jae 0x1b7b14
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 0x1b7b7a
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
movl %ecx, %edx
cmpq %rdx, %rax
jbe 0x1b7baa
movq 0xa8(%rbx), %rsi
movl %ecx, (%rsi,%rdx,4)
movq 0x90(%rbx), %rsi
movl %ecx, (%rsi,%rdx,4)
incl %ecx
jmp 0x1b7b8b
movq 0x18(%rbx), %rcx
movl 0x4c(%rbx), %edx
jmp 0x1b7bc1
movq 0x18(%rbx), %rcx
movl 0x4c(%rbx), %edx
xorl %eax, %eax
cmpq %rdx, %rcx
jbe 0x1b7c0c
cmpq %rdx, %rcx
jbe 0x1b7c02
movl %edx, %edx
cmpq %rdx, %rcx
jbe 0x1b7c02
movq 0x28(%rbx), %rax
movq %rdx, %rdi
shlq $0x4, %rdi
movq (%rax,%rdi), %rsi
btq $0x20, %rsi
jb 0x1b7bfe
addq %rdi, %rax
movq 0xa8(%rbx), %rdi
shrq $0x21, %rsi
movl (%rdi,%rsi,4), %esi
movl 0x8(%rax), %eax
shrl %eax
cmpl (%rdi,%rax,4), %esi
jae 0x1b7c0e
incl %edx
jmp 0x1b7bc6
movq %rbx, %rdi
callq 0x1b6311
xorl %eax, %eax
popq %rbx
retq
movq %rbx, %rdi
callq 0x1b6311
movq %rbx, %rdi
callq 0x1b73c3
xorl $0x1, %eax
jmp 0x1b7c0c